summaryrefslogtreecommitdiffstats
path: root/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-12-31 02:28:52 +0000
committerKHobbits <rob@khobbits.co.uk>2012-12-31 02:28:52 +0000
commit86619275992b4b29bfac91897986b10f2ef863cb (patch)
treec46ac4dd7fb3a7d7dde90d508e3b123efd09def7 /EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java
parenta6b83ca260386fbafb24473aca5f95dc2d5c284b (diff)
downloadEssentials-86619275992b4b29bfac91897986b10f2ef863cb.tar
Essentials-86619275992b4b29bfac91897986b10f2ef863cb.tar.gz
Essentials-86619275992b4b29bfac91897986b10f2ef863cb.tar.lz
Essentials-86619275992b4b29bfac91897986b10f2ef863cb.tar.xz
Essentials-86619275992b4b29bfac91897986b10f2ef863cb.zip
Merge gravy's pull and reformat code
Diffstat (limited to 'EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java')
-rw-r--r--EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java123
1 files changed, 57 insertions, 66 deletions
diff --git a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java
index 2e0aba9a4..4334d6697 100644
--- a/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java
+++ b/EssentialsAntiBuild/src/net/ess3/antibuild/EssentialsAntiBuildListener.java
@@ -1,8 +1,6 @@
package net.ess3.antibuild;
import static net.ess3.I18n._;
-import net.ess3.api.IEssentials;
-import net.ess3.api.IUser;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
@@ -11,13 +9,18 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
-import org.bukkit.event.block.*;
+import org.bukkit.event.block.BlockBreakEvent;
+import org.bukkit.event.block.BlockPistonExtendEvent;
+import org.bukkit.event.block.BlockPistonRetractEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
+import net.ess3.api.IEssentials;
+import net.ess3.api.IUser;
public class EssentialsAntiBuildListener implements Listener
@@ -33,39 +36,36 @@ public class EssentialsAntiBuildListener implements Listener
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(final BlockPlaceEvent event)
- {
+ {
final Player user = event.getPlayer();
final Block block = event.getBlockPlaced();
final int typeId = block.getTypeId();
final Material type = block.getType();
- if (antib.getSettings().getData().isDisableBuild()
- && !Permissions.BUILD.isAuthorized(user)
- && !Permissions.PLACEMENT.isAuthorized(user, block))
+ if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.PLACEMENT.isAuthorized(user, block))
+ {
+ if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
- if (antib.getSettings().getData().isWarnOnBuildDisallow())
- {
- user.sendMessage(_("antiBuildPlace", type.toString()));
- }
- event.setCancelled(true);
- return;
+ user.sendMessage(_("antiBuildPlace", type.toString()));
}
+ event.setCancelled(true);
+ return;
+ }
- if (antib.getSettings().getData().getBlacklist().getPlacement(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user))
+ if (antib.getSettings().getData().getBlacklist().getPlacement(type) && !Permissions.BLACKLIST_ALLOWPLACEMENT.isAuthorized(user))
+ {
+ if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
- if (antib.getSettings().getData().isWarnOnBuildDisallow())
- {
- user.sendMessage(_("antiBuildPlace", type.toString()));
- }
- event.setCancelled(true);
- return;
+ user.sendMessage(_("antiBuildPlace", type.toString()));
}
+ event.setCancelled(true);
+ return;
+ }
- if (antib.getSettings().getData().getAlert().getAlertOnPlacementContains(type)
- && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
- {
- antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced"));
- }
+ if (antib.getSettings().getData().getAlert().getAlertOnPlacementContains(type) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
+ {
+ antib.getEssentialsConnect().alert(user, type.toString(), _("alertPlaced"));
+ }
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -75,36 +75,33 @@ public class EssentialsAntiBuildListener implements Listener
final Block block = event.getBlock();
final int typeId = block.getTypeId();
final Material type = block.getType();
-
- if (antib.getSettings().getData().isDisableBuild()
- && !Permissions.BUILD.isAuthorized(user)
- && !Permissions.BREAK.isAuthorized(user, block))
- {
- if (antib.getSettings().getData().isWarnOnBuildDisallow())
- {
- user.sendMessage(_("antiBuildBreak", type.toString()));
- }
- event.setCancelled(true);
- return;
- }
- if (antib.getSettings().getData().getBlacklist().getBreaking(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user))
+ if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.BREAK.isAuthorized(user, block))
+ {
+ if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
- if (antib.getSettings().getData().isWarnOnBuildDisallow())
- {
- user.sendMessage(_("antiBuildBreak", type.toString()));
- }
- event.setCancelled(true);
- return;
+ user.sendMessage(_("antiBuildBreak", type.toString()));
}
+ event.setCancelled(true);
+ return;
+ }
- if (antib.getSettings().getData().getAlert().getAlertOnBreakContains(type)
- && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
+ if (antib.getSettings().getData().getBlacklist().getBreaking(type) && !Permissions.BLACKLIST_ALLOWBREAK.isAuthorized(user))
+ {
+ if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
- antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke"));
+ user.sendMessage(_("antiBuildBreak", type.toString()));
}
+ event.setCancelled(true);
+ return;
+ }
+
+ if (antib.getSettings().getData().getAlert().getAlertOnBreakContains(type) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
+ {
+ antib.getEssentialsConnect().alert(user, type.toString(), _("alertBroke"));
+ }
}
-
+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPaintingBreak(final PaintingBreakByEntityEvent event)
{
@@ -112,9 +109,8 @@ public class EssentialsAntiBuildListener implements Listener
if (entity instanceof Player)
{
final IUser user = ess.getUserMap().getUser((Player)entity);
- if (antib.getSettings().getData().isDisableBuild()
- && !Permissions.BUILD.isAuthorized(user)
- && !Permissions.BREAK.isAuthorized(user, Material.PAINTING, null))
+ if (antib.getSettings().getData().isDisableBuild() && !Permissions.BUILD.isAuthorized(user) && !Permissions.BREAK.isAuthorized(
+ user, Material.PAINTING, null))
{
if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
@@ -159,9 +155,7 @@ public class EssentialsAntiBuildListener implements Listener
final Player user = event.getPlayer();
final ItemStack item = event.getItem();
- if (item != null
- && antib.getSettings().getData().getBlacklist().getUsage(item.getType())
- && !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user))
+ if (item != null && antib.getSettings().getData().getBlacklist().getUsage(item.getType()) && !Permissions.BLACKLIST_ALLOWUSAGE.isAuthorized(user))
{
if (antib.getSettings().getData().isWarnOnBuildDisallow())
{
@@ -171,15 +165,12 @@ public class EssentialsAntiBuildListener implements Listener
return;
}
- if (item != null
- && antib.getSettings().getData().getAlert().getAlertOnUseContains(item.getType())
- && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
+ if (item != null && antib.getSettings().getData().getAlert().getAlertOnUseContains(item.getType()) && !Permissions.ALERTS_NOTRIGGER.isAuthorized(user))
{
antib.getEssentialsConnect().alert(user, item.getType().toString(), _("alertUsed"));
}
- if (antib.getSettings().getData().isDisableUse()
- && !Permissions.BUILD.isAuthorized(user))
+ if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
{
if (event.hasItem() && !Permissions.INTERACT.isAuthorized(user, item.getType(), item.getData()))
{
@@ -211,8 +202,7 @@ public class EssentialsAntiBuildListener implements Listener
final Player user = (Player)entity;
final ItemStack item = event.getRecipe().getResult();
- if (antib.getSettings().getData().isDisableUse()
- && !Permissions.BUILD.isAuthorized(user))
+ if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
{
if (!Permissions.CRAFT.isAuthorized(user, item.getType(), item.getData()))
{
@@ -233,8 +223,7 @@ public class EssentialsAntiBuildListener implements Listener
final Player user = event.getPlayer();
final ItemStack item = event.getItem().getItemStack();
- if (antib.getSettings().getData().isDisableUse()
- && !Permissions.BUILD.isAuthorized(user))
+ if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
{
if (!Permissions.PICKUP.isAuthorized(user, item.getType(), item.getData()))
{
@@ -251,8 +240,10 @@ public class EssentialsAntiBuildListener implements Listener
final Player user = event.getPlayer();
final ItemStack item = event.getItemDrop().getItemStack();
- if (antib.getSettings().getData().isDisableUse()
- && !Permissions.BUILD.isAuthorized(user));
+ if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user))
+ {
+ ;
+ }
{
if (!Permissions.DROP.isAuthorized(user, item.getType(), item.getData()))
{
@@ -264,5 +255,5 @@ public class EssentialsAntiBuildListener implements Listener
}
}
}
- }
+ }
}