summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-03 00:07:44 +0100
committersnowleo <schneeleo@gmail.com>2012-01-03 00:07:44 +0100
commit7153676137a23f6780b21682456377b0f86b6fb1 (patch)
tree7e455830ab2356e9f8a7411dc097ecb86149d428 /EssentialsProtect
parentd2c1b24e4bea0b54b1af2a3f78e78eb2c840b51b (diff)
downloadEssentials-7153676137a23f6780b21682456377b0f86b6fb1.tar
Essentials-7153676137a23f6780b21682456377b0f86b6fb1.tar.gz
Essentials-7153676137a23f6780b21682456377b0f86b6fb1.tar.lz
Essentials-7153676137a23f6780b21682456377b0f86b6fb1.tar.xz
Essentials-7153676137a23f6780b21682456377b0f86b6fb1.zip
Starting to break Protect
Diffstat (limited to 'EssentialsProtect')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java11
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java28
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java4
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java20
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java1
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java10
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java22
7 files changed, 62 insertions, 34 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java
index 7f9ec44e4..6f724ac87 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java
@@ -1,13 +1,13 @@
package com.earth2me.essentials.protect;
-import com.earth2me.essentials.api.IReload;
+import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
+import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.protect.data.ProtectedBlockMemory;
import com.earth2me.essentials.protect.data.ProtectedBlockMySQL;
import com.earth2me.essentials.protect.data.ProtectedBlockSQLite;
import java.beans.PropertyVetoException;
-import static com.earth2me.essentials.I18n._;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
@@ -30,7 +30,7 @@ public class EssentialsConnect
ess = (IEssentials)essPlugin;
protect = (IProtect)essProtect;
ProtectReloader pr = new ProtectReloader();
- pr.reloadConfig();
+ pr.onReload();
ess.addReloadListener(pr);
LOGGER.info(_("loadinfo", essProtect.getDescription().getName(), essProtect.getDescription().getVersion(), "essentials team"));
@@ -72,7 +72,8 @@ public class EssentialsConnect
{
protect.getStorage().onPluginDeactivation();
}
- for (ProtectConfig protectConfig : ProtectConfig.values())
+
+ /*for (ProtectConfig protectConfig : ProtectConfig.values())
{
if (protectConfig.isList())
{
@@ -87,7 +88,7 @@ public class EssentialsConnect
protect.getSettingsBoolean().put(protectConfig, ess.getSettings().getProtectBoolean(protectConfig.getConfigName(), protectConfig.getDefaultValueBoolean()));
}
- }
+ }*/
if (protect.getSettingString(ProtectConfig.datatype).equalsIgnoreCase("mysql"))
{
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
index e313298cd..43975216e 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
@@ -1,9 +1,6 @@
package com.earth2me.essentials.protect;
import com.earth2me.essentials.protect.data.IProtectedBlock;
-import java.util.EnumMap;
-import java.util.List;
-import java.util.Map;
import java.util.logging.Filter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -20,11 +17,12 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static com.mchange.v2.log.MLogger C3P0logger;
- private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
- private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
- private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
+ //private final transient Map<ProtectConfig, Boolean> settingsBoolean = new EnumMap<ProtectConfig, Boolean>(ProtectConfig.class);
+ //private final transient Map<ProtectConfig, String> settingsString = new EnumMap<ProtectConfig, String>(ProtectConfig.class);
+ //private final transient Map<ProtectConfig, List<Integer>> settingsList = new EnumMap<ProtectConfig, List<Integer>>(ProtectConfig.class);
private transient IProtectedBlock storage = null;
private transient EssentialsConnect ess = null;
+ private transient ProtectHolder settings = null;
@Override
public void onLoad()
@@ -95,12 +93,12 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
LOGGER.log(Level.SEVERE, "Essentials not installed or failed to load. Essenials Protect is in emergency mode now.");
}
- @Override
+ /*@Override
public boolean checkProtectionItems(final ProtectConfig list, final int id)
{
final List<Integer> itemList = settingsList.get(list);
return itemList != null && !itemList.isEmpty() && itemList.contains(id);
- }
+ }*/
@Override
public IProtectedBlock getStorage()
@@ -119,7 +117,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
return ess;
}
- public Map<ProtectConfig, Boolean> getSettingsBoolean()
+ /*public Map<ProtectConfig, Boolean> getSettingsBoolean()
{
return settingsBoolean;
}
@@ -146,7 +144,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
{
final String str = settingsString.get(protectConfig);
return str == null ? protectConfig.getDefaultValueString() : str;
- }
+ }*/
public void onDisable()
{
@@ -163,4 +161,14 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
{
}
}
+
+ public ProtectHolder getSettings()
+ {
+ return settings;
+ }
+
+ public void setSettings(final ProtectHolder settings)
+ {
+ this.settings = settings;
+ }
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index f30de1d81..abbbe5939 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -33,7 +33,7 @@ public class EssentialsProtectBlockListener extends BlockListener
final IUser user = ess.getUser(event.getPlayer());
- if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
+ if (prot.getSettingBool(ProtectConfig.disable_build) && !user.isAuthorized(Permissions.BUILD))
{
event.setCancelled(true);
return;
@@ -230,7 +230,7 @@ public class EssentialsProtectBlockListener extends BlockListener
}
final IUser user = ess.getUser(event.getPlayer());
- if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
+ if (prot.getSettingBool(ProtectConfig.disable_build) && !user.isAuthorized(Permissions.BUILD))
{
event.setCancelled(true);
return;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java
index afcb6e8ce..d25661bf8 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java
@@ -1,28 +1,24 @@
package com.earth2me.essentials.protect;
import com.earth2me.essentials.protect.data.IProtectedBlock;
-import java.util.List;
-import java.util.Map;
import org.bukkit.plugin.Plugin;
public interface IProtect extends Plugin
{
- boolean checkProtectionItems(final ProtectConfig list, final int id);
-
- boolean getSettingBool(final ProtectConfig protectConfig);
-
- String getSettingString(final ProtectConfig protectConfig);
-
+// boolean checkProtectionItems(final ProtectConfig list, final int id);
+// boolean getSettingBool(final ProtectConfig protectConfig);
+// String getSettingString(final ProtectConfig protectConfig);
IProtectedBlock getStorage();
void setStorage(IProtectedBlock pb);
EssentialsConnect getEssentialsConnect();
- Map<ProtectConfig, Boolean> getSettingsBoolean();
-
- Map<ProtectConfig, String> getSettingsString();
+// Map<ProtectConfig, Boolean> getSettingsBoolean();
+// Map<ProtectConfig, String> getSettingsString();
+// Map<ProtectConfig, List<Integer>> getSettingsList();
+ ProtectHolder getSettings();
- Map<ProtectConfig, List<Integer>> getSettingsList();
+ void setSettings(ProtectHolder settings);
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
index 699af6a9b..04b9d47df 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
@@ -6,6 +6,7 @@ import java.util.Locale;
public enum Permissions implements IPermission
{
+ BUILD,
PREVENTDAMAGE_FALL,
PREVENTDAMAGE_NONE
;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java
index bee8d0f4d..feeeb19df 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java
@@ -1,7 +1,7 @@
package com.earth2me.essentials.protect;
-public enum ProtectConfig
+/*public enum ProtectConfig
{
datatype("protect.datatype", "sqlite"),
mysqlDB("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"),
@@ -87,7 +87,7 @@ public enum ProtectConfig
/**
* @return the configName
- */
+ *//*
public String getConfigName()
{
return configName;
@@ -95,7 +95,7 @@ public enum ProtectConfig
/**
* @return the default value String
- */
+ *//*
public String getDefaultValueString()
{
return defValueString;
@@ -103,7 +103,7 @@ public enum ProtectConfig
/**
* @return the default value boolean
- */
+ *//*
public boolean getDefaultValueBoolean()
{
return defValueBoolean;
@@ -118,4 +118,4 @@ public enum ProtectConfig
{
return isList;
}
-}
+}*/
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java
new file mode 100644
index 000000000..2e2451397
--- /dev/null
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java
@@ -0,0 +1,22 @@
+package com.earth2me.essentials.protect;
+
+import com.earth2me.essentials.api.IEssentials;
+import com.earth2me.essentials.settings.protect.Protect;
+import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
+import java.io.File;
+import java.io.IOException;
+
+
+public class ProtectHolder extends AsyncStorageObjectHolder<Protect>
+{
+ public ProtectHolder(IEssentials ess)
+ {
+ super(ess, Protect.class);
+ }
+
+ @Override
+ public File getStorageFile() throws IOException
+ {
+ return new File(ess.getDataFolder(), "protect.yml");
+ }
+}