summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src
diff options
context:
space:
mode:
authorementalo <ementalodev@gmx.co.uk>2012-07-17 12:26:55 +0100
committerementalo <ementalodev@gmx.co.uk>2012-07-17 14:21:03 +0100
commita661bce7b3de3f53e2b7b79c1283f0affa6fe9c3 (patch)
tree2aa10b6300f6c8d3cb2b298c124180fade74857a /EssentialsProtect/src
parent3c385e69271dfe8530fadc3f67e13ee495e4b0e1 (diff)
parent9f05e43ecf8e6e1a8fcaef757678e762f0d82573 (diff)
downloadEssentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar
Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.gz
Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.lz
Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.tar.xz
Essentials-a661bce7b3de3f53e2b7b79c1283f0affa6fe9c3.zip
Merge of server-layer branch
Diffstat (limited to 'EssentialsProtect/src')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java121
-rw-r--r--EssentialsProtect/src/net/ess3/protect/BlockBreakPermissions.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/BlockBreakPermissions.java)21
-rw-r--r--EssentialsProtect/src/net/ess3/protect/BlockPlacePermissions.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/BlockPlacePermissions.java)20
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EmergencyListener.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java)2
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java)24
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java)83
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java)119
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java)84
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectPlayerListener.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java)4
-rw-r--r--EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java)2
-rw-r--r--EssentialsProtect/src/net/ess3/protect/IProtect.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java)4
-rw-r--r--EssentialsProtect/src/net/ess3/protect/ItemUsePermissions.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/ItemUsePermissions.java)19
-rw-r--r--EssentialsProtect/src/net/ess3/protect/Permissions.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java)6
-rw-r--r--EssentialsProtect/src/net/ess3/protect/ProtectHolder.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java)14
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/IProtectedBlock.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java)2
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/OwnedBlock.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java)2
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockJDBC.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java)26
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMemory.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java)42
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMySQL.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java)32
-rw-r--r--EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockSQLite.java (renamed from EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java)32
-rw-r--r--EssentialsProtect/src/plugin.yml4
21 files changed, 254 insertions, 409 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java b/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java
deleted file mode 100644
index feeeb19df..000000000
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectConfig.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package com.earth2me.essentials.protect;
-
-
-/*public enum ProtectConfig
-{
- datatype("protect.datatype", "sqlite"),
- mysqlDB("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"),
- dbUsername("protect.username", "root"),
- dbPassword("protect.password", ""),
- memstore("protect.memstore", false),
- disable_contactdmg("protect.disable.contactdmg", false),
- disable_lavadmg("protect.disable.lavadmg", false),
- disable_build("protect.disable.build", true),
- disable_use("protect.disable.use", true),
- disable_pvp("protect.disable.pvp", false),
- disable_projectiles("protect.disable.projectiles", false),
- disable_fall("protect.disable.fall", false),
- disable_suffocate("protect.disable.suffocate", false),
- disable_firedmg("protect.disable.firedmg", false),
- disable_lightning("protect.disable.lightning", false),
- disable_drown("protect.disable.drown", false),
- disable_weather_storm("protect.disable.weather.storm", false),
- disable_weather_lightning("protect.disable.weather.lightning", false),
- disable_weather_thunder("protect.disable.weather.thunder", false),
- prevent_fire_spread("protect.prevent.fire-spread", true),
- prevent_flint_fire("protect.prevent.flint-fire", false),
- prevent_lava_fire_spread("protect.prevent.lava-fire-spread", true),
- prevent_lightning_fire_spread("protect.prevent.lightning-fire-spread", true),
- prevent_water_flow("protect.prevent.water-flow", false),
- prevent_lava_flow("protect.prevent.lava-flow", false),
- prevent_water_bucket_flow("protect.prevent.water-bucket-flow", false),
- prevent_portal_creation("protect.prevent.portal-creation", false),
- prevent_block_on_rail("protect.protect.prevent-block-on-rails", false),
- prevent_tnt_explosion("protect.prevent.tnt-explosion", false),
- prevent_tnt_playerdmg("protect.prevent.tnt-playerdamage", false),
- prevent_fireball_explosion("protect.prevent.fireball-explosion", false),
- prevent_fireball_fire("protect.prevent.fireball-fire", false),
- prevent_fireball_playerdmg("protect.prevent.fireball-playerdamage", false),
- prevent_creeper_explosion("protect.prevent.creeper-explosion", true),
- prevent_creeper_playerdmg("protect.prevent.creeper-playerdamage", false),
- prevent_creeper_blockdmg("protect.prevent.creeper-blockdamage", false),
- prevent_enderman_pickup("protect.prevent.enderman-pickup", false),
- prevent_villager_death("protect.prevent.villager-death", false),
- prevent_enderdragon_blockdmg("protect.prevent.enderdragon-blockdamage", true),
- prevent_entitytarget("protect.prevent.entitytarget", false),
- protect_rails("protect.protect.rails", true),
- protect_below_rails("protect.protect.block-below", true),
- protect_signs("protect.protect.signs", true),
- protect_against_signs("protect.protect.block-below", true),
- enderdragon_fakeexplosions("protect.enderdragon-fakeexplosions", false),
- alert_on_placement("protect.alert.on-placement"),
- alert_on_use("protect.alert.on-use"),
- alert_on_break("protect.alert.on-break"),
- blacklist_placement("protect.blacklist.placement"),
- blacklist_usage("protect.blacklist.usage"),
- blacklist_break("protect.blacklist.break"),
- blacklist_piston("protect.blacklist.piston");
- private final String configName;
- private final String defValueString;
- private final boolean defValueBoolean;
- private final boolean isList;
- private final boolean isString;
-
- private ProtectConfig(final String configName)
- {
- this(configName, null, false, true, false);
- }
-
- private ProtectConfig(final String configName, final String defValueString)
- {
- this(configName, defValueString, false, false, true);
- }
-
- private ProtectConfig(final String configName, final boolean defValueBoolean)
- {
- this(configName, null, defValueBoolean, false, false);
- }
-
- private ProtectConfig(final String configName, final String defValueString, final boolean defValueBoolean, final boolean isList, final boolean isString)
- {
- this.configName = configName;
- this.defValueString = defValueString;
- this.defValueBoolean = defValueBoolean;
- this.isList = isList;
- this.isString = isString;
- }
-
- /**
- * @return the configName
- *//*
- public String getConfigName()
- {
- return configName;
- }
-
- /**
- * @return the default value String
- *//*
- public String getDefaultValueString()
- {
- return defValueString;
- }
-
- /**
- * @return the default value boolean
- *//*
- public boolean getDefaultValueBoolean()
- {
- return defValueBoolean;
- }
-
- public boolean isString()
- {
- return isString;
- }
-
- public boolean isList()
- {
- return isList;
- }
-}*/
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/BlockBreakPermissions.java b/EssentialsProtect/src/net/ess3/protect/BlockBreakPermissions.java
index 50be5dadb..1a07588e8 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/BlockBreakPermissions.java
+++ b/EssentialsProtect/src/net/ess3/protect/BlockBreakPermissions.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import net.ess3.api.IPermission;
import net.ess3.permissions.AbstractSuperpermsPermission;
@@ -8,26 +8,30 @@ import java.util.Map;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionDefault;
-public class BlockBreakPermissions extends AbstractSuperpermsPermission{
- private static Map<Material,IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
+
+public final class BlockBreakPermissions extends AbstractSuperpermsPermission
+{
+ private static Map<Material, IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
private static final String base = "essentials.protect.blockbreak.";
private final String permission;
-
- public static IPermission getPermission(Material mat)
+
+ public static IPermission getPermission(final Material mat)
{
IPermission perm = permissions.get(mat);
- if (perm == null) {
+ if (perm == null)
+ {
perm = new BlockBreakPermissions(mat.toString().toLowerCase(Locale.ENGLISH));
permissions.put(mat, perm);
}
return perm;
}
- private BlockBreakPermissions(String matName)
+ private BlockBreakPermissions(final String matName)
{
+ super();
this.permission = base + matName;
}
-
+
@Override
public String getPermission()
{
@@ -40,4 +44,3 @@ public class BlockBreakPermissions extends AbstractSuperpermsPermission{
return PermissionDefault.TRUE;
}
}
-
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/BlockPlacePermissions.java b/EssentialsProtect/src/net/ess3/protect/BlockPlacePermissions.java
index 0e553a243..87e771e73 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/BlockPlacePermissions.java
+++ b/EssentialsProtect/src/net/ess3/protect/BlockPlacePermissions.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import net.ess3.api.IPermission;
import net.ess3.permissions.AbstractSuperpermsPermission;
@@ -8,26 +8,30 @@ import java.util.Map;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionDefault;
-public class BlockPlacePermissions extends AbstractSuperpermsPermission{
- private static Map<Material,IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
+
+public class BlockPlacePermissions extends AbstractSuperpermsPermission
+{
+ private static Map<Material, IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
private static final String base = "essentials.protect.blockplace.";
private final String permission;
-
- public static IPermission getPermission(Material mat)
+
+ public static IPermission getPermission(final Material mat)
{
IPermission perm = permissions.get(mat);
- if (perm == null) {
+ if (perm == null)
+ {
perm = new BlockPlacePermissions(mat.toString().toLowerCase(Locale.ENGLISH));
permissions.put(mat, perm);
}
return perm;
}
- private BlockPlacePermissions(String matName)
+ private BlockPlacePermissions(final String matName)
{
+ super();
this.permission = base + matName;
}
-
+
@Override
public String getPermission()
{
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java b/EssentialsProtect/src/net/ess3/protect/EmergencyListener.java
index 5f9253c55..2d70ee698 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EmergencyListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EmergencyListener.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java b/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java
index 67993175d..c3fcfe441 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsConnect.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsConnect.java
@@ -1,11 +1,11 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import net.ess3.api.IReload;
import net.ess3.api.IUser;
-import com.earth2me.essentials.protect.data.ProtectedBlockMySQL;
-import com.earth2me.essentials.protect.data.ProtectedBlockSQLite;
+import net.ess3.protect.data.ProtectedBlockMySQL;
+import net.ess3.protect.data.ProtectedBlockSQLite;
import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -20,7 +20,7 @@ public class EssentialsConnect
private final transient IEssentials ess;
private final transient IProtect protect;
- public EssentialsConnect(Plugin essPlugin, Plugin essProtect)
+ public EssentialsConnect(final Plugin essPlugin, final Plugin essProtect)
{
if (!essProtect.getDescription().getVersion().equals(essPlugin.getDescription().getVersion()))
{
@@ -29,15 +29,11 @@ public class EssentialsConnect
ess = (IEssentials)essPlugin;
protect = (IProtect)essProtect;
protect.setSettings(new ProtectHolder(ess));
- ProtectReloader pr = new ProtectReloader();
+ final ProtectReloader pr = new ProtectReloader();
pr.onReload();
ess.addReloadListener(pr);
}
- public void onDisable()
- {
- }
-
public IEssentials getEssentials()
{
return ess;
@@ -84,7 +80,7 @@ public class EssentialsConnect
* }
*/
- ProtectHolder settings = protect.getSettings();
+ final ProtectHolder settings = protect.getSettings();
settings.acquireReadLock();
try
{
@@ -106,7 +102,7 @@ public class EssentialsConnect
{
try
{
- protect.setStorage(new ProtectedBlockSQLite("jdbc:sqlite:plugins/Essentials/EssentialsProtect.db"));
+ protect.setStorage(new ProtectedBlockSQLite("jdbc:sqlite:" + ess.getDataFolder() + "/EssentialsProtect.db"));
}
catch (PropertyVetoException ex)
{
@@ -114,9 +110,9 @@ public class EssentialsConnect
}
}
/*if (protect.getSettingBool(ProtectConfig.memstore))
- {
- protect.setStorage(new ProtectedBlockMemory(protect.getStorage(), protect));
- }*/
+ {
+ protect.setStorage(new ProtectedBlockMemory(protect.getStorage(), protect));
+ }*/
}
finally
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java
index 72000eeba..9f1e58e10 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtect.java
@@ -1,10 +1,11 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
-import com.earth2me.essentials.protect.data.IProtectedBlock;
+import net.ess3.protect.data.IProtectedBlock;
import java.util.logging.Filter;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
+
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@@ -21,6 +22,7 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
private transient IProtectedBlock storage = null;
private transient EssentialsConnect ess = null;
private transient ProtectHolder settings = null;
+ private transient com.mchange.v2.c3p0.management.ActiveManagementCoordinator temp; // leave this here for maven
@Override
public void onLoad()
@@ -28,17 +30,18 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
C3P0logger = com.mchange.v2.log.MLog.getLogger(com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.class);
C3P0logger.setFilter(new Filter()
{
- public boolean isLoggable(LogRecord lr)
+ public boolean isLoggable(final LogRecord lr)
{
return lr.getLevel() != Level.INFO;
}
});
}
+ @Override
public void onEnable()
{
final PluginManager pm = this.getServer().getPluginManager();
- final Plugin essPlugin = pm.getPlugin("Essentials3");
+ final Plugin essPlugin = pm.getPlugin("Essentials-3");
if (essPlugin == null || !essPlugin.isEnabled())
{
enableEmergencyMode(pm);
@@ -72,12 +75,11 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
}
/*@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);
- }*/
-
+ 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()
{
@@ -85,45 +87,46 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
}
@Override
- public void setStorage(IProtectedBlock pb)
+ public void setStorage(final IProtectedBlock pb)
{
storage = pb;
}
+ @Override
public EssentialsConnect getEssentialsConnect()
{
return ess;
}
-
- /*public Map<ProtectConfig, Boolean> getSettingsBoolean()
- {
- return settingsBoolean;
- }
-
- public Map<ProtectConfig, String> getSettingsString()
- {
- return settingsString;
- }
-
- public Map<ProtectConfig, List<Integer>> getSettingsList()
- {
- return settingsList;
- }
-
- @Override
- public boolean getSettingBool(final ProtectConfig protectConfig)
- {
- final Boolean bool = settingsBoolean.get(protectConfig);
- return bool == null ? protectConfig.getDefaultValueBoolean() : bool;
- }
+ /*public Map<ProtectConfig, Boolean> getSettingsBoolean()
+ {
+ return settingsBoolean;
+ }
+
+ public Map<ProtectConfig, String> getSettingsString()
+ {
+ return settingsString;
+ }
+
+ public Map<ProtectConfig, List<Integer>> getSettingsList()
+ {
+ return settingsList;
+ }
+
+ @Override
+ public boolean getSettingBool(final ProtectConfig protectConfig)
+ {
+ final Boolean bool = settingsBoolean.get(protectConfig);
+ return bool == null ? protectConfig.getDefaultValueBoolean() : bool;
+ }
+
+ @Override
+ public String getSettingString(final ProtectConfig protectConfig)
+ {
+ final String str = settingsString.get(protectConfig);
+ return str == null ? protectConfig.getDefaultValueString() : str;
+ }*/
@Override
- public String getSettingString(final ProtectConfig protectConfig)
- {
- final String str = settingsString.get(protectConfig);
- return str == null ? protectConfig.getDefaultValueString() : str;
- }*/
-
public void onDisable()
{
if (storage != null)
@@ -140,11 +143,13 @@ public class EssentialsProtect extends JavaPlugin implements IProtect
}
}
+ @Override
public ProtectHolder getSettings()
{
return settings;
}
+ @Override
public void setSettings(final ProtectHolder settings)
{
this.settings = settings;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java
index 1a711bd8d..77bb472c7 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectBlockListener.java
@@ -1,10 +1,11 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
import com.earth2me.essentials.protect.data.IProtectedBlock;
import java.util.ArrayList;
import java.util.List;
+
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -18,22 +19,15 @@ import org.bukkit.event.block.*;
public class EssentialsProtectBlockListener implements Listener
{
final private transient IProtect prot;
- final private transient IEssentials ess;
public EssentialsProtectBlockListener(final IProtect parent)
{
this.prot = parent;
- this.ess = prot.getEssentialsConnect().getEssentials();
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
-
final Player user = event.getPlayer();
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
@@ -46,7 +40,6 @@ public class EssentialsProtectBlockListener implements Listener
}
final Block blockPlaced = event.getBlockPlaced();
- final int id = blockPlaced.getTypeId();
if (!BlockPlacePermissions.getPermission(blockPlaced.getType()).isAuthorized(user))
{
@@ -54,8 +47,8 @@ public class EssentialsProtectBlockListener implements Listener
return;
}
- if (!Permissions.ALERTS_NOTRIGGER.isAuthorized(user) &&
- settings.getData().getAlertOnPlacement().contains(blockPlaced.getType()))
+ if (!Permissions.ALERTS_NOTRIGGER.isAuthorized(user)
+ && settings.getData().getAlertOnPlacement().contains(blockPlaced.getType()))
{
prot.getEssentialsConnect().alert(user, blockPlaced.getType().toString(), _("alertPlaced"));
}
@@ -82,18 +75,18 @@ public class EssentialsProtectBlockListener implements Listener
}
}
/*if ((blockPlaced.getType() == Material.SIGN_POST || blockPlaced.getType() == Material.WALL_SIGN)
- && settings.getData().getSignsAndRails().isProtectSigns()
- && user.isAuthorized("essentials.protect"))
- {
- protect.add(blockPlaced);
- if (settings.getData().getSignsAndRails().isBlockBelow()
- && event.getBlockAgainst().getType() != Material.SIGN_POST
- && event.getBlockAgainst().getType() != Material.WALL_SIGN
- && !isProtected(event.getBlockAgainst(), user, settings))
- {
- protect.add(event.getBlockAgainst());
- }
- }*/
+ && settings.getData().getSignsAndRails().isProtectSigns()
+ && user.isAuthorized("essentials.protect"))
+ {
+ protect.add(blockPlaced);
+ if (settings.getData().getSignsAndRails().isBlockBelow()
+ && event.getBlockAgainst().getType() != Material.SIGN_POST
+ && event.getBlockAgainst().getType() != Material.WALL_SIGN
+ && !isProtected(event.getBlockAgainst(), user, settings))
+ {
+ protect.add(event.getBlockAgainst());
+ }
+ }*/
for (Block block : protect)
{
prot.getStorage().protectBlock(block, user.getName());
@@ -105,13 +98,9 @@ public class EssentialsProtectBlockListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -165,13 +154,9 @@ public class EssentialsProtectBlockListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockFromTo(final BlockFromToEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -214,13 +199,9 @@ public class EssentialsProtectBlockListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(final BlockBurnEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -260,13 +241,9 @@ public class EssentialsProtectBlockListener implements Listener
BlockFace.SELF
};
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final Player user = event.getPlayer();
if (!Permissions.BUILD.isAuthorized(user))
@@ -275,7 +252,6 @@ public class EssentialsProtectBlockListener implements Listener
return;
}
final Block block = event.getBlock();
- final int typeId = block.getTypeId();
if (!BlockBreakPermissions.getPermission(block.getType()).isAuthorized(user))
{
@@ -366,13 +342,9 @@ public class EssentialsProtectBlockListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonExtend(final BlockPistonExtendEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -428,10 +400,10 @@ public class EssentialsProtectBlockListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPistonRetract(final BlockPistonRetractEvent event)
{
- if (event.isCancelled() || !event.isSticky())
+ if (!event.isSticky())
{
return;
}
@@ -482,7 +454,6 @@ public class EssentialsProtectBlockListener implements Listener
}
}
}
-
finally
{
settings.unlock();
@@ -499,31 +470,31 @@ public class EssentialsProtectBlockListener implements Listener
return prot.getStorage().isProtected(block, user.getName());
}
- final Block up = block.getRelative(BlockFace.UP);
- if (up != null && up.getType() == Material.SIGN_POST)
- {
- return prot.getStorage().isProtected(block, user.getName());
- }
- final BlockFace[] directions = new BlockFace[]
- {
- BlockFace.NORTH,
- BlockFace.EAST,
- BlockFace.SOUTH,
- BlockFace.WEST
- };
- for (BlockFace blockFace : directions)
+ final Block up = block.getRelative(BlockFace.UP);
+ if (up != null && up.getType() == Material.SIGN_POST)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ final BlockFace[] directions = new BlockFace[]
+ {
+ BlockFace.NORTH,
+ BlockFace.EAST,
+ BlockFace.SOUTH,
+ BlockFace.WEST
+ };
+ for (BlockFace blockFace : directions)
+ {
+ final Block signblock = block.getRelative(blockFace);
+ if (signblock.getType() == Material.WALL_SIGN)
{
- final Block signblock = block.getRelative(blockFace);
- if (signblock.getType() == Material.WALL_SIGN)
+ final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
+ if (signMat != null && signMat.getFacing() == blockFace)
{
- final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
- if (signMat != null && signMat.getFacing() == blockFace)
- {
- return prot.getStorage().isProtected(block, user.getName());
- }
+ return prot.getStorage().isProtected(block, user.getName());
}
}
-
+ }
+
}
if (settings.getData().getSignsAndRails().isProtectRails())
{
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
index dabf2b0a0..f4146c5bb 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectEntityListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectEntityListener.java
@@ -1,7 +1,6 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import net.ess3.api.IEssentials;
-import net.ess3.craftbukkit.FakeExplosion;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -9,30 +8,24 @@ import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
+import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
-import org.bukkit.event.entity.*;
public class EssentialsProtectEntityListener implements Listener
{
private final transient IProtect prot;
- private final transient IEssentials ess;
public EssentialsProtectEntityListener(final IProtect prot)
{
super();
this.prot = prot;
- this.ess = prot.getEssentialsConnect().getEssentials();
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityDamage(final EntityDamageEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -172,13 +165,9 @@ public class EssentialsProtectEntityListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityExplode(final EntityExplodeEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
@@ -196,9 +185,8 @@ public class EssentialsProtectEntityListener implements Listener
|| settings.getData().getPrevent().isCreeperBlockdamage()
|| (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
{
- //Nicccccccccce plaaacccccccccce..
- FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
event.setCancelled(true);
+ event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
return;
}
else if (event.getEntity() instanceof TNTPrimed
@@ -249,57 +237,23 @@ public class EssentialsProtectEntityListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onCreatureSpawn(final CreatureSpawnEvent event)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onEntityTarget(final EntityTargetEvent event)
{
- if (event.getEntity() instanceof Player)
- {
- return;
- }
- if (event.isCancelled())
- {
- return;
- }
- final CreatureType creature = event.getCreatureType();
- if (creature == null)
+ if (event.getTarget().getType() == EntityType.PLAYER)
{
- return;
- }
- final ProtectHolder settings = prot.getSettings();
- settings.acquireReadLock();
- try
- {
- final Boolean prevent = settings.getData().getPrevent().getSpawn().get(creature);
- if (prevent != null && prevent)
+ final Player user = (Player)event.getTarget();
+ if ((event.getReason() == TargetReason.CLOSEST_PLAYER
+ || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
+ || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
+ || event.getReason() == TargetReason.RANDOM_TARGET
+ || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
+ || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
+ && Permissions.ENTITYTARGET.isAuthorized(user))
{
event.setCancelled(true);
}
}
- finally
- {
- settings.unlock();
- }
- }
-
- @EventHandler(priority = EventPriority.HIGHEST)
- public void onEntityTarget(final EntityTargetEvent event)
- {
- if (event.isCancelled() || !(event.getTarget() instanceof Player))
- {
- return;
- }
- final Player user = (Player)event.getTarget();
- if ((event.getReason() == TargetReason.CLOSEST_PLAYER
- || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
- || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
- || event.getReason() == TargetReason.RANDOM_TARGET
- || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
- || event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
- && Permissions.ENTITYTARGET.isAuthorized(user))
- {
- event.setCancelled(true);
- return;
- }
}
@EventHandler(priority = EventPriority.HIGHEST)
@@ -321,13 +275,9 @@ public class EssentialsProtectEntityListener implements Listener
}
}
- @EventHandler(priority = EventPriority.HIGHEST)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
- if (event.isCancelled())
- {
- return;
- }
final ProtectHolder settings = prot.getSettings();
settings.acquireReadLock();
try
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectPlayerListener.java
index d92265442..8022df16d 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectPlayerListener.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import static net.ess3.I18n._;
import net.ess3.api.IEssentials;
@@ -16,12 +16,10 @@ import org.bukkit.inventory.ItemStack;
public class EssentialsProtectPlayerListener implements Listener
{
private final transient IProtect prot;
- private final transient IEssentials ess;
public EssentialsProtectPlayerListener(final IProtect prot)
{
this.prot = prot;
- this.ess = prot.getEssentialsConnect().getEssentials();
}
@EventHandler(priority = EventPriority.LOW)
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java
index babebac71..6f08bdd13 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectWeatherListener.java
+++ b/EssentialsProtect/src/net/ess3/protect/EssentialsProtectWeatherListener.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java b/EssentialsProtect/src/net/ess3/protect/IProtect.java
index d25661bf8..df2a454a0 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/IProtect.java
+++ b/EssentialsProtect/src/net/ess3/protect/IProtect.java
@@ -1,6 +1,6 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
-import com.earth2me.essentials.protect.data.IProtectedBlock;
+import net.ess3.protect.data.IProtectedBlock;
import org.bukkit.plugin.Plugin;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ItemUsePermissions.java b/EssentialsProtect/src/net/ess3/protect/ItemUsePermissions.java
index e623fe003..d9ecf9bc0 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/ItemUsePermissions.java
+++ b/EssentialsProtect/src/net/ess3/protect/ItemUsePermissions.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import net.ess3.api.IPermission;
import net.ess3.permissions.AbstractSuperpermsPermission;
@@ -8,26 +8,29 @@ import java.util.Map;
import org.bukkit.Material;
import org.bukkit.permissions.PermissionDefault;
-public class ItemUsePermissions extends AbstractSuperpermsPermission{
- private static Map<Material,IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
+
+public class ItemUsePermissions extends AbstractSuperpermsPermission
+{
+ private static Map<Material, IPermission> permissions = new EnumMap<Material, IPermission>(Material.class);
private static final String base = "essentials.protect.itemuse.";
private final String permission;
-
- public static IPermission getPermission(Material mat)
+
+ public static IPermission getPermission(final Material mat)
{
IPermission perm = permissions.get(mat);
- if (perm == null) {
+ if (perm == null)
+ {
perm = new ItemUsePermissions(mat.toString().toLowerCase(Locale.ENGLISH));
permissions.put(mat, perm);
}
return perm;
}
- private ItemUsePermissions(String matName)
+ private ItemUsePermissions(final String matName)
{
this.permission = base + matName;
}
-
+
@Override
public String getPermission()
{
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java b/EssentialsProtect/src/net/ess3/protect/Permissions.java
index 0cb2d49ef..37042618b 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/Permissions.java
+++ b/EssentialsProtect/src/net/ess3/protect/Permissions.java
@@ -1,7 +1,7 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
-import net.ess3.utils.Util;
import net.ess3.api.IPermission;
+import net.ess3.utils.Util;
import java.util.Locale;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
@@ -74,7 +74,7 @@ public enum Permissions implements IPermission
}
@Override
- public boolean isAuthorized(CommandSender sender)
+ public boolean isAuthorized(final CommandSender sender)
{
return sender.hasPermission(getBukkitPermission());
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java b/EssentialsProtect/src/net/ess3/protect/ProtectHolder.java
index d9df03bbf..145a5e97e 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/ProtectHolder.java
+++ b/EssentialsProtect/src/net/ess3/protect/ProtectHolder.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect;
+package net.ess3.protect;
import net.ess3.api.IEssentials;
import net.ess3.settings.protect.Protect;
@@ -9,7 +9,7 @@ import java.io.IOException;
public class ProtectHolder extends AsyncStorageObjectHolder<Protect>
{
- public ProtectHolder(IEssentials ess)
+ public ProtectHolder(final IEssentials ess)
{
super(ess, Protect.class);
}
@@ -19,4 +19,14 @@ public class ProtectHolder extends AsyncStorageObjectHolder<Protect>
{
return new File(ess.getDataFolder(), "protect.yml");
}
+
+ @Override
+ public void finishRead()
+ {
+ }
+
+ @Override
+ public void finishWrite()
+ {
+ }
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java b/EssentialsProtect/src/net/ess3/protect/data/IProtectedBlock.java
index 755baface..a27adfb3c 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/IProtectedBlock.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/IProtectedBlock.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
import java.util.List;
import org.bukkit.block.Block;
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java b/EssentialsProtect/src/net/ess3/protect/data/OwnedBlock.java
index dc28feae8..cac1826e9 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/OwnedBlock.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/OwnedBlock.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
public class OwnedBlock
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockJDBC.java
index e24a71b80..70475c6f5 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockJDBC.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockJDBC.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import java.beans.PropertyVetoException;
@@ -34,12 +34,12 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
protected abstract PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException;
- public ProtectedBlockJDBC(String driver, String url) throws PropertyVetoException
+ public ProtectedBlockJDBC(final String driver, final String url) throws PropertyVetoException
{
this(driver, url, null, null);
}
- public ProtectedBlockJDBC(String driver, String url, String username, String password) throws PropertyVetoException
+ public ProtectedBlockJDBC(final String driver, final String url, final String username, final String password) throws PropertyVetoException
{
cpds = new ComboPooledDataSource();
cpds.setDriverClass(driver);
@@ -97,6 +97,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
+ @Override
public void clearProtections()
{
Connection conn = null;
@@ -138,7 +139,8 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
- public void importProtections(List<OwnedBlock> blocks)
+ @Override
+ public void importProtections(final List<OwnedBlock> blocks)
{
for (OwnedBlock ownedBlock : blocks)
{
@@ -150,6 +152,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
+ @Override
public List<OwnedBlock> exportProtections()
{
Connection conn = null;
@@ -216,12 +219,13 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
- public void protectBlock(Block block, String playerName)
+ @Override
+ public void protectBlock(final Block block, final String playerName)
{
protectBlock(block.getWorld().getName(), block.getX(), block.getY(), block.getZ(), playerName);
}
- private void protectBlock(String world, int x, int y, int z, String playerName)
+ private void protectBlock(final String world, final int x, final int y, final int z, final String playerName)
{
Connection conn = null;
PreparedStatement ps = null;
@@ -262,7 +266,8 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
- public boolean isProtected(Block block, String playerName)
+ @Override
+ public boolean isProtected(final Block block, final String playerName)
{
Connection conn = null;
PreparedStatement ps = null;
@@ -317,7 +322,8 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
- public List<String> getOwners(Block block)
+ @Override
+ public List<String> getOwners(final Block block)
{
Connection conn = null;
PreparedStatement ps = null;
@@ -377,7 +383,8 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
- public int unprotectBlock(Block block)
+ @Override
+ public int unprotectBlock(final Block block)
{
Connection conn = null;
PreparedStatement ps = null;
@@ -419,6 +426,7 @@ public abstract class ProtectedBlockJDBC implements IProtectedBlock
}
}
+ @Override
public void onPluginDeactivation()
{
cpds.close();
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMemory.java
index 876c8a575..10c825154 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMemory.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMemory.java
@@ -1,13 +1,13 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
-import java.util.Map.Entry;
import java.util.*;
+import java.util.Map.Entry;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.plugin.Plugin;
-public class ProtectedBlockMemory implements IProtectedBlock
+public final class ProtectedBlockMemory implements IProtectedBlock
{
private final transient List<String> worlds = new ArrayList<String>();
private final transient List<String> playerNames = new ArrayList<String>();
@@ -123,12 +123,14 @@ public class ProtectedBlockMemory implements IProtectedBlock
importProtections(storage.exportProtections());
}
+ @Override
public void clearProtections()
{
blocks.clear();
}
- public final void importProtections(final List<OwnedBlock> blocks)
+ @Override
+ public void importProtections(final List<OwnedBlock> blocks)
{
for (OwnedBlock ownedBlock : blocks)
{
@@ -141,6 +143,7 @@ public class ProtectedBlockMemory implements IProtectedBlock
}
}
+ @Override
public List<OwnedBlock> exportProtections()
{
final List<OwnedBlock> blockList = new ArrayList<OwnedBlock>(blocks.size());
@@ -160,12 +163,14 @@ public class ProtectedBlockMemory implements IProtectedBlock
return blockList;
}
+ @Override
public void protectBlock(final Block block, final String playerName)
{
final ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
protectBlock(pl, playerName);
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
{
+ @Override
public void run()
{
storage.protectBlock(block, playerName);
@@ -173,9 +178,9 @@ public class ProtectedBlockMemory implements IProtectedBlock
});
}
- private final void protectBlock(ProtectedLocation pl, String playerName)
+ private void protectBlock(final ProtectedLocation pl, final String playerName)
{
- int playerId = getPlayerId(playerName);
+ final int playerId = getPlayerId(playerName);
ProtectedBy pb = blocks.get(pl);
if (pb == null)
{
@@ -185,27 +190,31 @@ public class ProtectedBlockMemory implements IProtectedBlock
pb.add(playerId);
}
- public boolean isProtected(Block block, String playerName)
+ @Override
+ public boolean isProtected(final Block block, final String playerName)
{
- int playerId = getPlayerId(playerName);
- ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
- ProtectedBy pb = blocks.get(pl);
+ final int playerId = getPlayerId(playerName);
+ final ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
+ final ProtectedBy pb = blocks.get(pl);
return !pb.contains(playerId);
}
- public List<String> getOwners(Block block)
+ @Override
+ public List<String> getOwners(final Block block)
{
ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
ProtectedBy pb = blocks.get(pl);
return pb.getPlayers(playerNames);
}
+ @Override
public int unprotectBlock(final Block block)
{
- ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
- ProtectedBy pb = blocks.remove(pl);
+ final ProtectedLocation pl = new ProtectedLocation(block, getWorldId(block.getWorld()));
+ final ProtectedBy pb = blocks.remove(pl);
plugin.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable()
{
+ @Override
public void run()
{
storage.unprotectBlock(block);
@@ -214,7 +223,7 @@ public class ProtectedBlockMemory implements IProtectedBlock
return pb.size();
}
- private int getPlayerId(String playername)
+ private int getPlayerId(final String playername)
{
int id = playerNames.indexOf(playername);
if (id < 0)
@@ -225,12 +234,12 @@ public class ProtectedBlockMemory implements IProtectedBlock
return id;
}
- private int getWorldId(World world)
+ private int getWorldId(final World world)
{
return getWorldId(world.getName());
}
- private int getWorldId(String name)
+ private int getWorldId(final String name)
{
int id = worlds.indexOf(name);
if (id < 0)
@@ -241,6 +250,7 @@ public class ProtectedBlockMemory implements IProtectedBlock
return id;
}
+ @Override
public void onPluginDeactivation()
{
storage.onPluginDeactivation();
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMySQL.java
index 2a0077698..9fd17d0a7 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockMySQL.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockMySQL.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
import java.beans.PropertyVetoException;
import java.sql.Connection;
@@ -11,7 +11,7 @@ import java.util.logging.Logger;
public class ProtectedBlockMySQL extends ProtectedBlockJDBC
{
- public ProtectedBlockMySQL(String url, String username, String password) throws PropertyVetoException
+ public ProtectedBlockMySQL(final String url, final String username, final String password) throws PropertyVetoException
{
super("com.mysql.jdbc.Driver", url, username, password);
}
@@ -24,7 +24,7 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
+ ") ENGINE=MyISAM DEFAULT CHARSET=utf8";
@Override
- protected PreparedStatement getStatementCreateTable(Connection conn) throws SQLException
+ protected PreparedStatement getStatementCreateTable(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryCreateTable);
}
@@ -40,7 +40,7 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
+ "DROP PRIMARY KEY ;";
@Override
- protected PreparedStatement getStatementUpdateFrom2_0Table(Connection conn) throws SQLException
+ protected PreparedStatement getStatementUpdateFrom2_0Table(final Connection conn) throws SQLException
{
PreparedStatement testPS = null;
ResultSet testRS = null;
@@ -86,7 +86,7 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
private static final String QueryDeleteAll = "DELETE FROM EssentialsProtect;";
@Override
- protected PreparedStatement getStatementDeleteAll(Connection conn) throws SQLException
+ protected PreparedStatement getStatementDeleteAll(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryDeleteAll);
}
@@ -94,9 +94,10 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
"INSERT INTO EssentialsProtect (worldName, x, y, z, playerName) VALUES (?, ?, ?, ?, ?);";
@Override
- protected PreparedStatement getStatementInsert(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException
+ protected PreparedStatement getStatementInsert(final Connection conn, final String world, final int x, final int y, final int z,
+ final String playerName) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryInsert);
+ final PreparedStatement ps = conn.prepareStatement(QueryInsert);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -109,9 +110,10 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
+ "WHERE worldName = ? AND x = ? AND y = ? AND z = ? GROUP BY x;";
@Override
- protected PreparedStatement getStatementPlayerCountByLocation(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException
+ protected PreparedStatement getStatementPlayerCountByLocation(final Connection conn, final String world, final int x, final int y, final int z,
+ final String playerName) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryCountByPlayer);
+ final PreparedStatement ps = conn.prepareStatement(QueryCountByPlayer);
ps.setString(1, playerName);
ps.setString(2, world);
ps.setInt(3, x);
@@ -123,9 +125,10 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
"SELECT playerName FROM EssentialsProtect WHERE worldname = ? AND x = ? AND y = ? AND z = ?;";
@Override
- protected PreparedStatement getStatementPlayersByLocation(Connection conn, String world, int x, int y, int z) throws SQLException
+ protected PreparedStatement getStatementPlayersByLocation(final Connection conn, final String world,
+ final int x, final int y, final int z) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation);
+ final PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -136,9 +139,10 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
"DELETE FROM EssentialsProtect WHERE worldName = ? AND x = ? AND y = ? AND z = ?;";
@Override
- protected PreparedStatement getStatementDeleteByLocation(Connection conn, String world, int x, int y, int z) throws SQLException
+ protected PreparedStatement getStatementDeleteByLocation(final Connection conn, final String world,
+ final int x, final int y, final int z) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation);
+ final PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -149,7 +153,7 @@ public class ProtectedBlockMySQL extends ProtectedBlockJDBC
"SELECT worldName, x, y, z, playerName FROM EssentialsProtect;";
@Override
- protected PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException
+ protected PreparedStatement getStatementAllBlocks(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryAllBlocks);
}
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockSQLite.java
index cf256f1ec..65dbac213 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/data/ProtectedBlockSQLite.java
+++ b/EssentialsProtect/src/net/ess3/protect/data/ProtectedBlockSQLite.java
@@ -1,4 +1,4 @@
-package com.earth2me.essentials.protect.data;
+package net.ess3.protect.data;
import java.beans.PropertyVetoException;
import java.sql.Connection;
@@ -8,7 +8,7 @@ import java.sql.SQLException;
public class ProtectedBlockSQLite extends ProtectedBlockJDBC
{
- public ProtectedBlockSQLite(String url) throws PropertyVetoException
+ public ProtectedBlockSQLite(final String url) throws PropertyVetoException
{
super("org.sqlite.JDBC", url);
}
@@ -18,7 +18,7 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
+ "x NUMERIC, y NUMERIC, z NUMERIC)";
@Override
- protected PreparedStatement getStatementCreateTable(Connection conn) throws SQLException
+ protected PreparedStatement getStatementCreateTable(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryCreateTable);
}
@@ -27,14 +27,14 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
+ "worldName, x, z, y)";
@Override
- protected PreparedStatement getStatementUpdateFrom2_0Table(Connection conn) throws SQLException
+ protected PreparedStatement getStatementUpdateFrom2_0Table(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryUpdateFrom2_0Table);
}
private static final String QueryDeleteAll = "DELETE FROM EssentialsProtect;";
@Override
- protected PreparedStatement getStatementDeleteAll(Connection conn) throws SQLException
+ protected PreparedStatement getStatementDeleteAll(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryDeleteAll);
}
@@ -42,9 +42,10 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
"INSERT INTO EssentialsProtect (worldName, x, y, z, playerName) VALUES (?, ?, ?, ?, ?);";
@Override
- protected PreparedStatement getStatementInsert(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException
+ protected PreparedStatement getStatementInsert(final Connection conn, final String world,
+ final int x, final int y, final int z, final String playerName) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryInsert);
+ final PreparedStatement ps = conn.prepareStatement(QueryInsert);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -57,9 +58,10 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
+ "WHERE worldName = ? AND x = ? AND y = ? AND z = ? GROUP BY x;";
@Override
- protected PreparedStatement getStatementPlayerCountByLocation(Connection conn, String world, int x, int y, int z, String playerName) throws SQLException
+ protected PreparedStatement getStatementPlayerCountByLocation(final Connection conn, final String world,
+ final int x, final int y, final int z, final String playerName) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryPlayerCountByLocation);
+ final PreparedStatement ps = conn.prepareStatement(QueryPlayerCountByLocation);
ps.setString(1, playerName);
ps.setString(2, world);
ps.setInt(3, x);
@@ -71,9 +73,10 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
"SELECT playerName FROM EssentialsProtect WHERE worldname = ? AND x = ? AND y = ? AND z = ?;";
@Override
- protected PreparedStatement getStatementPlayersByLocation(Connection conn, String world, int x, int y, int z) throws SQLException
+ protected PreparedStatement getStatementPlayersByLocation(final Connection conn, final String world,
+ final int x, final int y, final int z) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation);
+ final PreparedStatement ps = conn.prepareStatement(QueryPlayersByLocation);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -84,9 +87,10 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
"DELETE FROM EssentialsProtect WHERE worldName = ? AND x = ? AND y = ? AND z = ?;";
@Override
- protected PreparedStatement getStatementDeleteByLocation(Connection conn, String world, int x, int y, int z) throws SQLException
+ protected PreparedStatement getStatementDeleteByLocation(final Connection conn, final String world,
+ final int x, final int y, final int z) throws SQLException
{
- PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation);
+ final PreparedStatement ps = conn.prepareStatement(QueryDeleteByLocation);
ps.setString(1, world);
ps.setInt(2, x);
ps.setInt(3, y);
@@ -97,7 +101,7 @@ public class ProtectedBlockSQLite extends ProtectedBlockJDBC
"SELECT worldName, x, y, z, playerName FROM EssentialsProtect;";
@Override
- protected PreparedStatement getStatementAllBlocks(Connection conn) throws SQLException
+ protected PreparedStatement getStatementAllBlocks(final Connection conn) throws SQLException
{
return conn.prepareStatement(QueryAllBlocks);
}
diff --git a/EssentialsProtect/src/plugin.yml b/EssentialsProtect/src/plugin.yml
index f87cdc7c7..1510a4fa1 100644
--- a/EssentialsProtect/src/plugin.yml
+++ b/EssentialsProtect/src/plugin.yml
@@ -1,9 +1,9 @@
# This determines the command prefix when there are conflicts (/name:home, /name:help, etc.)
name: EssentialsProtect
-main: com.earth2me.essentials.protect.EssentialsProtect
+main: net.ess3.protect.EssentialsProtect
# Note to developers: This next line cannot change, or the automatic versioning system will break.
version: ${build.number}
website: http://tiny.cc/EssentialsWiki
description: Provides protection for various parts of the world.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
-softdepend: [Essentials3] \ No newline at end of file
+softdepend: [Essentials-3] \ No newline at end of file