首次提交
This commit is contained in:
30
.gitignore
vendored
Normal file
30
.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
### IntelliJ IDEA ###
|
||||||
|
out/
|
||||||
|
!**/src/main/**/out/
|
||||||
|
!**/src/test/**/out/
|
||||||
|
.idea
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
bin/
|
||||||
|
!**/src/main/**/bin/
|
||||||
|
!**/src/test/**/bin/
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
||||||
33
MC_TP.iml
Normal file
33
MC_TP.iml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>SPIGOT</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
<projectReimportVersion>1</projectReimportVersion>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="spigot-api-1.20.4-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="核心支持库" level="project" />
|
||||||
|
<orderEntry type="library" name="ling.json" level="project" />
|
||||||
|
<orderEntry type="module-library">
|
||||||
|
<library>
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/24.0.0/annotations-24.0.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC />
|
||||||
|
<SOURCES />
|
||||||
|
</library>
|
||||||
|
</orderEntry>
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
BIN
lib/ling.json.jar
Normal file
BIN
lib/ling.json.jar
Normal file
Binary file not shown.
BIN
lib/spigot-api-1.20.4-R0.1-SNAPSHOT.jar
Normal file
BIN
lib/spigot-api-1.20.4-R0.1-SNAPSHOT.jar
Normal file
Binary file not shown.
BIN
lib/核心支持库.jar
Normal file
BIN
lib/核心支持库.jar
Normal file
Binary file not shown.
9
resources/plugin.yml
Normal file
9
resources/plugin.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
name: ZuoBiaoGuanLiQi
|
||||||
|
main: mc.tp.Main
|
||||||
|
version: 1.0
|
||||||
|
api-version: 1.17
|
||||||
|
commands:
|
||||||
|
zb:
|
||||||
|
usage: "/zb <选项> <参数>"
|
||||||
|
description: "使用坐标管理器来管理坐标"
|
||||||
|
|
||||||
52
src/mc/tp/Main.java
Normal file
52
src/mc/tp/Main.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import ling.json.JSONObject;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.PluginCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class Main extends JavaPlugin {
|
||||||
|
public static final HashMap<Player, 玩家对象> playerMap = new HashMap<>();
|
||||||
|
private static Main 插件实例;
|
||||||
|
protected static Logger logger;
|
||||||
|
|
||||||
|
public Main() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
try {
|
||||||
|
new JSONObject();
|
||||||
|
插件实例 = this;
|
||||||
|
logger = this.getLogger();
|
||||||
|
Bukkit.getPluginManager().registerEvents(new 坐标记录器(), this);
|
||||||
|
命令处理器 obj = new 命令处理器();
|
||||||
|
((PluginCommand)Objects.requireNonNull(Bukkit.getPluginCommand("zb"))).setExecutor(obj);
|
||||||
|
((PluginCommand)Objects.requireNonNull(Bukkit.getPluginCommand("zb"))).setTabCompleter(obj);
|
||||||
|
this.getLogger().info("坐标管理器加载成功!");
|
||||||
|
} catch (Exception var2) {
|
||||||
|
var2.printStackTrace();
|
||||||
|
this.getLogger().info("坐标管理器注册失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void info(String msg) {
|
||||||
|
logger.info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Main get插件实例() {
|
||||||
|
return 插件实例;
|
||||||
|
}
|
||||||
|
}
|
||||||
99
src/mc/tp/传送/传送栈.java
Normal file
99
src/mc/tp/传送/传送栈.java
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.传送;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class 传送栈 {
|
||||||
|
protected static final List<传送记录> 传送栈 = new ArrayList();
|
||||||
|
public static final HashMap<UUID, 历史记录> 撤销栈 = new HashMap();
|
||||||
|
|
||||||
|
public 传送栈() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void 筛选过期请求() {
|
||||||
|
List<传送记录> temp = new ArrayList();
|
||||||
|
Iterator var1 = 传送栈.iterator();
|
||||||
|
|
||||||
|
传送记录 传送记录;
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
传送记录 = (传送记录)var1.next();
|
||||||
|
if (传送记录.是否过期()) {
|
||||||
|
temp.add(传送记录);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var1 = temp.iterator();
|
||||||
|
|
||||||
|
while(var1.hasNext()) {
|
||||||
|
传送记录 = (传送记录)var1.next();
|
||||||
|
ChatColor var10001 = ChatColor.RED;
|
||||||
|
传送记录.来源.sendMessage("" + var10001 + "玩家[" + 传送记录.目标.getName() + "]超时未回应。");
|
||||||
|
传送记录.目标.sendMessage("超时未回应,来自玩家[" + 传送记录.来源.getName() + "]的传送请求被自动拒绝。");
|
||||||
|
传送栈.remove(传送记录);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static 传送记录 查询目标(Player player) {
|
||||||
|
Iterator var1 = 传送栈.iterator();
|
||||||
|
|
||||||
|
传送记录 传送记录;
|
||||||
|
do {
|
||||||
|
if (!var1.hasNext()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
传送记录 = (传送记录)var1.next();
|
||||||
|
} while(!传送记录.目标.getUniqueId().equals(player.getUniqueId()));
|
||||||
|
|
||||||
|
return 传送记录;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static 传送记录 查询来源(Player player) {
|
||||||
|
Iterator var1 = 传送栈.iterator();
|
||||||
|
|
||||||
|
传送记录 传送记录;
|
||||||
|
do {
|
||||||
|
if (!var1.hasNext()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
传送记录 = (传送记录)var1.next();
|
||||||
|
} while(!传送记录.来源.getUniqueId().equals(player.getUniqueId()));
|
||||||
|
|
||||||
|
return 传送记录;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void 删除记录(传送记录 data) {
|
||||||
|
传送栈.remove(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void 添加记录(传送记录 data) {
|
||||||
|
传送栈.add(data);
|
||||||
|
data.来源.sendMessage("已经向玩家[" + data.目标.getName() + "]发送传送请求,等待回应。");
|
||||||
|
data.目标.sendMessage("玩家[" + data.来源.getName() + "]请求向你传送,执行/zb yes同意该请求,/zb no拒绝");
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
(new Thread(() -> {
|
||||||
|
try {
|
||||||
|
while(true) {
|
||||||
|
筛选过期请求();
|
||||||
|
Thread.sleep(15000L);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException var1) {
|
||||||
|
var1.printStackTrace();
|
||||||
|
}
|
||||||
|
})).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/mc/tp/传送/传送记录.java
Normal file
25
src/mc/tp/传送/传送记录.java
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.传送;
|
||||||
|
|
||||||
|
import ling.android.操作.时间操作;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class 传送记录 {
|
||||||
|
public final Player 来源;
|
||||||
|
public final Player 目标;
|
||||||
|
public final long 创建时间;
|
||||||
|
|
||||||
|
public 传送记录(Player 来源, Player 目标) {
|
||||||
|
this.来源 = 来源;
|
||||||
|
this.目标 = 目标;
|
||||||
|
this.创建时间 = 时间操作.取时间戳();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean 是否过期() {
|
||||||
|
return 时间操作.取时间戳() - this.创建时间 > 15000L;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/mc/tp/传送/历史记录.java
Normal file
22
src/mc/tp/传送/历史记录.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.传送;
|
||||||
|
|
||||||
|
import ling.android.操作.时间操作;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class 历史记录 {
|
||||||
|
public final long 创建时间 = 时间操作.取时间戳();
|
||||||
|
public final Location location;
|
||||||
|
|
||||||
|
public 历史记录(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean 是否过期() {
|
||||||
|
return 时间操作.取时间戳() - this.创建时间 > 300000L;
|
||||||
|
}
|
||||||
|
}
|
||||||
305
src/mc/tp/命令处理器.java
Normal file
305
src/mc/tp/命令处理器.java
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ling.json.JSONException;
|
||||||
|
import mc.tp.传送.传送栈;
|
||||||
|
import mc.tp.传送.传送记录;
|
||||||
|
import mc.tp.传送.历史记录;
|
||||||
|
import mc.tp.坐标管理.对象;
|
||||||
|
import mc.tp.坐标管理.坐标管理器;
|
||||||
|
import mc.tp.坐标管理.记录;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class 命令处理器 implements CommandExecutor, TabCompleter {
|
||||||
|
public 命令处理器() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||||
|
if (commandSender instanceof Player player) {
|
||||||
|
try {
|
||||||
|
if (s.equals("zb")) {
|
||||||
|
if (strings.length == 0) {
|
||||||
|
this.渲染GUI(player);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return this.命令处理((Player) commandSender, strings);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (IndexOutOfBoundsException var7) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("该命令只能由玩家执行");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 渲染GUI(Player player) {
|
||||||
|
Inventory inv = Bukkit.createInventory(player, 54, "[坐标管理器]主菜单");
|
||||||
|
传送记录 map = 传送栈.查询目标(player);
|
||||||
|
ItemStack 撤销传送;
|
||||||
|
ItemMeta meta;
|
||||||
|
if (map != null) {
|
||||||
|
撤销传送 = new ItemStack(Material.ENDER_PEARL);
|
||||||
|
meta = 撤销传送.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("允许[" + map.来源.getName() + "]");
|
||||||
|
meta.setLore(Arrays.asList("将允许[" + map.来源.getName() + "]向您传送", ChatColor.RED + "您无法撤销这项决定!"));
|
||||||
|
撤销传送.setItemMeta(meta);
|
||||||
|
ItemStack 拒绝传送 = new ItemStack(Material.BARRIER);
|
||||||
|
meta = 拒绝传送.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("拒绝[" + map.来源.getName() + "]");
|
||||||
|
meta.setLore(Arrays.asList("将拒绝[" + map.来源.getName() + "]向您传送", "对方将收到您的提示!"));
|
||||||
|
拒绝传送.setItemMeta(meta);
|
||||||
|
inv.setItem(0, 撤销传送);
|
||||||
|
inv.setItem(8, 拒绝传送);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (传送栈.撤销栈.containsKey(player.getUniqueId())) {
|
||||||
|
历史记录 ret = (历史记录) 传送栈.撤销栈.get(player.getUniqueId());
|
||||||
|
if (!ret.是否过期()) {
|
||||||
|
撤销传送 = new ItemStack(Material.MINECART);
|
||||||
|
meta = 撤销传送.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("撤销传送");
|
||||||
|
meta.setLore(Arrays.asList("将您送回上次传送的起始位置", "坐标:", "X " + (int) ret.location.getX(), "Y " + (int) ret.location.getY(), "Z " + (int) ret.location.getZ()));
|
||||||
|
撤销传送.setItemMeta(meta);
|
||||||
|
inv.setItem(4, 撤销传送);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack 传送 = new ItemStack(Material.FILLED_MAP);
|
||||||
|
meta = 传送.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("坐标列表");
|
||||||
|
传送.setItemMeta(meta);
|
||||||
|
inv.setItem(9, 传送);
|
||||||
|
传送 = new ItemStack(Material.NETHERITE_SWORD);
|
||||||
|
meta = 传送.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("传送");
|
||||||
|
meta.setLore(Arrays.asList("您将在下个界面选择传送目标", ChatColor.RED + "此列表最多仅列出45个玩家", ChatColor.RED + "超过请手动输入命令"));
|
||||||
|
传送.setItemMeta(meta);
|
||||||
|
inv.setItem(17, 传送);
|
||||||
|
player.openInventory(inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean 命令处理(Player commandSender, String[] strings) {
|
||||||
|
switch (strings[0]) {
|
||||||
|
case "tp": {
|
||||||
|
Player player = Bukkit.getPlayer(strings[1]);
|
||||||
|
if (player == null) {
|
||||||
|
List<记录> items = 坐标管理器.读取数据(commandSender.getUniqueId().toString()).读取记录();
|
||||||
|
for (记录 item : items) {
|
||||||
|
if (item.getName().equals(strings[1])) {
|
||||||
|
历史记录 ret = new 历史记录(commandSender.getLocation());
|
||||||
|
传送栈.撤销栈.put(commandSender.getUniqueId(), ret);
|
||||||
|
commandSender.teleport(item.getLocation());
|
||||||
|
commandSender.sendMessage("已经将您传送到[" + item.getName() + "]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "对象不存在");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.getUniqueId().equals(commandSender.getUniqueId())) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "不能向自己传送!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
传送记录 data = new 传送记录(commandSender, player);
|
||||||
|
传送栈.添加记录(data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "no": {
|
||||||
|
传送记录 data = 传送栈.查询目标(commandSender);
|
||||||
|
if (data == null) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "没有找到指向您的传送请求!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
传送栈.删除记录(data);
|
||||||
|
commandSender.sendMessage("已拒绝[" + data.来源.getName() + "]。");
|
||||||
|
data.来源.sendMessage("[" + data.目标.getName() + "]拒绝了您。");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "yes": {
|
||||||
|
传送记录 data = 传送栈.查询目标(commandSender);
|
||||||
|
if (data == null) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "没有找到指向您的传送请求!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
传送栈.删除记录(data);
|
||||||
|
历史记录 ret = new 历史记录(data.来源.getLocation());
|
||||||
|
传送栈.撤销栈.put(data.来源.getUniqueId(), ret);
|
||||||
|
data.来源.teleport(data.目标.getLocation());
|
||||||
|
data.目标.sendMessage("已将[" + data.来源.getName() + "]传送到您身边。");
|
||||||
|
data.来源.sendMessage("已将您传送到[" + data.目标.getName() + "]身边。");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "return": {
|
||||||
|
if (!传送栈.撤销栈.containsKey(commandSender.getUniqueId())) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "没有找到传送历史,无法撤销!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
历史记录 data = (历史记录) 传送栈.撤销栈.get(commandSender.getUniqueId());
|
||||||
|
if (data.是否过期()) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "记录已经过期,无法撤销!");
|
||||||
|
传送栈.撤销栈.remove(commandSender.getUniqueId());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
commandSender.teleport(data.location);
|
||||||
|
传送栈.撤销栈.remove(commandSender.getUniqueId());
|
||||||
|
commandSender.sendMessage("撤销传送成功!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "add": {
|
||||||
|
if (strings.length < 2) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "请键入坐标名称。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
对象 obj = 坐标管理器.读取数据(commandSender.getUniqueId().toString());
|
||||||
|
List<记录> list = obj.读取记录();
|
||||||
|
|
||||||
|
for (记录 o : list) {
|
||||||
|
if (o.getName().equals(strings[1])) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "您不能添加重复的坐标名称!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
坐标管理器.添加坐标(commandSender.getUniqueId().toString(), strings[1], commandSender.getLocation());
|
||||||
|
((玩家对象) Main.playerMap.get(commandSender)).更新坐标栏();
|
||||||
|
break;
|
||||||
|
} catch (JSONException var10) {
|
||||||
|
var10.printStackTrace();
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "服务器内部错误!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "remove": {
|
||||||
|
if (strings.length < 2) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "请键入坐标名称。");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
对象 obj = 坐标管理器.读取数据(commandSender.getUniqueId().toString());
|
||||||
|
List<记录> list = obj.读取记录();
|
||||||
|
int index = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
if (((记录) list.get(i)).getName().equals(strings[1])) {
|
||||||
|
index = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index == -1) {
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "未找到坐标:" + strings[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
list.remove(index);
|
||||||
|
obj.写入记录(list);
|
||||||
|
((玩家对象) Main.playerMap.get(commandSender)).更新坐标栏();
|
||||||
|
commandSender.sendMessage("删除坐标成功");
|
||||||
|
break;
|
||||||
|
} catch (JSONException var9) {
|
||||||
|
var9.printStackTrace();
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "服务器内部错误!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
commandSender.sendMessage(ChatColor.RED + "语法错误!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
|
||||||
|
if (!(commandSender instanceof Player)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
ArrayList<String> list = new ArrayList<>();
|
||||||
|
if (strings.length != 0 && strings.length != 1) {
|
||||||
|
if (strings[0].equals("yes") || strings[0].equals("no") || strings[0].equals("return")) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
if (strings.length == 2 && strings[0].equals("tp")) {
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (!player.getUniqueId().equals(((Player) commandSender).getUniqueId())) {
|
||||||
|
list.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
对象 obj = 坐标管理器.读取数据(((Player) commandSender).getUniqueId().toString());
|
||||||
|
List<记录> temp = obj.读取记录();
|
||||||
|
for (记录 item : temp) {
|
||||||
|
list.add(item.getName());
|
||||||
|
}
|
||||||
|
list.add("<传送到坐标锚点时请确认目标点当前可以安全传送>");
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
if (strings.length > 2 && strings[0].equals("tp")) {
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
return (strings.length != 2 || !strings[0].equals("add")) && !strings[0].equals("remove") ? null : Collections.singletonList("<坐标名称>");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
list.add("tp");
|
||||||
|
list.add("yes");
|
||||||
|
list.add("no");
|
||||||
|
list.add("return");
|
||||||
|
list.add("add");
|
||||||
|
list.add("remove");
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
src/mc/tp/坐标管理/坐标管理器.java
Normal file
53
src/mc/tp/坐标管理/坐标管理器.java
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.坐标管理;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import ling.android.操作.文件操作;
|
||||||
|
import ling.json.JSONException;
|
||||||
|
import ling.json.JSONObject;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class 坐标管理器 {
|
||||||
|
public static String 主目录;
|
||||||
|
public static final String FS;
|
||||||
|
|
||||||
|
public 坐标管理器() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static 对象 读取数据(String UUID) {
|
||||||
|
return new 对象(UUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void 添加坐标(String UUID, String name, Location location) throws JSONException {
|
||||||
|
记录 data = new 记录(name, location);
|
||||||
|
对象 obj = 读取数据(UUID);
|
||||||
|
List<记录> list = obj.读取记录();
|
||||||
|
list.add(data);
|
||||||
|
obj.写入记录(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
FS = File.separator;
|
||||||
|
|
||||||
|
try {
|
||||||
|
String var10000 = System.getProperty("user.dir");
|
||||||
|
主目录 = var10000 + File.separator + "plugins" + File.separator + "坐标管理器";
|
||||||
|
if (!文件操作.文件是否存在(主目录)) {
|
||||||
|
文件操作.创建目录(主目录);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!文件操作.文件是否存在(主目录 + FS + "Data.json")) {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
文件操作.写出文本文件(主目录 + FS + "Data.json", json.toString());
|
||||||
|
}
|
||||||
|
} catch (Exception var1) {
|
||||||
|
var1.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
79
src/mc/tp/坐标管理/对象.java
Normal file
79
src/mc/tp/坐标管理/对象.java
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.坐标管理;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ling.android.操作.文件操作;
|
||||||
|
import ling.json.JSONArray;
|
||||||
|
import ling.json.JSONException;
|
||||||
|
import ling.json.JSONObject;
|
||||||
|
|
||||||
|
public class 对象 {
|
||||||
|
protected final String UUID;
|
||||||
|
|
||||||
|
protected 对象(String UUID) {
|
||||||
|
this.UUID = UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFraction() {
|
||||||
|
JSONObject json = new JSONObject(文件操作.读入文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json"));
|
||||||
|
if (!json.has(this.UUID)) {
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
JSONObject obj = json.getJSONObject(this.UUID);
|
||||||
|
if (!obj.has("Fraction"))
|
||||||
|
return 0;
|
||||||
|
return obj.getInt("Fraction");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFraction(int fraction) {
|
||||||
|
JSONObject json = new JSONObject(文件操作.读入文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json"));
|
||||||
|
JSONObject data;
|
||||||
|
if (!json.has(this.UUID))
|
||||||
|
data = new JSONObject();
|
||||||
|
else
|
||||||
|
data = json.getJSONObject(this.UUID);
|
||||||
|
|
||||||
|
data.put("Fraction", fraction);
|
||||||
|
json.put(this.UUID, data);
|
||||||
|
文件操作.写出文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json", json.toString(4));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<记录> 读取记录() throws JSONException {
|
||||||
|
JSONObject json = new JSONObject(文件操作.读入文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json"));
|
||||||
|
if (!json.has(this.UUID)) {
|
||||||
|
return new ArrayList();
|
||||||
|
} else {
|
||||||
|
JSONObject obj = json.getJSONObject(this.UUID);
|
||||||
|
if(!obj.has("Fraction"))
|
||||||
|
setFraction(0);
|
||||||
|
JSONArray array = obj.getJSONArray("Data");
|
||||||
|
List<记录> data = new ArrayList();
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length(); ++i) {
|
||||||
|
data.add(new 记录(array.getJSONObject(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 写入记录(List<记录> list) throws JSONException {
|
||||||
|
JSONObject json = new JSONObject(文件操作.读入文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json"));
|
||||||
|
JSONObject data = new JSONObject();
|
||||||
|
JSONArray array = new JSONArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
array.put(((记录) list.get(i)).toJSONObject());
|
||||||
|
}
|
||||||
|
data.put("Data", array);
|
||||||
|
json.put(this.UUID, data);
|
||||||
|
文件操作.写出文本文件(坐标管理器.主目录 + 坐标管理器.FS + "Data.json", json.toString(4));
|
||||||
|
}
|
||||||
|
}
|
||||||
50
src/mc/tp/坐标管理/记录.java
Normal file
50
src/mc/tp/坐标管理/记录.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp.坐标管理;
|
||||||
|
|
||||||
|
import ling.json.JSONException;
|
||||||
|
import ling.json.JSONObject;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
|
||||||
|
public class 记录 {
|
||||||
|
protected Location location;
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
public 记录(String name, Location location) {
|
||||||
|
this.location = location;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public 记录(JSONObject json) throws JSONException {
|
||||||
|
this.location = new Location(Bukkit.getWorld(json.getString("world")), json.getDouble("X"), json.getDouble("Y"), json.getDouble("Z"));
|
||||||
|
this.name = json.getString("name");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject toJSONObject() {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
|
||||||
|
try {
|
||||||
|
json.put("name", this.name);
|
||||||
|
json.put("world", this.location.getWorld().getName());
|
||||||
|
json.put("X", this.location.getX());
|
||||||
|
json.put("Y", this.location.getY());
|
||||||
|
json.put("Z", this.location.getZ());
|
||||||
|
} catch (JSONException var3) {
|
||||||
|
var3.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
}
|
||||||
240
src/mc/tp/坐标记录器.java
Normal file
240
src/mc/tp/坐标记录器.java
Normal file
@@ -0,0 +1,240 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ling.json.JSONException;
|
||||||
|
import mc.tp.坐标管理.坐标管理器;
|
||||||
|
import mc.tp.坐标管理.对象;
|
||||||
|
import mc.tp.坐标管理.记录;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
public class 坐标记录器 implements Listener {
|
||||||
|
public 坐标记录器() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void 玩家登陆(PlayerJoinEvent event) {
|
||||||
|
if (!Main.playerMap.containsKey(event.getPlayer())) {
|
||||||
|
Main.info("玩家[" + event.getPlayer().getName() + "]登陆服务器,已添加到管理列表");
|
||||||
|
Main.playerMap.put(event.getPlayer(), new 玩家对象(event.getPlayer()));
|
||||||
|
} else {
|
||||||
|
Main.info("玩家[" + event.getPlayer().getName() + "]已经在管理列表中");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void 玩家登出(PlayerQuitEvent event) {
|
||||||
|
Main.playerMap.remove(event.getPlayer());
|
||||||
|
Main.info("玩家[" + event.getPlayer().getName() + "]退出服务器,停止管理");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void 玩家移动(PlayerMoveEvent event) {
|
||||||
|
((玩家对象) Main.playerMap.get(event.getPlayer())).更新();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void GUI处理(InventoryClickEvent e) {
|
||||||
|
Player player;
|
||||||
|
ItemStack 点击物品;
|
||||||
|
if (e.getWhoClicked().getOpenInventory().getTitle().equals("[坐标管理器]主菜单")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
if (e.getRawSlot() < 0 || e.getRawSlot() > e.getInventory().getSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (Player) e.getWhoClicked();
|
||||||
|
点击物品 = e.getCurrentItem();
|
||||||
|
if (点击物品 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int 点击位置 = e.getRawSlot();
|
||||||
|
if (点击位置 == 0) {
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb yes");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (点击位置 == 8) {
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb no");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (点击位置 == 4) {
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb return");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (点击位置 == 9) {
|
||||||
|
player.closeInventory();
|
||||||
|
this.渲染坐标GUI(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (点击位置 == 17) {
|
||||||
|
player.closeInventory();
|
||||||
|
this.渲染玩家GUI(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
String 名称;
|
||||||
|
ItemMeta meta;
|
||||||
|
if (e.getWhoClicked().getOpenInventory().getTitle().equals("[坐标管理器]保存的坐标")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
if (e.getRawSlot() < 0 || e.getRawSlot() > e.getInventory().getSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (Player) e.getWhoClicked();
|
||||||
|
点击物品 = e.getCurrentItem();
|
||||||
|
if (点击物品 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getRawSlot() == 53) {
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.isShiftClick() && e.isRightClick()) {
|
||||||
|
meta = 点击物品.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
名称 = meta.getDisplayName();
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb remove " + 名称);
|
||||||
|
player.performCommand("zb");
|
||||||
|
}
|
||||||
|
} else if (e.getWhoClicked().getOpenInventory().getTitle().equals("[坐标管理器]传送菜单")) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
if (e.getRawSlot() < 0 || e.getRawSlot() > e.getInventory().getSize()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player = (Player) e.getWhoClicked();
|
||||||
|
点击物品 = e.getCurrentItem();
|
||||||
|
if (点击物品 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getRawSlot() == 53) {
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.isShiftClick() && e.isRightClick()) {
|
||||||
|
meta = 点击物品.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
名称 = meta.getDisplayName();
|
||||||
|
player.closeInventory();
|
||||||
|
player.performCommand("zb tp " + 名称);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 渲染玩家GUI(Player player) {
|
||||||
|
Inventory inv = Bukkit.createInventory(player, 54, "[坐标管理器]传送菜单");
|
||||||
|
int i = 0;
|
||||||
|
Iterator var4 = Bukkit.getOnlinePlayers().iterator();
|
||||||
|
|
||||||
|
while (var4.hasNext()) {
|
||||||
|
Player 玩家 = (Player) var4.next();
|
||||||
|
if (!玩家.getUniqueId().equals(player.getUniqueId())) {
|
||||||
|
if (i > 44) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack 玩家对象 = new ItemStack(Material.ENDER_PEARL);
|
||||||
|
ItemMeta meta = 玩家对象.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName(玩家.getName());
|
||||||
|
meta.setLore(Arrays.asList("按住[shift]后[右键点击]向他传送", ChatColor.RED + "你将有机会撤销。"));
|
||||||
|
玩家对象.setItemMeta(meta);
|
||||||
|
inv.setItem(i, 玩家对象);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack 上一页 = new ItemStack(Material.ARROW);
|
||||||
|
ItemMeta meta = 上一页.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("返回上一页");
|
||||||
|
上一页.setItemMeta(meta);
|
||||||
|
inv.setItem(53, 上一页);
|
||||||
|
player.openInventory(inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 渲染坐标GUI(Player player) {
|
||||||
|
Inventory inv = Bukkit.createInventory(player, 54, "[坐标管理器]保存的坐标");
|
||||||
|
|
||||||
|
try {
|
||||||
|
对象 obj = 坐标管理器.读取数据(player.getUniqueId().toString());
|
||||||
|
List<记录> map = obj.读取记录();
|
||||||
|
|
||||||
|
for (int i = 0; i < map.size() && i <= 44; ++i) {
|
||||||
|
ItemStack 坐标 = new ItemStack(Material.DIAMOND);
|
||||||
|
ItemMeta meta = 坐标.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName(((记录) map.get(i)).getName());
|
||||||
|
String[] var10001 = new String[4];
|
||||||
|
Object var10004 = map.get(i);
|
||||||
|
var10001[0] = "X " + (int) ((记录) var10004).getLocation().getX();
|
||||||
|
var10004 = map.get(i);
|
||||||
|
var10001[1] = "Y " + (int) ((记录) var10004).getLocation().getY();
|
||||||
|
var10004 = map.get(i);
|
||||||
|
var10001[2] = "Z " + (int) ((记录) var10004).getLocation().getZ();
|
||||||
|
var10001[3] = ChatColor.RED + "按住[shift]后[右键点击]删除此坐标!";
|
||||||
|
meta.setLore(Arrays.asList(var10001));
|
||||||
|
坐标.setItemMeta(meta);
|
||||||
|
inv.setItem(i, 坐标);
|
||||||
|
}
|
||||||
|
} catch (JSONException var8) {
|
||||||
|
var8.printStackTrace();
|
||||||
|
player.sendMessage(ChatColor.RED + "服务器内部错误,列出坐标失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack 上一页 = new ItemStack(Material.ARROW);
|
||||||
|
ItemMeta meta = 上一页.getItemMeta();
|
||||||
|
|
||||||
|
assert meta != null;
|
||||||
|
|
||||||
|
meta.setDisplayName("返回上一页");
|
||||||
|
上一页.setItemMeta(meta);
|
||||||
|
inv.setItem(53, 上一页);
|
||||||
|
player.openInventory(inv);
|
||||||
|
}
|
||||||
|
}
|
||||||
100
src/mc/tp/玩家对象.java
Normal file
100
src/mc/tp/玩家对象.java
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
//
|
||||||
|
// Source code recreated from a .class file by IntelliJ IDEA
|
||||||
|
// (powered by FernFlower decompiler)
|
||||||
|
//
|
||||||
|
|
||||||
|
package mc.tp;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import mc.tp.坐标管理.坐标管理器;
|
||||||
|
import mc.tp.坐标管理.对象;
|
||||||
|
import mc.tp.坐标管理.记录;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
|
|
||||||
|
public class 玩家对象 {
|
||||||
|
protected Scoreboard scoreboard;
|
||||||
|
protected Objective obj;
|
||||||
|
protected Player player;
|
||||||
|
protected String xyz = "";
|
||||||
|
private int x = 0;
|
||||||
|
private int y = 0;
|
||||||
|
private int z = 0;
|
||||||
|
private final List<String> 坐标栏 = new ArrayList();
|
||||||
|
|
||||||
|
public 玩家对象(Player player) {
|
||||||
|
try {
|
||||||
|
this.player = player;
|
||||||
|
this.scoreboard = ((ScoreboardManager)Objects.requireNonNull(Bukkit.getScoreboardManager())).getNewScoreboard();
|
||||||
|
this.obj = this.scoreboard.registerNewObjective("坐标", "dummy", ChatColor.GOLD.toString() + ChatColor.BOLD + "坐标");
|
||||||
|
this.obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
int var10001 = (int)player.getLocation().getX();
|
||||||
|
this.xyz = "X " + var10001 + " Y " + (int)player.getLocation().getY() + " Z " + (int)player.getLocation().getZ();
|
||||||
|
Score score = this.obj.getScore(this.xyz);
|
||||||
|
score.setScore(0);
|
||||||
|
this.x = (int)player.getLocation().getX();
|
||||||
|
this.y = (int)player.getLocation().getY();
|
||||||
|
this.z = (int)player.getLocation().getZ();
|
||||||
|
player.setScoreboard(this.scoreboard);
|
||||||
|
this.更新坐标栏();
|
||||||
|
} catch (Exception var3) {
|
||||||
|
var3.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 更新() {
|
||||||
|
if (this.x != (int)this.player.getLocation().getX() || this.y != (int)this.player.getLocation().getY() || this.z != (int)this.player.getLocation().getZ()) {
|
||||||
|
this.scoreboard.resetScores(this.xyz);
|
||||||
|
int var10001 = (int)this.player.getLocation().getX();
|
||||||
|
this.xyz = "X " + var10001 + " Y " + (int)this.player.getLocation().getY() + " Z " + (int)this.player.getLocation().getZ();
|
||||||
|
Score score = this.obj.getScore(this.xyz);
|
||||||
|
score.setScore(999);
|
||||||
|
this.x = (int)this.player.getLocation().getX();
|
||||||
|
this.y = (int)this.player.getLocation().getY();
|
||||||
|
this.z = (int)this.player.getLocation().getZ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void 更新坐标栏() {
|
||||||
|
for(int i = 0; i < this.坐标栏.size(); ++i) {
|
||||||
|
this.scoreboard.resetScores((String)this.坐标栏.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.坐标栏.clear();
|
||||||
|
对象 obj = 坐标管理器.读取数据(this.player.getUniqueId().toString());
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<记录> list = obj.读取记录();
|
||||||
|
|
||||||
|
for(int i = 0; i < list.size(); ++i) {
|
||||||
|
Location location = ((记录)list.get(i)).getLocation();
|
||||||
|
List var10000 = this.坐标栏;
|
||||||
|
String var10001 = ((记录)list.get(i)).getName();
|
||||||
|
var10000.add(var10001 + " X " + (int)location.getX() + " Y " + (int)location.getY() + " Z " + (int)location.getZ());
|
||||||
|
}
|
||||||
|
} catch (Exception var5) {
|
||||||
|
this.坐标栏.add("处理坐标出错!");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < this.坐标栏.size(); ++i) {
|
||||||
|
Score score = this.obj.getScore((String)this.坐标栏.get(i));
|
||||||
|
score.setScore(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Scoreboard getScoreboard() {
|
||||||
|
return this.scoreboard;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user