Emergency fix for a bug in vanilla minecraft and bukkit that prevents

people from really dying.
This commit is contained in:
Evenprime 2011-11-28 15:47:27 +01:00
parent 7173b8661c
commit 1dd6ccb786
7 changed files with 26 additions and 12 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cc.co.evenprime.bukkit</groupId>
<artifactId>NoCheat</artifactId>
<version>2.18</version>
<version>2.19</version>
<packaging>jar</packaging>
<name>NoCheat</name>
<properties>

View File

@ -13,8 +13,8 @@ import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
@ -134,30 +134,32 @@ public class NoCheat extends JavaPlugin {
// Then print a list of active checks per world
ActiveCheckPrinter.printActiveChecks(this, eventManagers);
if(mcVersion == MCVersion.MC100) {
if(mcVersion == MCVersion.MC100 && this.conf.getConfigurationCacheForWorld(null).emergencyfix) {
// Tell the server admin that we are activating a workaround
log.logToConsole(LogLevel.LOW, "[NoCheat] Activating temporary bugfix for broken player death handling of minecraft.");
// Activate workaround, reset death ticks when a player dies
log.logToConsole(LogLevel.LOW, "[NoCheat] Activating emergency bugfix for broken player death handling of minecraft.");
// reset death ticks on deaths, such that they can go over 20 again
getServer().getPluginManager().registerEvent(Type.ENTITY_DEATH, new EntityListener() {
@Override
public void onEntityDeath(EntityDeathEvent event) {
if(event.getEntity() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) event.getEntity();
player.getHandle().deathTicks = 0;
player.getHandle().deathTicks = 19;
}
}
}, Priority.Monitor, this);
// Activate workaround, reset death ticks when a player spawns
getServer().getPluginManager().registerEvent(Type.PLAYER_RESPAWN, new PlayerListener() {
// reset death ticks on joins, such that they can go over 20 again
getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, new PlayerListener() {
@Override
public void onPlayerRespawn(PlayerRespawnEvent event) {
public void onPlayerJoin(PlayerJoinEvent event) {
if(event.getPlayer() instanceof CraftPlayer) {
CraftPlayer player = (CraftPlayer) event.getPlayer();
player.getHandle().deathTicks = 0;
if(player.getHealth() <= 0) {
player.getHandle().deathTicks = 19;
}
}
}
}, Priority.Monitor, this);

View File

@ -32,6 +32,9 @@ public abstract class Configuration {
public final static OptionNode DEBUG_SHOWACTIVECHECKS = new OptionNode("showactivechecks", DEBUG, DataType.BOOLEAN);
public static final OptionNode DEBUG_COMPATIBILITY = new OptionNode("compatibility", DEBUG, DataType.BOOLEAN);
private final static OptionNode EMERGENCYFIX = new OptionNode("emergencyfix", ROOT, DataType.PARENT);
public final static OptionNode EMERGENCYFIX_ENFORCEPLAYERDEATH = new OptionNode("enforceplayerdeath", EMERGENCYFIX, DataType.BOOLEAN);
private final static OptionNode MOVING = new OptionNode("moving", ROOT, DataType.PARENT);
public final static OptionNode MOVING_CHECK = new OptionNode("check", MOVING, DataType.BOOLEAN);
public final static OptionNode MOVING_IDENTIFYCREATIVEMODE = new OptionNode("identifycreativemode", MOVING, DataType.BOOLEAN);

View File

@ -34,6 +34,11 @@ public class DefaultConfiguration extends Configuration {
setValue(DEBUG_SHOWACTIVECHECKS, false);
setValue(DEBUG_COMPATIBILITY, true);
}
/*** EMERGENCY_FIX ***/
{
setValue(EMERGENCYFIX_ENFORCEPLAYERDEATH, true);
}
/*** MOVING ***/
{

View File

@ -26,6 +26,8 @@ public class Explainations {
set(Configuration.DEBUG_SHOWACTIVECHECKS, "Print to the console an overview of all checks that are enabled when NoCheat gets loaded.");
set(Configuration.DEBUG_COMPATIBILITY, "Do some voodoo to fix common mistakes of other plugins which interfere with NoCheat.");
set(Configuration.EMERGENCYFIX_ENFORCEPLAYERDEATH, "Fix a bug that prevents people from really dying, causing them to not drop XP,\n and still being able to fight, place/destroy blocks etc. in an invulnerable state.");
set(Configuration.MOVING_CHECK, "If true, do various checks on PlayerMove events.");
set(Configuration.MOVING_IDENTIFYCREATIVEMODE, "If true, NoCheat will automatically identify if players are in creative mode and will allow them to fly, avoid fall damage etc.");

View File

@ -18,6 +18,7 @@ public class ConfigurationCache {
public final CCChat chat;
public final CCDebug debug;
public final CCFight fight;
public final boolean emergencyfix;
/**
* Instantiate a config cache and populate it with the data of a
@ -35,5 +36,6 @@ public class ConfigurationCache {
debug = new CCDebug(data);
fight = new CCFight(data);
emergencyfix = data.getBoolean(Configuration.EMERGENCYFIX_ENFORCEPLAYERDEATH);
}
}

View File

@ -106,7 +106,7 @@ public class MovingEventManager extends EventManagerImpl {
// Get the world-specific configuration that applies here
final NoCheatPlayer player = plugin.getPlayer(event.getPlayer());
// Not interested at all in players in vehicles or dead
if(event.getPlayer().isInsideVehicle() || player.isDead()) {
return;