diff --git a/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java b/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java index 58aff48..9ee2ee1 100644 --- a/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java +++ b/src/main/java/cn/citycraft/ItemMamager/ItemMamager.java @@ -5,9 +5,8 @@ package cn.citycraft.ItemMamager; import org.bukkit.plugin.java.JavaPlugin; -import cn.citycraft.ItemMamager.commands.BindCommand; +import cn.citycraft.ItemMamager.commands.ItemMamagerCommand; import cn.citycraft.ItemMamager.listen.PlayerListen; -import cn.citycraft.PluginHelper.commands.HandlerSubCommand; /** * 物品管理器主类 @@ -20,10 +19,7 @@ public class ItemMamager extends JavaPlugin { @Override public void onEnable() { this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this); - HandlerSubCommand cmdhandler = new HandlerSubCommand(this); - cmdhandler.registerCommand(new BindCommand()); - this.getCommand("im").setExecutor(cmdhandler); - this.getCommand("im").setTabCompleter(cmdhandler); + this.getCommand("im").setExecutor(new ItemMamagerCommand(this)); } @Override diff --git a/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java b/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java index 4f790e5..4a7c222 100644 --- a/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java +++ b/src/main/java/cn/citycraft/ItemMamager/commands/BindCommand.java @@ -4,38 +4,21 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandException; import org.bukkit.command.CommandSender; +import cn.citycraft.ItemMamager.ItemMamager; import cn.citycraft.PluginHelper.commands.BaseCommand; public class BindCommand extends BaseCommand { + ItemMamager plugin; - public BindCommand() { + public BindCommand(final ItemMamager plugin) { super("bind", "b"); - } - - @Override - public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException { - // TODO 自动生成的方法存根 + this.plugin = plugin; } @Override - public String getDescription() { - return "物品绑定"; - } + public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException { - @Override - public int getMinimumArguments() { - return 0; - } - - @Override - public String getPossibleArguments() { - return ""; - } - - @Override - public boolean isOnlyPlayerExecutable() { - return true; } } diff --git a/src/main/java/cn/citycraft/ItemMamager/commands/ItemMamagerCommand.java b/src/main/java/cn/citycraft/ItemMamager/commands/ItemMamagerCommand.java new file mode 100644 index 0000000..14eca68 --- /dev/null +++ b/src/main/java/cn/citycraft/ItemMamager/commands/ItemMamagerCommand.java @@ -0,0 +1,33 @@ +package cn.citycraft.ItemMamager.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandException; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import cn.citycraft.ItemMamager.ItemMamager; +import cn.citycraft.PluginHelper.commands.DefaultCommand; +import cn.citycraft.PluginHelper.commands.HandlerSubCommand; + +public class ItemMamagerCommand implements CommandExecutor, DefaultCommand { + HandlerSubCommand hsc; + ItemMamager plugin; + + public ItemMamagerCommand(final ItemMamager itemMamager) { + plugin = itemMamager; + hsc = new HandlerSubCommand(plugin); + hsc.setDefaultCommand(this); + hsc.registerCommand(new BindCommand(plugin)); + } + + @Override + public void defaultExecute(final CommandSender sender, final Command command, final String label) throws CommandException { + hsc.sendHelp(sender, label); + } + + @Override + public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) { + return hsc.onCommand(sender, command, label, args); + } + +} diff --git a/src/main/java/cn/citycraft/ItemMamager/manager/ItemHandler.java b/src/main/java/cn/citycraft/ItemMamager/manager/ItemHandler.java index f5cb17d..cb3a203 100644 --- a/src/main/java/cn/citycraft/ItemMamager/manager/ItemHandler.java +++ b/src/main/java/cn/citycraft/ItemMamager/manager/ItemHandler.java @@ -35,7 +35,7 @@ public class ItemHandler { public String getBindName(ItemStack itemStack) { if (isBound(itemStack, TAG.TIME) || isBound(itemStack, TAG.TIMEBIND)) { String mark = getMarkString(itemStack, MARK.BIND); - return MARK.BIND.clearMark(mark); + return MARK.BIND.getMarkData(mark); } return null; } @@ -43,7 +43,7 @@ public class ItemHandler { public String getBindTime(ItemStack itemStack) { if (isBound(itemStack, TAG.BIND) || isBound(itemStack, TAG.TIMEBIND)) { String mark = getMarkString(itemStack, MARK.TIME); - return MARK.TIME.clearMark(mark); + return MARK.TIME.getMarkData(mark); } return null; } diff --git a/src/main/java/cn/citycraft/ItemMamager/utils/ItemUtil.java b/src/main/java/cn/citycraft/ItemMamager/utils/ItemUtil.java index 464c3c2..1859ec4 100644 --- a/src/main/java/cn/citycraft/ItemMamager/utils/ItemUtil.java +++ b/src/main/java/cn/citycraft/ItemMamager/utils/ItemUtil.java @@ -50,7 +50,7 @@ public class ItemUtil { return mark + lore; } - public String clearMark(String lore) { + public String getMarkData(String lore) { return lore.replaceAll(mark, ""); }