diff options
author | ementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-30 14:22:14 +0000 |
---|---|---|
committer | ementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb> | 2011-03-30 14:22:14 +0000 |
commit | c2f7853ec910d672cb1484dc8215404a6091c47d (patch) | |
tree | 040afef0371857807d3c7cddaab7ccbda1731aae /EssentialsProtect/src/com/earth2me | |
parent | d4973ae64412cd8b022ef48c3261bec0b4566815 (diff) | |
download | Essentials-c2f7853ec910d672cb1484dc8215404a6091c47d.tar Essentials-c2f7853ec910d672cb1484dc8215404a6091c47d.tar.gz Essentials-c2f7853ec910d672cb1484dc8215404a6091c47d.tar.lz Essentials-c2f7853ec910d672cb1484dc8215404a6091c47d.tar.xz Essentials-c2f7853ec910d672cb1484dc8215404a6091c47d.zip |
2.1 v
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1035 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsProtect/src/com/earth2me')
3 files changed, 45 insertions, 31 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java index 798153b1c..a2c577789 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java @@ -48,15 +48,17 @@ public class EssentialsProtect extends JavaPlugin playerListener = new EssentialsProtectPlayerListener(this); blockListener = new EssentialsProtectBlockListener(this); entityListener = new EssentialsProtectEntityListener(this); - pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this); + pm.registerEvent(Type.PLAYER_ITEM, playerListener, Priority.Low, this); // Why is this commented? //pm.registerEvent(Type.BLOCK_DAMAGED, blockListener, Priority.High, this); - pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Highest, this); - pm.registerEvent(Type.BLOCK_FROMTO, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_RIGHTCLICKED, blockListener, Priority.Low, this); + pm.registerEvent(Type.BLOCK_PLACED, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_INTERACT, blockListener, Priority.Highest, this); + pm.registerEvent(Type.BLOCK_FLOW, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_IGNITE, blockListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BURN, blockListener, Priority.Highest, this); pm.registerEvent(Type.ENTITY_EXPLODE, entityListener, Priority.Highest, this); - pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Highest, this); + pm.registerEvent(Type.ENTITY_DAMAGED, entityListener, Priority.Highest, this); pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this); pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this); diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java index e96165ecd..43b508a58 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java @@ -38,6 +38,23 @@ public class EssentialsProtectBlockListener extends BlockListener } @Override + public void onBlockRightClick(BlockRightClickEvent event) + { + initialize(); + User user = User.get(event.getPlayer()); + if (user.isAuthorized("essentials.protect.admin")) + { + String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(), + event.getBlock()); + if (ownerName != null) + { + user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owner: " + + ownerName); + } + } + } + + @Override public void onBlockPlace(BlockPlaceEvent event) { if (event.isCancelled()) return; @@ -163,6 +180,22 @@ public class EssentialsProtectBlockListener extends BlockListener } @Override + public void onBlockInteract(BlockInteractEvent event) + { + if (event.isCancelled()) return; + if (!event.isPlayer()) return; + + User user = User.get((Player)event.getEntity()); + + if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) + { + event.setCancelled(true); + return; + } + + } + + @Override public void onBlockBurn(BlockBurnEvent event) { Block block = event.getBlock(); diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java index c75bb6324..61419f69a 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java @@ -2,9 +2,7 @@ package com.earth2me.essentials.protect; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; -import org.bukkit.ChatColor; import org.bukkit.block.Block; -import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.inventory.ItemStack; @@ -31,36 +29,18 @@ public class EssentialsProtectPlayerListener extends PlayerListener } @Override - public void onPlayerInteract(PlayerInteractEvent event) + public void onPlayerItem(PlayerItemEvent event) { - initialize(); - if (event.isCancelled()) return; + if(event.isCancelled()) return; ItemStack item = event.getItem(); User user = User.get(event.getPlayer()); - Block blockClicked = event.getClickedBlock(); - - if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild()) - { - event.setCancelled(true); - return; - } - + Block blockPlaced = event.getBlockClicked(); if (EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage")) { event.setCancelled(true); return; } - if (user.isAuthorized("essentials.protect.admin")) - { - String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(), - blockClicked); - if (ownerName != null) - { - user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owner: " - + ownerName); - } - } if (EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId()))) { parent.alert(user, item.getType().toString(), "used: "); @@ -73,9 +53,9 @@ public class EssentialsProtectPlayerListener extends PlayerListener if (user.isAuthorized("essentials.protect")) { - signBlockX = blockClicked.getX(); - signBlockY = blockClicked.getY(); - signBlockZ = blockClicked.getZ(); + signBlockX = blockPlaced.getX(); + signBlockY = blockPlaced.getY(); + signBlockZ = blockPlaced.getZ(); initialize(); spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX, @@ -89,6 +69,5 @@ public class EssentialsProtectPlayerListener extends PlayerListener } } } - } } |