diff options
author | snowleo <schneeleo@gmail.com> | 2011-06-26 16:06:19 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-06-26 16:06:19 +0200 |
commit | fa5d6fbfaecd3892ef870d500a6c38e7ae40058a (patch) | |
tree | e45fbe349539d81ade5e2432a8ada50b26bc2a35 | |
parent | 88ded926f49deed78fb6d238661f3c900483b0a6 (diff) | |
download | Essentials-fa5d6fbfaecd3892ef870d500a6c38e7ae40058a.tar Essentials-fa5d6fbfaecd3892ef870d500a6c38e7ae40058a.tar.gz Essentials-fa5d6fbfaecd3892ef870d500a6c38e7ae40058a.tar.lz Essentials-fa5d6fbfaecd3892ef870d500a6c38e7ae40058a.tar.xz Essentials-fa5d6fbfaecd3892ef870d500a6c38e7ae40058a.zip |
Missing onBlockPlace event for Protection sign
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java | 39 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignProtection.java | 42 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 3 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 3 |
8 files changed, 88 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 543df7fc5..b7a47de14 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -10,6 +10,7 @@ import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockListener; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.SignChangeEvent; @@ -82,9 +83,36 @@ public class SignBlockListener extends BlockListener for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); - if (event.getLine(0).equalsIgnoreCase(sign.getTemplateName())) + if (event.getLine(0).equalsIgnoreCase(sign.getTemplateName()) + && !sign.onSignCreate(event, ess)) { - event.setCancelled(!sign.onSignCreate(event, ess)); + event.setCancelled(true); + return; + } + } + } + + @Override + public void onBlockPlace(final BlockPlaceEvent event) + { + if (event.isCancelled() || ess.getSettings().areSignsDisabled()) + { + return; + } + + final Block block = event.getBlock(); + if (block.getType() == Material.WALL_SIGN + || block.getType() == Material.SIGN_POST) + { + return; + } + for (Signs signs : Signs.values()) + { + final EssentialsSign sign = signs.getSign(); + if (sign.getBlocks().contains(block.getType()) + && !sign.onBlockPlace(block, event.getPlayer(), ess)) + { + event.setCancelled(true); return; } } @@ -98,7 +126,7 @@ public class SignBlockListener extends BlockListener return; } - Block block = event.getBlock(); + final Block block = event.getBlock(); if ((block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || EssentialsSign.checkIfBlockBreaksSigns(block))) @@ -109,9 +137,10 @@ public class SignBlockListener extends BlockListener for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); - if (sign.getBlocks().contains(block.getType())) + if (sign.getBlocks().contains(block.getType()) + && !sign.onBlockBurn(block, ess)) { - event.setCancelled(!sign.onBlockBurn(block, ess)); + event.setCancelled(true); return; } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 02a811c78..8e0f4461f 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -231,6 +231,48 @@ public class SignProtection extends EssentialsSign { return protectedBlocks; } + + @Override + protected boolean onBlockPlace(final Block block, final User player, final String username, final IEssentials ess) throws SignException + { + final SignProtectionState state = isBlockProtected(block, player, username); + + if (state == SignProtectionState.OWNER || state == SignProtectionState.NOSIGN) + { + return true; + } + + if ((state == SignProtectionState.ALLOWED || state == SignProtectionState.NOT_ALLOWED) + && player.isAuthorized("essentials.signs.protection.override")) + { + return true; + } + + + player.sendMessage(Util.format("noPlacePermission", block.getType().toString().toLowerCase())); + return false; + } + + @Override + protected boolean onBlockInteract(final Block block, final User player, final String username, final IEssentials ess) throws SignException + { + final SignProtectionState state = isBlockProtected(block, player, username); + + if (state == SignProtectionState.OWNER || state == SignProtectionState.NOSIGN || state == SignProtectionState.ALLOWED) + { + return true; + } + + if (state == SignProtectionState.NOT_ALLOWED + && player.isAuthorized("essentials.signs.protection.override")) + { + return true; + } + + + player.sendMessage(Util.format("noAccessPermission", block.getType().toString().toLowerCase())); + return false; + } @Override protected boolean onBlockBreak(final Block block, final User player, final String username, final IEssentials ess) throws SignException diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 2394df0a4..1467df312 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -74,8 +74,8 @@ foreverAlone = \u00a7cYou have nobody to whom you can reply. freedMemory = Freed {0} MB. gcchunks = chunks, gcentities = entities -gcmax = Maximum memory: {0} MB gcfree = Free memory: {0} MB +gcmax = Maximum memory: {0} MB gctotal = Allocated memory: {0} MB generatingPortal = \u00a77Generating an exit portal. geoIpUrlEmpty = GeoIP download url is empty. @@ -186,6 +186,7 @@ noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c p noMotd = \u00a7cThere is no message of the day." noNewMail = \u00a77You have no new mail. noPendingRequest = You do not have a pending request. +noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. noRules = \u00a7cThere are no rules specified yet. noWarpsDefined = No warps defined none = none diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 115200f73..8f696830c 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -76,8 +76,8 @@ foreverAlone = \u00a7cDu har ingen du kan svare. freedMemory = Befriede {0} MB. gcchunks = stykker, gcentities = enheder -gcmax = Maximum memory: {0} MB gcfree = Free memory: {0} MB +gcmax = Maximum memory: {0} MB gctotal = Allocated memory: {0} MB generatingPortal = \u00a77Genererer en udgangs portal. geoIpUrlEmpty = GeoIP download url er tom. @@ -188,6 +188,7 @@ noMailSendPerm = \u00a7cDu har ikke \u00a7fessentials.mail.send\u00a7c tilladels noMotd = \u00a7cDer er ikke nogen besked for dagen." noNewMail = \u00a77Du har ingen ny post. noPendingRequest = Du har ikke en ventende anmodning. +noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. noRules = \u00a7cDer er ingen regler fastsat endnu. noWarpsDefined = Ingen warps defineret none = ingen diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 88c6548bd..7b287c583 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -74,8 +74,8 @@ foreverAlone = \u00a7cDu hast niemanden, dem du antworten kannst. freedMemory = {0} MB frei gemacht. gcchunks = Chunks, gcentities = Einheiten -gcmax = Maximaler Speicher: {0} MB gcfree = Freier Speicher: {0} MB +gcmax = Maximaler Speicher: {0} MB gctotal = Reservierter Speicher: {0} MB generatingPortal = \u00a77Erstelle ein Ausgangsportal. geoIpUrlEmpty = GeoIP Download-URL ist leer. @@ -186,6 +186,7 @@ noMailSendPerm = \u00a7cDu hast die Rechte \u00a7fessentials.mail.send\u00a7c ni noMotd = \u00a7cEs existiert keine Willkommensnachricht." noNewMail = \u00a77Du hast keine Nachrichten. noPendingRequest = Du hast keine Teleportierungsanfragen. +noPlacePermission = \u00a7cDu hast keine Rechte, einen Block in der N\u00e4he des Schildes zu platzieren. noRules = \u00a7cEs wurden keine Regeln definiert. noWarpsDefined = Keine Warp-Punkte erstellt. none = keine diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 2394df0a4..1467df312 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -74,8 +74,8 @@ foreverAlone = \u00a7cYou have nobody to whom you can reply. freedMemory = Freed {0} MB. gcchunks = chunks, gcentities = entities -gcmax = Maximum memory: {0} MB gcfree = Free memory: {0} MB +gcmax = Maximum memory: {0} MB gctotal = Allocated memory: {0} MB generatingPortal = \u00a77Generating an exit portal. geoIpUrlEmpty = GeoIP download url is empty. @@ -186,6 +186,7 @@ noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c p noMotd = \u00a7cThere is no message of the day." noNewMail = \u00a77You have no new mail. noPendingRequest = You do not have a pending request. +noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. noRules = \u00a7cThere are no rules specified yet. noWarpsDefined = No warps defined none = none diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 3b1a861d9..c53559ed3 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -74,8 +74,8 @@ foreverAlone = \u00a7cVous n''avez personne \u00e0 qui r\u00e9pondre. freedMemory = A lib\u00e9r\u00e9 {0} Mo. gcchunks = chunks, gcentities = entit\u00e9s -gcmax = M\u00e9moire maximale: {0} Mo gcfree = Free memory: {0} Mo +gcmax = M\u00e9moire maximale: {0} Mo gctotal = Allocated memory: {0} Mo generatingPortal = \u00a77G\u00e9n\u00e9ration d''un portail de sortie. geoIpUrlEmpty = L''url de t\u00e9l\u00e9chargement de GeoIP est vide. @@ -186,6 +186,7 @@ noMailSendPerm = \u00a7cVous n''avez pas la permission \u00a7fessentials.mail.se noMotd = \u00a7cIl n''y a pas de message su jour. noNewMail = \u00a77Vous n''avez pas de courrier. noPendingRequest = Vous n''avez pas de requ\u00eate non lue. +noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. noRules = \u00a7cIl n''y a pas encore de r\u00e8gles d\u00e9finies. noWarpsDefined = Aucun warps d\u00e9finis. none = aucun diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index ab97ab46f..549c6a439 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -75,8 +75,8 @@ foreverAlone = \u00a7cJe hebt niemand waarnaar je kan reageren. freedMemory = {0} MB gelost. gcchunks = chunks, gcentities = entities -gcmax = Maximaal geheugen: {0} MB gcfree = Free memory: {0} MB +gcmax = Maximaal geheugen: {0} MB gctotal = Allocated memory: {0} MB generatingPortal = \u00a77Uitgangs portal aan het cre\u00ebren. geoIpUrlEmpty = GeoIP download url is leeg. @@ -187,6 +187,7 @@ noMailSendPerm = \u00a7cJe hebt de \u00a7fessentials.mail.send\u00a7c toestemmin noMotd = \u00a7cEr is geen bericht van de dag." noNewMail = \u00a77Je hebt geen nieuwe berichten. noPendingRequest = Je hebt geen aanvragen. +noPlacePermission = \u00a7cYou do not have permission to place a block near that sign. noRules = \u00a7cEr zijn nog geen regels gegeven. noWarpsDefined = Geen warps gedefinieerd none = geen |