summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java145
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java16
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java6
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java12
4 files changed, 130 insertions, 49 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index 9c774b848..ef5481acc 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -1,16 +1,20 @@
package com.earth2me.essentials;
import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.bukkit.ChatColor;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.io.File;
import java.util.ArrayList;
import org.bukkit.entity.CreatureType;
+import org.bukkit.inventory.ItemStack;
public class Settings implements IConf
{
private EssentialsConf config;
+ private final static Logger logger = Logger.getLogger("Minecraft");
public Settings(File dataFolder)
{
@@ -197,39 +201,94 @@ public class Settings implements IConf
return epSettings;
}
- public ArrayList getEpAlertOnPlacement()
- {
- ArrayList epAlertPlace = new ArrayList();
- epAlertPlace.addAll(Arrays.asList(config.getString("protect.alert.on-placement", "").split(",")));
+ public ArrayList<Integer> getEpAlertOnPlacement()
+ {
+ ArrayList<Integer> epAlertPlace = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.alert.on-placement", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epAlertPlace.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in alert on placement list.");
+ }
+ }
return epAlertPlace;
}
- public ArrayList getEpAlertOnUse()
- {
- ArrayList epAlertUse = new ArrayList();
- epAlertUse.addAll(Arrays.asList(config.getString("protect.alert.on-use", "").split(",")));
+ public ArrayList<Integer> getEpAlertOnUse()
+ {
+ ArrayList<Integer> epAlertUse = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.alert.on-use", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epAlertUse.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in alert on use list.");
+ }
+ }
return epAlertUse;
}
- public ArrayList getEpAlertOnBreak()
- {
- ArrayList epAlertPlace = new ArrayList();
- epAlertPlace.addAll(Arrays.asList(config.getString("protect.alert.on-break", "").split(",")));
+ public ArrayList<Integer> getEpAlertOnBreak()
+ {
+ ArrayList<Integer> epAlertPlace = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.alert.on-break", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epAlertPlace.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in alert on break list.");
+ }
+ }
return epAlertPlace;
}
- public ArrayList epBlackListPlacement()
- {
- ArrayList epBlack = new ArrayList();
- epBlack.addAll(Arrays.asList(config.getString("protect.blacklist.placement", "").split(",")));
- return epBlack;
- }
-
- public ArrayList epBlackListUsage()
- {
- ArrayList epBlack = new ArrayList();
- epBlack.addAll(Arrays.asList(config.getString("protect.blacklist.usage", "").split(",")));
- return epBlack;
+ public ArrayList<Integer> epBlackListPlacement()
+ {
+ ArrayList<Integer> epBlacklistPlacement = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.blacklist.placement", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epBlacklistPlacement.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in placement blacklist.");
+ }
+ }
+ return epBlacklistPlacement;
+ }
+
+ public ArrayList<Integer> epBlackListUsage()
+ {
+ ArrayList<Integer> epBlackListUsage = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.blacklist.usage", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epBlackListUsage.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in usage blacklist.");
+ }
+ }
+ return epBlackListUsage;
}
public HashMap<String, Boolean> getEpGuardSettings()
@@ -332,17 +391,39 @@ public class Settings implements IConf
config.load();
}
- public ArrayList itemSpawnBlacklist()
- {
- ArrayList epItemSpwn = new ArrayList();
- epItemSpwn.addAll(Arrays.asList(config.getString("item-spawn-blacklist", "").split(",")));
+ public ArrayList<Integer> itemSpawnBlacklist()
+ {
+ ArrayList<Integer> epItemSpwn = new ArrayList<Integer>();
+ for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epItemSpwn.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in item spawn blacklist.");
+ }
+ }
return epItemSpwn;
}
- public ArrayList epBlockBreakingBlacklist()
- {
- ArrayList epBreakList = new ArrayList();
- epBreakList.addAll(Arrays.asList(config.getString("protect.blacklist.break", "").split(",")));
+ public ArrayList<Integer> epBlockBreakingBlacklist()
+ {
+ ArrayList<Integer> epBreakList = new ArrayList<Integer>();
+ for (String itemName : config.getString("protect.blacklist.break", "").split(",")) {
+ if (itemName.isEmpty()) {
+ continue;
+ }
+ ItemStack is;
+ try {
+ is = ItemDb.get(itemName);
+ epBreakList.add(is.getTypeId());
+ } catch (Exception ex) {
+ logger.log(Level.SEVERE, "Unknown item " + itemName + " in block breaking blacklist.");
+ }
+ }
return epBreakList;
}
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
index ec93acc2c..3a041413f 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
@@ -26,12 +26,12 @@ public class EssentialsProtect extends JavaPlugin
public static HashMap<String, String> dataSettings = null;
public static HashMap<String, Boolean> guardSettings = null;
public static HashMap<String, Boolean> playerSettings = null;
- public static ArrayList usageList = null;
- public static ArrayList blackListPlace = null;
- public static ArrayList breakBlackList = null;
- public static ArrayList onPlaceAlert = null;
- public static ArrayList onUseAlert = null;
- public static ArrayList onBreakAlert = null;
+ public static ArrayList<Integer> usageList = null;
+ public static ArrayList<Integer> blackListPlace = null;
+ public static ArrayList<Integer> breakBlackList = null;
+ public static ArrayList<Integer> onPlaceAlert = null;
+ public static ArrayList<Integer> onUseAlert = null;
+ public static ArrayList<Integer> onBreakAlert = null;
public EssentialsProtect()
@@ -65,9 +65,9 @@ public class EssentialsProtect extends JavaPlugin
logger.info("Loaded " + this.getDescription().getName() + " build " + this.getDescription().getVersion() + " maintained by " + AUTHORS);
}
- public static boolean checkProtectionItems(ArrayList itemList, int id)
+ public static boolean checkProtectionItems(ArrayList<Integer> itemList, int id)
{
- return !itemList.isEmpty() && itemList.contains(String.valueOf(id));
+ return !itemList.isEmpty() && itemList.contains(id);
}
@Override
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index be5757364..742cb9d6d 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -56,7 +56,7 @@ public class EssentialsProtectBlockListener extends BlockListener
return;
}
- if (!EssentialsProtect.onPlaceAlert.isEmpty() && EssentialsProtect.onPlaceAlert.contains(String.valueOf(item.getTypeId())))
+ if (EssentialsProtect.checkProtectionItems(EssentialsProtect.onPlaceAlert, id))
{
parent.alert(user, item.getType().toString(), "placed: ");
}
@@ -192,13 +192,13 @@ public class EssentialsProtectBlockListener extends BlockListener
return;
}
- if(EssentialsProtect.breakBlackList.contains(String.valueOf(block.getTypeId())) && !user.isAuthorized("essentials.protect.exemptbreak"))
+ if (EssentialsProtect.checkProtectionItems(EssentialsProtect.breakBlackList, block.getTypeId()) && !user.isAuthorized("essentials.protect.exemptbreak"))
{
event.setCancelled(true);
return;
}
- if (!EssentialsProtect.onBreakAlert.isEmpty() && EssentialsProtect.onBreakAlert.contains(String.valueOf(block.getTypeId())))
+ if (EssentialsProtect.checkProtectionItems(EssentialsProtect.onBreakAlert, block.getTypeId()))
{
parent.alert(user, block.getType().toString(), "broke: ");
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
index 0c9cddec5..f8ef85cc7 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -45,11 +45,11 @@ public class EssentialsProtectPlayerListener extends PlayerListener
}
- if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage"))
- {
- event.setCancelled(true);
- return;
- }
+ if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage"))
+ {
+ event.setCancelled(true);
+ return;
+ }
if (user.isAuthorized("essentials.protect.admin"))
{
@@ -61,7 +61,7 @@ public class EssentialsProtectPlayerListener extends PlayerListener
+ ownerName);
}
}
- if (item != null && EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId())))
+ if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.onUseAlert, item.getTypeId()))
{
parent.alert(user, item.getType().toString(), "used: ");
}