mirror of
https://github.com/CarmJos/MoeTeleport.git
synced 2026-06-04 16:46:10 +08:00
[1.2.0] 版本更新
- [R] 使用空格代替制表符进行格式化。 - [F] 修复通过 PlugMan 等第三方插件进行重载时插件功能失效的问题。
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
<groupId>cc.carm.plugin</groupId>
|
<groupId>cc.carm.plugin</groupId>
|
||||||
<artifactId>moeteleport</artifactId>
|
<artifactId>moeteleport</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.2.0</version>
|
||||||
|
|
||||||
<name>MoeTeleport</name>
|
<name>MoeTeleport</name>
|
||||||
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
<description>喵喵传送,简单的传送、设置家的插件。</description>
|
||||||
|
|||||||
@@ -15,11 +15,13 @@ import cc.carm.plugin.moeteleport.manager.ConfigManager;
|
|||||||
import cc.carm.plugin.moeteleport.manager.RequestManager;
|
import cc.carm.plugin.moeteleport.manager.RequestManager;
|
||||||
import cc.carm.plugin.moeteleport.manager.TeleportManager;
|
import cc.carm.plugin.moeteleport.manager.TeleportManager;
|
||||||
import cc.carm.plugin.moeteleport.manager.UserManager;
|
import cc.carm.plugin.moeteleport.manager.UserManager;
|
||||||
|
import cc.carm.plugin.moeteleport.model.UserData;
|
||||||
import cc.carm.plugin.moeteleport.util.ColorParser;
|
import cc.carm.plugin.moeteleport.util.ColorParser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -27,61 +29,12 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public class Main extends JavaPlugin {
|
public class Main extends JavaPlugin {
|
||||||
|
|
||||||
private static Main instance;
|
|
||||||
public static boolean debugMode = true;
|
public static boolean debugMode = true;
|
||||||
|
private static Main instance;
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private TeleportManager teleportManager;
|
private TeleportManager teleportManager;
|
||||||
private RequestManager requestManager;
|
private RequestManager requestManager;
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
instance = this;
|
|
||||||
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
log("加载配置文件...");
|
|
||||||
ConfigManager.initConfig();
|
|
||||||
|
|
||||||
log("加载用户管理器...");
|
|
||||||
this.userManager = new UserManager(this);
|
|
||||||
|
|
||||||
log("加载请求管理器...");
|
|
||||||
this.requestManager = new RequestManager(this);
|
|
||||||
|
|
||||||
log("注册监听器...");
|
|
||||||
regListener(new UserListener());
|
|
||||||
|
|
||||||
log("注册指令...");
|
|
||||||
registerCommand("back", new BackCommand());
|
|
||||||
|
|
||||||
registerCommand("home", new GoHomeCommand(), new HomeNameCompleter());
|
|
||||||
registerCommand("delHome", new DelHomeCommand(), new HomeNameCompleter());
|
|
||||||
registerCommand("setHome", new SetHomeCommand());
|
|
||||||
registerCommand("listHome", new ListHomeCommand());
|
|
||||||
|
|
||||||
registerCommand("tpa", new TpaCommand(), new PlayerNameCompleter());
|
|
||||||
registerCommand("tpaHere", new TpaCommand(), new PlayerNameCompleter());
|
|
||||||
registerCommand("tpAccept", new TpHandleCommand(), new TpRequestCompleter());
|
|
||||||
registerCommand("tpDeny", new TpHandleCommand(), new TpRequestCompleter());
|
|
||||||
|
|
||||||
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
|
|
||||||
getRequestManager().shutdown();
|
|
||||||
|
|
||||||
log("卸载监听器...");
|
|
||||||
Bukkit.getServicesManager().unregisterAll(this);
|
|
||||||
|
|
||||||
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册监听器
|
* 注册监听器
|
||||||
*
|
*
|
||||||
@@ -131,4 +84,59 @@ public class Main extends JavaPlugin {
|
|||||||
return Main.getInstance().requestManager;
|
return Main.getInstance().requestManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
log(getName() + " " + getDescription().getVersion() + " &7开始加载...");
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
log("加载配置文件...");
|
||||||
|
ConfigManager.initConfig();
|
||||||
|
|
||||||
|
log("加载用户管理器...");
|
||||||
|
this.userManager = new UserManager(this);
|
||||||
|
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||||
|
log(" 加载现有用户数据...");
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
UserData data = Main.getUserManager().loadData(player.getUniqueId());
|
||||||
|
Main.getUserManager().getUserDataMap().put(player.getUniqueId(), data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log("加载请求管理器...");
|
||||||
|
this.requestManager = new RequestManager(this);
|
||||||
|
|
||||||
|
log("注册监听器...");
|
||||||
|
regListener(new UserListener());
|
||||||
|
|
||||||
|
log("注册指令...");
|
||||||
|
registerCommand("back", new BackCommand());
|
||||||
|
|
||||||
|
registerCommand("home", new GoHomeCommand(), new HomeNameCompleter());
|
||||||
|
registerCommand("delHome", new DelHomeCommand(), new HomeNameCompleter());
|
||||||
|
registerCommand("setHome", new SetHomeCommand());
|
||||||
|
registerCommand("listHome", new ListHomeCommand());
|
||||||
|
|
||||||
|
registerCommand("tpa", new TpaCommand(), new PlayerNameCompleter());
|
||||||
|
registerCommand("tpaHere", new TpaCommand(), new PlayerNameCompleter());
|
||||||
|
registerCommand("tpAccept", new TpHandleCommand(), new TpRequestCompleter());
|
||||||
|
registerCommand("tpDeny", new TpHandleCommand(), new TpRequestCompleter());
|
||||||
|
|
||||||
|
log("加载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
log(getName() + " " + getDescription().getVersion() + " 开始卸载...");
|
||||||
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
getRequestManager().shutdown();
|
||||||
|
|
||||||
|
log("卸载监听器...");
|
||||||
|
Bukkit.getServicesManager().unregisterAll(this);
|
||||||
|
|
||||||
|
log("卸载完成 ,共耗时 " + (System.currentTimeMillis() - startTime) + " ms 。");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.Objects;
|
|||||||
public class DataLocation implements Cloneable {
|
public class DataLocation implements Cloneable {
|
||||||
|
|
||||||
public static final DecimalFormat format = new DecimalFormat("0.00");
|
public static final DecimalFormat format = new DecimalFormat("0.00");
|
||||||
private String worldName;
|
private final String worldName;
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
private double z;
|
private double z;
|
||||||
@@ -38,6 +38,32 @@ public class DataLocation implements Cloneable {
|
|||||||
this.yaw = yaw;
|
this.yaw = yaw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DataLocation deserializeText(String s) {
|
||||||
|
if (s == null || !s.contains(";")) return null;
|
||||||
|
String[] args = StringUtils.split(s, ";");
|
||||||
|
if (args.length < 4) return null;
|
||||||
|
try {
|
||||||
|
String worldName = args[0];
|
||||||
|
double x = NumberConversions.toDouble(args[1]);
|
||||||
|
double y = NumberConversions.toDouble(args[2]);
|
||||||
|
double z = NumberConversions.toDouble(args[3]);
|
||||||
|
float yaw = 0;
|
||||||
|
float pitch = 0;
|
||||||
|
if (args.length == 6) {
|
||||||
|
yaw = NumberConversions.toFloat(args[4]);
|
||||||
|
pitch = NumberConversions.toFloat(args[5]);
|
||||||
|
}
|
||||||
|
return new DataLocation(worldName, x, y, z, yaw, pitch);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public static DataLocation parseString(String s) {
|
||||||
|
return deserializeText(s);
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorldName() {
|
public String getWorldName() {
|
||||||
return worldName;
|
return worldName;
|
||||||
}
|
}
|
||||||
@@ -82,12 +108,10 @@ public class DataLocation implements Cloneable {
|
|||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public @NotNull Location getBukkitLocation(World world) {
|
public @NotNull Location getBukkitLocation(World world) {
|
||||||
return new Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
|
return new Location(world, getX(), getY(), getZ(), getYaw(), getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public @Nullable Location getBukkitLocation() {
|
public @Nullable Location getBukkitLocation() {
|
||||||
World world = Bukkit.getWorld(getWorldName());
|
World world = Bukkit.getWorld(getWorldName());
|
||||||
if (world == null) return null;
|
if (world == null) return null;
|
||||||
@@ -143,30 +167,4 @@ public class DataLocation implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataLocation deserializeText(String s) {
|
|
||||||
if (s == null || !s.contains(";")) return null;
|
|
||||||
String[] args = StringUtils.split(s, ";");
|
|
||||||
if (args.length < 4) return null;
|
|
||||||
try {
|
|
||||||
String worldName = args[0];
|
|
||||||
double x = NumberConversions.toDouble(args[1]);
|
|
||||||
double y = NumberConversions.toDouble(args[2]);
|
|
||||||
double z = NumberConversions.toDouble(args[3]);
|
|
||||||
float yaw = 0;
|
|
||||||
float pitch = 0;
|
|
||||||
if (args.length == 6) {
|
|
||||||
yaw = NumberConversions.toFloat(args[4]);
|
|
||||||
pitch = NumberConversions.toFloat(args[5]);
|
|
||||||
}
|
|
||||||
return new DataLocation(worldName, x, y, z, yaw, pitch);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public static DataLocation parseString(String s) {
|
|
||||||
return deserializeText(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -17,15 +17,11 @@ public class UserData {
|
|||||||
|
|
||||||
private final @NotNull File dataFile;
|
private final @NotNull File dataFile;
|
||||||
private final @NotNull FileConfiguration dataConfig;
|
private final @NotNull FileConfiguration dataConfig;
|
||||||
|
|
||||||
private @Nullable Location lastLocation;
|
|
||||||
|
|
||||||
private LinkedHashMap<String, DataLocation> homeLocations;
|
|
||||||
|
|
||||||
private final HashSet<UUID/*receiverUUID*/> sentRequests = new HashSet<>(); // 记录发出的请求
|
private final HashSet<UUID/*receiverUUID*/> sentRequests = new HashSet<>(); // 记录发出的请求
|
||||||
private final ConcurrentHashMap<UUID/*senderUUID*/, TeleportRequest> receivedRequests = new ConcurrentHashMap<>(); // 记录收到的传送请求
|
private final ConcurrentHashMap<UUID/*senderUUID*/, TeleportRequest> receivedRequests = new ConcurrentHashMap<>(); // 记录收到的传送请求
|
||||||
|
|
||||||
public boolean enableAutoSelect = false;
|
public boolean enableAutoSelect = false;
|
||||||
|
private @Nullable Location lastLocation;
|
||||||
|
private LinkedHashMap<String, DataLocation> homeLocations;
|
||||||
|
|
||||||
public UserData(@NotNull File dataFolder, @NotNull UUID uuid) {
|
public UserData(@NotNull File dataFolder, @NotNull UUID uuid) {
|
||||||
this(new File(dataFolder, uuid + ".yml"));
|
this(new File(dataFolder, uuid + ".yml"));
|
||||||
@@ -100,14 +96,14 @@ public class UserData {
|
|||||||
return receivedRequests;
|
return receivedRequests;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
|
||||||
this.enableAutoSelect = enableAutoSelect;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnableAutoSelect() {
|
public boolean isEnableAutoSelect() {
|
||||||
return enableAutoSelect;
|
return enableAutoSelect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setEnableAutoSelect(boolean enableAutoSelect) {
|
||||||
|
this.enableAutoSelect = enableAutoSelect;
|
||||||
|
}
|
||||||
|
|
||||||
public @NotNull File getDataFile() {
|
public @NotNull File getDataFile() {
|
||||||
return dataFile;
|
return dataFile;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package cc.carm.plugin.moeteleport.util;
|
package cc.carm.plugin.moeteleport.util;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -7,8 +6,7 @@ import java.util.regex.Pattern;
|
|||||||
public class ColorParser {
|
public class ColorParser {
|
||||||
|
|
||||||
public static String parse(String text) {
|
public static String parse(String text) {
|
||||||
text = parseHexColor(text);
|
return parseColor(parseHexColor(text));
|
||||||
return parseColor(text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String parseColor(final String text) {
|
public static String parseColor(final String text) {
|
||||||
|
|||||||
Reference in New Issue
Block a user