1
0
mirror of https://e.coding.net/circlecloud/ItemMamager.git synced 2024-11-22 01:58:54 +00:00

update project...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-10-27 21:00:00 +08:00
parent df8b488d5f
commit 0aeef978d9
5 changed files with 43 additions and 31 deletions

View File

@ -5,9 +5,8 @@ package cn.citycraft.ItemMamager;
import org.bukkit.plugin.java.JavaPlugin; 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.ItemMamager.listen.PlayerListen;
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
/** /**
* 物品管理器主类 * 物品管理器主类
@ -20,10 +19,7 @@ public class ItemMamager extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this); this.getServer().getPluginManager().registerEvents(new PlayerListen(this), this);
HandlerSubCommand cmdhandler = new HandlerSubCommand(this); this.getCommand("im").setExecutor(new ItemMamagerCommand(this));
cmdhandler.registerCommand(new BindCommand());
this.getCommand("im").setExecutor(cmdhandler);
this.getCommand("im").setTabCompleter(cmdhandler);
} }
@Override @Override

View File

@ -4,38 +4,21 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandException; import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import cn.citycraft.ItemMamager.ItemMamager;
import cn.citycraft.PluginHelper.commands.BaseCommand; import cn.citycraft.PluginHelper.commands.BaseCommand;
public class BindCommand extends BaseCommand { public class BindCommand extends BaseCommand {
ItemMamager plugin;
public BindCommand() { public BindCommand(final ItemMamager plugin) {
super("bind", "b"); super("bind", "b");
} this.plugin = plugin;
@Override
public void execute(CommandSender sender, Command command, String label, String[] args) throws CommandException {
// TODO 自动生成的方法存根
} }
@Override @Override
public String getDescription() { public void execute(final CommandSender sender, final Command command, final String label, final String[] args) throws CommandException {
return "物品绑定";
}
@Override
public int getMinimumArguments() {
return 0;
}
@Override
public String getPossibleArguments() {
return "";
}
@Override
public boolean isOnlyPlayerExecutable() {
return true;
} }
} }

View File

@ -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);
}
}

View File

@ -35,7 +35,7 @@ public class ItemHandler {
public String getBindName(ItemStack itemStack) { public String getBindName(ItemStack itemStack) {
if (isBound(itemStack, TAG.TIME) || isBound(itemStack, TAG.TIMEBIND)) { if (isBound(itemStack, TAG.TIME) || isBound(itemStack, TAG.TIMEBIND)) {
String mark = getMarkString(itemStack, MARK.BIND); String mark = getMarkString(itemStack, MARK.BIND);
return MARK.BIND.clearMark(mark); return MARK.BIND.getMarkData(mark);
} }
return null; return null;
} }
@ -43,7 +43,7 @@ public class ItemHandler {
public String getBindTime(ItemStack itemStack) { public String getBindTime(ItemStack itemStack) {
if (isBound(itemStack, TAG.BIND) || isBound(itemStack, TAG.TIMEBIND)) { if (isBound(itemStack, TAG.BIND) || isBound(itemStack, TAG.TIMEBIND)) {
String mark = getMarkString(itemStack, MARK.TIME); String mark = getMarkString(itemStack, MARK.TIME);
return MARK.TIME.clearMark(mark); return MARK.TIME.getMarkData(mark);
} }
return null; return null;
} }

View File

@ -50,7 +50,7 @@ public class ItemUtil {
return mark + lore; return mark + lore;
} }
public String clearMark(String lore) { public String getMarkData(String lore) {
return lore.replaceAll(mark, ""); return lore.replaceAll(mark, "");
} }