mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-05 23:08:23 +00:00
gah
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1036 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
c2f7853ec9
commit
243ff48778
3 changed files with 31 additions and 45 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -37,23 +37,6 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||
spData = new EssentialsProtectData();
|
||||
}
|
||||
|
||||
@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)
|
||||
{
|
||||
|
@ -179,22 +162,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)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue