Added monster egg permissions (modifyworld.spawn.<entity>, example: modifyworld.spawn.villager)

This commit is contained in:
t3hk0d3 2012-10-31 23:17:12 +04:00
parent 081dc8786f
commit eb36ff3422
2 changed files with 9 additions and 2 deletions

View File

@ -159,6 +159,8 @@ public abstract class ModifyworldListener implements Listener {
protected String getObjectPermission(Object obj) {
if (obj instanceof Entity) {
return (getEntityName((Entity) obj));
} else if (obj instanceof EntityType) {
return formatEnumString(((EntityType)obj).name());
} else if (obj instanceof BlockState) {
return (getBlockPermission(((BlockState)obj).getBlock()));
} else if (obj instanceof ItemStack) {

View File

@ -37,6 +37,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.SpawnEgg;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
import ru.tehkode.modifyworld.ModifyworldListener;
@ -265,9 +266,13 @@ public class PlayerListener extends ModifyworldListener {
event.getPlayer().updateInventory();
}
}
if (action == Action.RIGHT_CLICK_AIR) {
return;
return; // no need to check further
case MONSTER_EGG:
case MONSTER_EGGS:
if (permissionDenied(player, "modifyworld.spawn", ((SpawnEgg)player.getItemInHand().getData()).getSpawnedType())) {
event.setUseItemInHand(Result.DENY);
}
return; // no need to check further
}
}