summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-18 04:01:01 +0100
committersnowleo <schneeleo@gmail.com>2012-01-18 04:01:01 +0100
commitf0dd81ee000b333b2aca59b9949518c7686cceb1 (patch)
treecf620b5603e1b25656550f87a37975b6dc5351af /EssentialsProtect
parent27b0cc86de8c21f089e0e68a5db3ebb42f4df2d2 (diff)
parent5c1d49fd0efe56c24d6ae5f63f4d0cc31329243d (diff)
downloadEssentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.gz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.lz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.xz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.zip
Merge branch 'refs/heads/master' into 3.0
Did some tweaks, so that it actually works. Conflicts: Essentials/src/com/earth2me/essentials/Essentials.java Essentials/src/com/earth2me/essentials/User.java Essentials/src/com/earth2me/essentials/Util.java Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java Essentials/src/com/earth2me/essentials/commands/Commandmail.java Essentials/src/com/earth2me/essentials/commands/Commandme.java Essentials/src/com/earth2me/essentials/commands/Commandmsg.java Essentials/src/com/earth2me/essentials/commands/Commandnick.java Essentials/src/com/earth2me/essentials/commands/Commandr.java Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java build.xml
Diffstat (limited to 'EssentialsProtect')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java61
1 files changed, 57 insertions, 4 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index 117c27a57..1d90384c1 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -59,7 +59,7 @@ public class EssentialsProtectBlockListener extends BlockListener
final Block below = blockPlaced.getRelative(BlockFace.DOWN);
if ((below.getType() == Material.RAILS || below.getType() == Material.POWERED_RAIL || below.getType() == Material.DETECTOR_RAIL)
&& settings.getData().getSignsAndRails().isPreventBlockAboveRails()
- && prot.getStorage().isProtected(below, user.getName()))
+ && isProtected(below, user, settings))
{
event.setCancelled(true);
return;
@@ -72,7 +72,7 @@ public class EssentialsProtectBlockListener extends BlockListener
{
protect.add(blockPlaced);
if (settings.getData().getSignsAndRails().isBlockBelow()
- && !prot.getStorage().isProtected(blockPlaced.getRelative(BlockFace.DOWN), user.getName()))
+ && !isProtected(blockPlaced.getRelative(BlockFace.DOWN), user, settings))
{
protect.add(blockPlaced.getRelative(BlockFace.DOWN));
}
@@ -85,7 +85,7 @@ public class EssentialsProtectBlockListener extends BlockListener
if (settings.getData().getSignsAndRails().isBlockBelow()
&& event.getBlockAgainst().getType() != Material.SIGN_POST
&& event.getBlockAgainst().getType() != Material.WALL_SIGN
- && !prot.getStorage().isProtected(event.getBlockAgainst(), user.getName()))
+ && !isProtected(event.getBlockAgainst(), user, settings))
{
protect.add(event.getBlockAgainst());
}
@@ -321,7 +321,7 @@ public class EssentialsProtectBlockListener extends BlockListener
else
{
- final boolean isProtected = storage.isProtected(block, user.getName());
+ final boolean isProtected = isProtected(block, user, settings);
if (isProtected)
{
event.setCancelled(true);
@@ -483,4 +483,57 @@ public class EssentialsProtectBlockListener extends BlockListener
settings.unlock();
}
}
+
+ private boolean isProtected(final Block block, final IUser user, final ProtectHolder settings)
+ {
+ final Material type = block.getType();
+ if (settings.getData().getSignsAndRails().isProtectSigns())
+ {
+ if (type == Material.WALL_SIGN || type == Material.SIGN_POST)
+ {
+ 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 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)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ }
+ }
+
+ }
+ if (settings.getData().getSignsAndRails().isProtectRails()) {
+ if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ if (settings.getData().getSignsAndRails().isBlockBelow())
+ {
+ final Block up = block.getRelative(BlockFace.UP);
+ if (up != null && (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL))
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ }
+ }
+ return false;
+ }
}