Allow using permission nocheat.itemdupe to bypass the new check.

This commit is contained in:
Evenprime 2011-04-25 17:51:46 +02:00
parent 385c807c10
commit cce01cca1a
4 changed files with 14 additions and 3 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 0.8.7
version: 0.8.8
commands:
nocheat:

View File

@ -307,6 +307,7 @@ public class NoCheat extends JavaPlugin {
data.permissionsCache[NoCheatData.PERMISSION_P] = permissions.has(player, "nocheat.p");
data.permissionsCache[NoCheatData.PERMISSION_SPEEDHACK] = permissions.has(player, "nocheat.speedhack");
data.permissionsCache[NoCheatData.PERMISSION_NOTIFY] = permissions.has(player, "nocheat.notify");
data.permissionsCache[NoCheatData.PERMISSION_ITEMDUPE] = permissions.has(player, "nocheat.itemdupe");
}
@ -337,7 +338,7 @@ public class NoCheat extends JavaPlugin {
(!speedhackCheck.isActive() ? speedhackCheck.getName() + "* " : (hasPermission(p, NoCheatData.PERMISSION_SPEEDHACK) ? speedhackCheck.getName() + " " : "")) +
(!airbuildCheck.isActive() ? airbuildCheck.getName() + "* " : (hasPermission(p, NoCheatData.PERMISSION_AIRBUILD) ? airbuildCheck.getName() + " " : "")) +
(!bedteleportCheck.isActive() ? bedteleportCheck.getName() + "* " : (hasPermission(p, NoCheatData.PERMISSION_BEDTELEPORT) ? bedteleportCheck.getName() + " " : "")) +
(!itemdupeCheck.isActive() ? itemdupeCheck.getName() + "* " : " ") +
(!itemdupeCheck.isActive() ? itemdupeCheck.getName() + "* " : (hasPermission(p, NoCheatData.PERMISSION_ITEMDUPE) ? itemdupeCheck.getName() + " " : "")) +
(hasPermission(p, NoCheatData.PERMISSION_NOTIFY) ? "notify " : ""));
}

View File

@ -48,7 +48,7 @@ public class NoCheatData {
public double maxYVelocity = 0.0D;
public long permissionsLastUpdate = 0;
public boolean permissionsCache[] = new boolean[7];
public boolean permissionsCache[] = new boolean[8];
public static final int PERMISSION_MOVING = 0;
@ -58,6 +58,7 @@ public class NoCheatData {
public static final int PERMISSION_BEDTELEPORT = 4;
public static final int PERMISSION_P = 5;
public static final int PERMISSION_NOTIFY = 6;
public static final int PERMISSION_ITEMDUPE = 7;
// Store data between Events
private static final Map<Player, NoCheatData> playerData = new HashMap<Player, NoCheatData>();

View File

@ -8,6 +8,7 @@ import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
public class ItemdupeCheck extends Check {
@ -18,6 +19,10 @@ public class ItemdupeCheck extends Check {
public void check(PlayerPickupItemEvent event) {
// Should we check at all?
if(plugin.hasPermission(event.getPlayer(), NoCheatData.PERMISSION_ITEMDUPE))
return;
Item i = event.getItem();
if(i != null) {
ItemStack s = i.getItemStack();
@ -32,6 +37,10 @@ public class ItemdupeCheck extends Check {
}
public void check(PlayerInteractEvent event) {
if(plugin.hasPermission(event.getPlayer(), NoCheatData.PERMISSION_ITEMDUPE))
return;
if(event.hasItem() && event.getItem().getAmount() <= 0) {// buggy item
event.setCancelled(true);
plugin.log(Level.WARNING, event.getPlayer().getName() + " tried to use an invalid item. Item will be removed now.");