summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java10
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java33
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java33
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
}
}
}
-
}
}