mirror of
https://e.coding.net/circlecloud/ProtectItem.git
synced 2024-12-26 20:38:49 +00:00
修复错误 汉化物品...
This commit is contained in:
parent
cd091d4df3
commit
52ebef4fa3
4
pom.xml
4
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
<artifactId>ProtectItem</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<name>ProtectItem</name>
|
||||
<build>
|
||||
<finalName>${project.name}</finalName>
|
||||
@ -54,7 +54,7 @@
|
||||
</build>
|
||||
<properties>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
<update.description>完善命令...</update.description>
|
||||
<update.description>修复错误 汉化物品...</update.description>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.LocalUtil;
|
||||
import cn.citycraft.ProtectItem.commands.ProtectItemCommand;
|
||||
import cn.citycraft.ProtectItem.listen.ClickItemListen;
|
||||
import cn.citycraft.ProtectItem.listen.DropItemListen;
|
||||
@ -16,9 +17,9 @@ import cn.citycraft.ProtectItem.utils.ActionType;
|
||||
import cn.citycraft.ProtectItem.utils.ItemManager;
|
||||
|
||||
public class ProtectItem extends JavaPlugin {
|
||||
public FileConfig config;
|
||||
public ItemManager itemManager;
|
||||
public FileConfig msgcfg;
|
||||
public FileConfig config;
|
||||
public String pluginname;
|
||||
|
||||
public ItemManager getItemManager() {
|
||||
@ -29,7 +30,7 @@ public class ProtectItem extends JavaPlugin {
|
||||
if (!itemManager.canAction(i, action) && !itemManager.hasActionPerm(p, i, action)) {
|
||||
final String message = msgcfg.getMessage("Message." + action.toString());
|
||||
if (message != null && !message.isEmpty()) {
|
||||
p.sendMessage(String.format(pluginname + " " + message, itemManager.getItemName(i)));
|
||||
p.sendMessage(String.format(pluginname + " " + message, LocalUtil.getItemName(itemManager.getItemName(i))));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -45,7 +46,7 @@ public class ProtectItem extends JavaPlugin {
|
||||
pm.registerEvents(new InteractItemListen(this), this);
|
||||
pm.registerEvents(new ItemHeldListen(this), this);
|
||||
pm.registerEvents(new PickupItemListen(this), this);
|
||||
this.getCommand("pi").setExecutor(new ProtectItemCommand(this));
|
||||
new ProtectItemCommand(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.BaseCommand;
|
||||
import cn.citycraft.PluginHelper.utils.LocalUtil;
|
||||
import cn.citycraft.ProtectItem.ProtectItem;
|
||||
import cn.citycraft.ProtectItem.utils.ActionType;
|
||||
|
||||
@ -30,14 +31,13 @@ public class CommandBan extends BaseCommand {
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
plugin.getItemManager().banItem(item);
|
||||
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + itemname + " §c已被禁封!");
|
||||
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + LocalUtil.getItemName(itemname) + " §c已被禁封!");
|
||||
return;
|
||||
case 1:
|
||||
|
||||
try {
|
||||
final ActionType action = Enum.valueOf(ActionType.class, args[0]);
|
||||
plugin.getItemManager().banItem(item, action);
|
||||
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + itemname + " §c已被禁封 §c操作 §b" + action.toString() + "!");
|
||||
p.sendMessage(plugin.pluginname + "§c当前物品 §a" + LocalUtil.getItemName(itemname) + " §c已被禁封 §c操作 §b" + action.toString() + "!");
|
||||
} catch (final Exception e) {
|
||||
p.sendMessage(plugin.pluginname + "§c未知的操作类型" + args[0] + "!");
|
||||
}
|
||||
|
@ -1,36 +1,19 @@
|
||||
package cn.citycraft.ProtectItem.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.PluginHelper.commands.DefaultCommand;
|
||||
import cn.citycraft.PluginHelper.commands.HandlerSubCommand;
|
||||
import cn.citycraft.ProtectItem.ProtectItem;
|
||||
|
||||
public class ProtectItemCommand implements CommandExecutor, DefaultCommand {
|
||||
public class ProtectItemCommand {
|
||||
|
||||
HandlerSubCommand hsc;
|
||||
ProtectItem plugin;
|
||||
|
||||
public ProtectItemCommand(final ProtectItem main) {
|
||||
plugin = main;
|
||||
hsc = new HandlerSubCommand(main);
|
||||
hsc.setDefaultCommand(this);
|
||||
hsc = new HandlerSubCommand(main, "pi");
|
||||
hsc.registerCommand(new CommandBan(main));
|
||||
hsc.registerCommand(new CommandList(main));
|
||||
hsc.registerCommand(new CommandUnban(main));
|
||||
}
|
||||
|
||||
@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 cmd, final String label, final String[] args) {
|
||||
return hsc.onCommand(sender, cmd, label, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,19 @@
|
||||
package cn.citycraft.ProtectItem.utils;
|
||||
|
||||
public enum ActionType {
|
||||
Click(),
|
||||
Drop(),
|
||||
Held(),
|
||||
Interact(),
|
||||
Pickup()
|
||||
Click("点击"),
|
||||
Drop("掉落"),
|
||||
Held("使用"),
|
||||
Interact("交互"),
|
||||
Pickup("拾取");
|
||||
|
||||
String name;
|
||||
|
||||
private ActionType(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.PluginHelper.config.FileConfig;
|
||||
import cn.citycraft.PluginHelper.utils.LocalUtil;
|
||||
import cn.citycraft.ProtectItem.ProtectItem;
|
||||
|
||||
public class ItemManager {
|
||||
@ -112,9 +113,9 @@ public class ItemManager {
|
||||
for (final Entry<String, List<ActionType>> item : itemlist.entrySet()) {
|
||||
String acts = "";
|
||||
for (final ActionType act : item.getValue()) {
|
||||
acts += act.toString() + " ";
|
||||
acts += act.getName() + " ";
|
||||
}
|
||||
sender.sendMessage("§a" + item.getKey() + " §c " + acts);
|
||||
sender.sendMessage("§a" + LocalUtil.getItemName(item.getKey()) + " §c " + acts);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user