Prevent dupe exploit in combination with .drop protection

This commit is contained in:
Evenprime 2011-09-07 17:37:47 +02:00
parent 5b56fc7302
commit fbd078209c
4 changed files with 52 additions and 8 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 2.01b
version: 2.02
permissions:

View File

@ -9,6 +9,7 @@ import cc.co.evenprime.bukkit.nocheat.data.DataManager;
import cc.co.evenprime.bukkit.nocheat.events.BlockPlaceEventManager;
import cc.co.evenprime.bukkit.nocheat.events.BlockBreakEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerItemDropEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerInteractEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerMoveEventManager;
import cc.co.evenprime.bukkit.nocheat.events.PlayerTeleportEventManager;
@ -35,12 +36,13 @@ public class NoCheat extends JavaPlugin {
private BlockBreakEventManager eventBlockBreakManager;
private BlockPlaceEventManager eventBlockPlaceManager;
private PlayerInteractEventManager eventPlayerInteractManager;
private PlayerItemDropEventManager eventPlayerItemDropManager;
private int taskId = -1;
private int ingameseconds = 0;
private long lastIngamesecondTime = 0L;
private long lastIngamesecondDuration = 0L;
private boolean skipCheck = false;
private boolean skipCheck = false;
private ActionManager action;
@ -77,6 +79,7 @@ public class NoCheat extends JavaPlugin {
eventPlayerTeleportManager = new PlayerTeleportEventManager(this);
eventBlockBreakManager = new BlockBreakEventManager(this);
eventBlockPlaceManager = new BlockPlaceEventManager(this);
eventPlayerItemDropManager = new PlayerItemDropEventManager(this);
eventPlayerInteractManager = new PlayerInteractEventManager(this);
PluginDescriptionFile pdfFile = this.getDescription();
@ -86,13 +89,15 @@ public class NoCheat extends JavaPlugin {
@Override
public void run() {
// If the previous second took to long, skip checks during this second
// If the previous second took to long, skip checks during
// this second
skipCheck = lastIngamesecondDuration > 1500;
long time = System.currentTimeMillis();
lastIngamesecondDuration = time - lastIngamesecondTime;
if(lastIngamesecondDuration < 1000) lastIngamesecondDuration = 1000;
if(lastIngamesecondDuration < 1000)
lastIngamesecondDuration = 1000;
lastIngamesecondTime = time;
ingameseconds++;
}
@ -125,7 +130,7 @@ public class NoCheat extends JavaPlugin {
public long getIngameSecondDuration() {
return lastIngamesecondDuration;
}
public boolean skipCheck() {
return skipCheck;
}

View File

@ -0,0 +1,39 @@
package cc.co.evenprime.bukkit.nocheat.events;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.PluginManager;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.config.ConfigurationManager;
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
/**
*
* Temporary, until Bukkit implements a real fix for the problem.
*
* @author Evenprime
*
*/
public class PlayerItemDropEventManager extends PlayerListener {
public PlayerItemDropEventManager(NoCheat plugin) {
PluginManager pm = Bukkit.getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_DROP_ITEM, this, Priority.Lowest, plugin);
}
@Override
public void onPlayerDropItem(PlayerDropItemEvent event) {
if(!event.getPlayer().isOnline()) {
event.setCancelled(true);
}
}
}

View File

@ -19,7 +19,7 @@ public class FlatConfigGenerator {
ParentOption o = (ParentOption) tree.getOption("");
String s = "";
String s = "# Want to know what these options do? Read the descriptions.txt file.\r\n\r\n";
for(Option option : o.getChildOptions()) {
s += optionToFlatString(option);