summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect
diff options
context:
space:
mode:
authorementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 14:28:46 +0000
committerementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 14:28:46 +0000
commit243ff48778cdee3fc0ee3b096ab9c441a50abc84 (patch)
tree66087969d3e5cf606b70a7aca3fe02b0215c22cc /EssentialsProtect
parentc2f7853ec910d672cb1484dc8215404a6091c47d (diff)
downloadEssentials-243ff48778cdee3fc0ee3b096ab9c441a50abc84.tar
Essentials-243ff48778cdee3fc0ee3b096ab9c441a50abc84.tar.gz
Essentials-243ff48778cdee3fc0ee3b096ab9c441a50abc84.tar.lz
Essentials-243ff48778cdee3fc0ee3b096ab9c441a50abc84.tar.xz
Essentials-243ff48778cdee3fc0ee3b096ab9c441a50abc84.zip
gah
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1036 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsProtect')
-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, 31 insertions, 45 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
index a2c577789..798153b1c 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtect.java
@@ -48,17 +48,15 @@ public class EssentialsProtect extends JavaPlugin
playerListener = new EssentialsProtectPlayerListener(this);
blockListener = new EssentialsProtectBlockListener(this);
entityListener = new EssentialsProtectEntityListener(this);
- pm.registerEvent(Type.PLAYER_ITEM, playerListener, Priority.Low, this);
+ pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
// Why is this commented?
//pm.registerEvent(Type.BLOCK_DAMAGED, blockListener, Priority.High, 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_PLACE, blockListener, Priority.Highest, this);
+ pm.registerEvent(Type.BLOCK_FROMTO, 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_DAMAGED, entityListener, Priority.Highest, this);
+ pm.registerEvent(Type.ENTITY_DAMAGE, 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 43b508a58..e96165ecd 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -38,23 +38,6 @@ 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;
@@ -180,22 +163,6 @@ 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 61419f69a..c75bb6324 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -2,7 +2,9 @@ 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;
@@ -29,18 +31,36 @@ public class EssentialsProtectPlayerListener extends PlayerListener
}
@Override
- public void onPlayerItem(PlayerItemEvent event)
+ public void onPlayerInteract(PlayerInteractEvent event)
{
- if(event.isCancelled()) return;
+ initialize();
+ if (event.isCancelled()) return;
ItemStack item = event.getItem();
User user = User.get(event.getPlayer());
- Block blockPlaced = event.getBlockClicked();
+ Block blockClicked = event.getClickedBlock();
+
+ if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
+ {
+ event.setCancelled(true);
+ return;
+ }
+
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: ");
@@ -53,9 +73,9 @@ public class EssentialsProtectPlayerListener extends PlayerListener
if (user.isAuthorized("essentials.protect"))
{
- signBlockX = blockPlaced.getX();
- signBlockY = blockPlaced.getY();
- signBlockZ = blockPlaced.getZ();
+ signBlockX = blockClicked.getX();
+ signBlockY = blockClicked.getY();
+ signBlockZ = blockClicked.getZ();
initialize();
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX,
@@ -69,5 +89,6 @@ public class EssentialsProtectPlayerListener extends PlayerListener
}
}
}
+
}
}