1
0
mirror of https://e.coding.net/circlecloud/ProtectItem.git synced 2024-12-26 20:38:49 +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 {
FileConfig itemconfig;
HashMap<String, List<ActionType>> itemlist = new HashMap<String, List<ActionType>>();
HashMap<String, ArrayList<ActionType>> itemlist = new HashMap<String, ArrayList<ActionType>>();
ProtectItem plugin;
public ItemManager(final ProtectItem main) {
@ -30,7 +30,7 @@ public class ItemManager {
final Set<String> items = itemconfig.getConfigurationSection("banitems").getKeys(false);
if (items != null) {
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)) {
try {
final ActionType act = Enum.valueOf(ActionType.class, action);
@ -51,8 +51,8 @@ public class ItemManager {
public void banItem(final ItemStack item, final ActionType... action) {
final String itemname = getItemName(item);
if (itemlist.containsKey(itemname)) {
final List<ActionType> actlist = itemlist.get(itemname);
final List<ActionType> addactlist = new ArrayList<ActionType>();
final ArrayList<ActionType> actlist = itemlist.get(itemname);
final ArrayList<ActionType> addactlist = new ArrayList<ActionType>();
for (final ActionType actionType : actlist) {
if (!actlist.contains(action)) {
addactlist.add(actionType);
@ -61,7 +61,7 @@ public class ItemManager {
actlist.addAll(addactlist);
itemlist.put(itemname, actlist);
} else {
itemlist.put(itemname, Arrays.asList(action));
itemlist.put(itemname, new ArrayList<>(Arrays.asList(action)));
}
this.saveConfig();
}
@ -91,7 +91,7 @@ public class ItemManager {
public void saveConfig() {
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>();
for (final ActionType act : banitem.getValue()) {
actlist.add(act.toString());
@ -105,7 +105,7 @@ public class ItemManager {
public void sendBanList(final CommandSender sender) {
sender.sendMessage("§6服务器已禁封的物品如下:");
sender.sendMessage("§a物品 §c操作");
for (final Entry<String, List<ActionType>> item : itemlist.entrySet()) {
for (final Entry<String, ArrayList<ActionType>> item : itemlist.entrySet()) {
String acts = "";
for (final ActionType act : item.getValue()) {
acts += act.getName() + " ";
@ -123,7 +123,7 @@ public class ItemManager {
public void unBanItem(final ItemStack item, final ActionType... action) {
final String itemname = getItemName(item);
if (itemlist.containsKey(itemname)) {
final List<ActionType> actlist = itemlist.get(itemname);
final ArrayList<ActionType> actlist = itemlist.get(itemname);
actlist.removeAll(Arrays.asList(action));
itemlist.put(itemname, actlist);
}