summaryrefslogtreecommitdiffstats
path: root/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
diff options
context:
space:
mode:
authorementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-06-02 23:09:59 +0000
committerementalo <ementalo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-06-02 23:09:59 +0000
commitf6cedda1e227f4e8e5a18bfc864ef515f286850e (patch)
tree5f3e873e899cb893ca9e8f7b524538e138fc1f77 /EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
parent3dab3d8df8ab31ce5330bb447983bcc498c2f9c6 (diff)
downloadEssentials-f6cedda1e227f4e8e5a18bfc864ef515f286850e.tar
Essentials-f6cedda1e227f4e8e5a18bfc864ef515f286850e.tar.gz
Essentials-f6cedda1e227f4e8e5a18bfc864ef515f286850e.tar.lz
Essentials-f6cedda1e227f4e8e5a18bfc864ef515f286850e.tar.xz
Essentials-f6cedda1e227f4e8e5a18bfc864ef515f286850e.zip
[trunk] Protect refactors (formally known as 3.0) needs ***EXTENSIVE*** testing
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1574 e251c2fe-e539-e718-e476-b85c1f46cddb
Diffstat (limited to 'EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java')
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java45
1 files changed, 21 insertions, 24 deletions
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
index 9e1d35732..4c9b2c5fd 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java
@@ -1,46 +1,33 @@
package com.earth2me.essentials.protect;
-import com.earth2me.essentials.Essentials;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
import org.bukkit.block.Block;
-import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.inventory.ItemStack;
-
+import com.earth2me.essentials.Essentials;
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.Util;
public class EssentialsProtectPlayerListener extends PlayerListener
{
private EssentialsProtect parent;
- private EssentialsProtectData spData = null;
public EssentialsProtectPlayerListener(EssentialsProtect parent)
{
+
this.parent = parent;
}
- public void initialize()
- {
- if (spData != null) return;
- spData = new EssentialsProtectData();
- }
-
@Override
public void onPlayerInteract(PlayerInteractEvent event)
{
- initialize();
if (event.isCancelled()) return;
ItemStack item = event.getItem();
- User user = Essentials.getStatic().getUser(event.getPlayer());
+ User user = parent.ess.getUser(event.getPlayer());
Block blockClicked = event.getClickedBlock();
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
{
- if(Essentials.getStatic().getSettings().warnOnBuildDisallow())
- {
- user.sendMessage(Util.i18n("buildAlert"));
- }
event.setCancelled(true);
return;
}
@@ -52,16 +39,26 @@ public class EssentialsProtectPlayerListener extends PlayerListener
return;
}
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK && user.isAuthorized("essentials.protect.ownerinfo"))
+ if (user.isAuthorized("essentials.protect.admin"))
{
- String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(),
- blockClicked);
- if (ownerName != null)
+ StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for (String owner : EssentialsProtect.getStorage().getOwners(blockClicked))
+ {
+ if (!first)
+ {
+ sb.append(", ");
+ }
+ first = false;
+ sb.append(owner);
+ }
+ String ownerNames = sb.toString();
+ if (ownerNames != null && !ownerNames.isEmpty())
{
- user.sendMessage(Util.format("protectionOwner", ownerName));
+ user.sendMessage(Util.format("protectionOwner", ownerNames));
}
}
- if (item != null && EssentialsProtect.checkProtectionItems(EssentialsProtect.onUseAlert, item.getTypeId()))
+ if (item != null && EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId())))
{
parent.alert(user, item.getType().toString(), Util.i18n("alertUsed"));
}