Merge branch 'master' of github.com:PEXPlugins/Modifyworld

This commit is contained in:
t3hk0d3 2012-06-07 12:10:28 +04:00
commit 7892227261
2 changed files with 25 additions and 2 deletions

View File

@ -94,6 +94,9 @@ public class Modifyworld extends JavaPlugin {
config.set("itemRestrictions", pexConfig.getBoolean("permissions.modifyworld.itemRestrictions", false));
config.set("informPlayers", pexConfig.getBoolean("permissions.informplayers.modifyworld", false));
config.set("whitelist", pexConfig.getBoolean("permissions.modifyworld.whitelist", false));
config.set("use-material-names", pexConfig.getBoolean("permissions.modifyworld.use-material-names", true));
config.set("drop-restricted-item", pexConfig.getBoolean("permissions.modifyworld.drop-restricted-item", false));
config.set("item-use-check", pexConfig.getBoolean("permissions.modifyworld.item-use-check", false));
// Messages
config.set("messages.whitelistMessage", pexConfig.getString("permissions.modifyworld.whitelistMessage", PlayerListener.WHITELIST_MESSAGE));

View File

@ -21,8 +21,10 @@ package ru.tehkode.modifyworld.handlers;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@ -210,13 +212,31 @@ public class PlayerListener extends ModifyworldListener {
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) { // item restriction check
this.checkPlayerInventory(event.getPlayer());
}
Player player = event.getPlayer();
if (action == Action.RIGHT_CLICK_AIR) { //RIGHT_CLICK_AIR is cancelled by default.
switch (player.getItemInHand().getType()) {
case POTION: //Only check splash potions.
if ((player.getItemInHand().getDurability() & 0x4000) != 0x4000) break;
case EGG:
case SNOW_BALL:
case EXP_BOTTLE:
if (!canInteractWithItem(player, "modifyworld.items.throw.", player.getItemInHand())) {
informPlayerAboutDenial(player);
event.setUseItemInHand(Result.DENY);
//Denying a potion works fine, but the client needs to be updated because it already reduced the item.
if (player.getItemInHand().getType() == Material.POTION)
event.getPlayer().updateInventory();
}
return;
}
}
if (action != Action.LEFT_CLICK_BLOCK && action != Action.RIGHT_CLICK_BLOCK && action != Action.PHYSICAL) {
return;
}
Player player = event.getPlayer();
if (this.checkItemUse && action != Action.PHYSICAL) {
if (!player.hasPermission("modifyworld.items.use." + getItemPermission(player.getItemInHand()) + ".on.block." + getBlockPermission(event.getClickedBlock()))) {
event.setCancelled(true);