1
0
mirror of https://e.coding.net/circlecloud/ProtectItem.git synced 2024-12-27 20:48:51 +00:00

修复禁封错误...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-11-29 15:38:30 +08:00
parent 7cdc3aaddb
commit aa71699cc1

View File

@ -19,7 +19,7 @@ import cn.citycraft.ProtectItem.ProtectItem;
public class ItemManager { public class ItemManager {
FileConfig itemconfig; FileConfig itemconfig;
HashMap<String, List<ActionType>> itemlist = new HashMap<String, List<ActionType>>(); HashMap<String, ArrayList<ActionType>> itemlist = new HashMap<String, ArrayList<ActionType>>();
ProtectItem plugin; ProtectItem plugin;
public ItemManager(final ProtectItem main) { public ItemManager(final ProtectItem main) {
@ -30,7 +30,7 @@ public class ItemManager {
final Set<String> items = itemconfig.getConfigurationSection("banitems").getKeys(false); final Set<String> items = itemconfig.getConfigurationSection("banitems").getKeys(false);
if (items != null) { if (items != null) {
for (final String banitem : items) { for (final String banitem : items) {
final List<ActionType> actlist = new ArrayList<ActionType>(); final ArrayList<ActionType> actlist = new ArrayList<ActionType>();
for (final String action : itemconfig.getStringList("banitems." + banitem)) { for (final String action : itemconfig.getStringList("banitems." + banitem)) {
try { try {
final ActionType act = Enum.valueOf(ActionType.class, action); final ActionType act = Enum.valueOf(ActionType.class, action);
@ -51,8 +51,8 @@ public class ItemManager {
public void banItem(final ItemStack item, final ActionType... action) { public void banItem(final ItemStack item, final ActionType... action) {
final String itemname = getItemName(item); final String itemname = getItemName(item);
if (itemlist.containsKey(itemname)) { if (itemlist.containsKey(itemname)) {
final List<ActionType> actlist = itemlist.get(itemname); final ArrayList<ActionType> actlist = itemlist.get(itemname);
final List<ActionType> addactlist = new ArrayList<ActionType>(); final ArrayList<ActionType> addactlist = new ArrayList<ActionType>();
for (final ActionType actionType : actlist) { for (final ActionType actionType : actlist) {
if (!actlist.contains(action)) { if (!actlist.contains(action)) {
addactlist.add(actionType); addactlist.add(actionType);
@ -61,7 +61,7 @@ public class ItemManager {
actlist.addAll(addactlist); actlist.addAll(addactlist);
itemlist.put(itemname, actlist); itemlist.put(itemname, actlist);
} else { } else {
itemlist.put(itemname, Arrays.asList(action)); itemlist.put(itemname, new ArrayList<>(Arrays.asList(action)));
} }
this.saveConfig(); this.saveConfig();
} }
@ -91,7 +91,7 @@ public class ItemManager {
public void saveConfig() { public void saveConfig() {
final HashMap<String, List<String>> banlist = new HashMap<String, List<String>>(); final HashMap<String, List<String>> banlist = new HashMap<String, List<String>>();
for (final Entry<String, List<ActionType>> banitem : itemlist.entrySet()) { for (final Entry<String, ArrayList<ActionType>> banitem : itemlist.entrySet()) {
final List<String> actlist = new ArrayList<String>(); final List<String> actlist = new ArrayList<String>();
for (final ActionType act : banitem.getValue()) { for (final ActionType act : banitem.getValue()) {
actlist.add(act.toString()); actlist.add(act.toString());
@ -105,7 +105,7 @@ public class ItemManager {
public void sendBanList(final CommandSender sender) { public void sendBanList(final CommandSender sender) {
sender.sendMessage("§6服务器已禁封的物品如下:"); sender.sendMessage("§6服务器已禁封的物品如下:");
sender.sendMessage("§a物品 §c操作"); sender.sendMessage("§a物品 §c操作");
for (final Entry<String, List<ActionType>> item : itemlist.entrySet()) { for (final Entry<String, ArrayList<ActionType>> item : itemlist.entrySet()) {
String acts = ""; String acts = "";
for (final ActionType act : item.getValue()) { for (final ActionType act : item.getValue()) {
acts += act.getName() + " "; acts += act.getName() + " ";
@ -123,7 +123,7 @@ public class ItemManager {
public void unBanItem(final ItemStack item, final ActionType... action) { public void unBanItem(final ItemStack item, final ActionType... action) {
final String itemname = getItemName(item); final String itemname = getItemName(item);
if (itemlist.containsKey(itemname)) { if (itemlist.containsKey(itemname)) {
final List<ActionType> actlist = itemlist.get(itemname); final ArrayList<ActionType> actlist = itemlist.get(itemname);
actlist.removeAll(Arrays.asList(action)); actlist.removeAll(Arrays.asList(action));
itemlist.put(itemname, actlist); itemlist.put(itemname, actlist);
} }