feat: 兼容1.0.0
This commit is contained in:
@@ -59,8 +59,8 @@ public class HamsterCorePlugin extends JavaPlugin {
|
|||||||
logger.info("已注册 CallbackListener.");
|
logger.info("已注册 CallbackListener.");
|
||||||
Bukkit.getPluginManager().registerEvents(DebugListener.INSTANCE, this);
|
Bukkit.getPluginManager().registerEvents(DebugListener.INSTANCE, this);
|
||||||
logger.info("已注册 DebugListener.");
|
logger.info("已注册 DebugListener.");
|
||||||
ParentCoreCommand.INSTANCE.hook();
|
ParentCoreCommand.INSTANCE.register();
|
||||||
ParentLoreCommand.INSTANCE.hook();
|
ParentLoreCommand.INSTANCE.register();
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||||
PointAPI.reloadPlayerPointAPIHook();
|
PointAPI.reloadPlayerPointAPIHook();
|
||||||
|
@@ -11,9 +11,8 @@ public abstract class ChildCommand implements TabExecutor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public abstract String getUsage();
|
public abstract String getUsage();
|
||||||
|
|
||||||
public abstract boolean hasPermission(@NotNull CommandSender sender);
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public abstract String getDescription();
|
public abstract String getDescription();
|
||||||
|
|
||||||
|
public abstract boolean hasPermission(@NotNull CommandSender sender);
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,25 @@ public abstract class ParentCommand extends ChildCommand {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void register() {
|
||||||
|
JavaPlugin plugin = getPlugin();
|
||||||
|
PluginCommand command = plugin.getCommand(getName());
|
||||||
|
if (command == null) {
|
||||||
|
throw new IllegalArgumentException("在插件 " + plugin.getName() + " 中未找到指令 " + getName() + ".");
|
||||||
|
}
|
||||||
|
command.setExecutor(this);
|
||||||
|
command.setTabCompleter(this);
|
||||||
|
plugin.getLogger().info("已注册指令 " + getUsage() + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 建议使用 {@link #register()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public void hook() {
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有子命令
|
* 获取所有子命令
|
||||||
* <p>
|
* <p>
|
||||||
@@ -108,17 +127,6 @@ public abstract class ParentCommand extends ChildCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hook() {
|
|
||||||
JavaPlugin plugin = getPlugin();
|
|
||||||
PluginCommand command = plugin.getCommand(getName());
|
|
||||||
if (command == null) {
|
|
||||||
throw new IllegalArgumentException("在插件 " + plugin.getName() + " 中未找到指令 " + getName() + ".");
|
|
||||||
}
|
|
||||||
command.setExecutor(this);
|
|
||||||
command.setTabCompleter(this);
|
|
||||||
plugin.getLogger().info("已注册指令 " + getUsage() + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
if (!hasPermission(sender)) {
|
if (!hasPermission(sender)) {
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package cn.hamster3.mc.plugin.core.common.util;
|
package cn.hamster3.mc.plugin.core.common.util;
|
||||||
|
|
||||||
|
import cn.hamster3.mc.plugin.core.common.api.CoreAPI;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import net.kyori.adventure.key.Key;
|
import net.kyori.adventure.key.Key;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
@@ -16,6 +18,17 @@ import java.util.zip.ZipOutputStream;
|
|||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public final class CoreUtils {
|
public final class CoreUtils {
|
||||||
|
/**
|
||||||
|
* @deprecated 建议使用 {@link CoreAPI#getGson()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static Gson GSON = CoreAPI.getInstance().getGson();
|
||||||
|
/**
|
||||||
|
* @deprecated 建议使用 {@link CoreAPI#getHumanGson()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static Gson GSON_HUMAN = CoreAPI.getInstance().getHumanGson();
|
||||||
|
|
||||||
private CoreUtils() {
|
private CoreUtils() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user