Removed "godmode" check, as it is FUBAR in MC 1.0.0, may return later

in different form. Added "emptyChat" check, looking for empty chat
messages.
This commit is contained in:
Evenprime 2011-11-27 16:43:54 +01:00
parent 5ce7bc04cd
commit a3479b0f58
22 changed files with 83 additions and 419 deletions

View File

@ -70,6 +70,8 @@ permissions:
children:
nocheat.checks.chat.spam:
description: Allow a player to send an infinite amount of chat messages
nocheat.checks.chat.empty:
description: Allow a player to send empty messages (normally not possible)
nocheat.checks.fight:
description: Allow the player to bypass all fight checks
children:
@ -79,8 +81,3 @@ permissions:
description: Allow a player to attack himself with close combat attacks (punching, swords, etc.)
nocheat.checks.fight.noswing:
description: Allow a player to fight without swinging their arm
nocheat.checks.timed:
description: Allow the player to bypass all timed checks
children:
nocheat.checks.timed.godmode:
description: Allow a player to use the godmode hack to make himself invincible to damage

View File

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

View File

@ -26,7 +26,6 @@ import cc.co.evenprime.bukkit.nocheat.events.ChatEventManager;
import cc.co.evenprime.bukkit.nocheat.events.EventManagerImpl;
import cc.co.evenprime.bukkit.nocheat.events.FightEventManager;
import cc.co.evenprime.bukkit.nocheat.events.MovingEventManager;
import cc.co.evenprime.bukkit.nocheat.events.TimedEventManager;
import cc.co.evenprime.bukkit.nocheat.events.WorkaroundsEventManager;
import cc.co.evenprime.bukkit.nocheat.log.LogLevel;
import cc.co.evenprime.bukkit.nocheat.log.LogManager;
@ -119,10 +118,6 @@ public class NoCheat extends JavaPlugin {
eventManagers.add(new BlockPlaceEventManager(this));
eventManagers.add(new FightEventManager(this));
TimedEventManager m = new TimedEventManager(this);
taskId = m.taskId; // There's a bukkit task, remember its id
eventManagers.add(m);
// Then set up a task to monitor server lag
if(lagMeasureTask == null) {
lagMeasureTask = new LagMeasureTask(this);

View File

@ -21,8 +21,6 @@ public interface NoCheatPlayer {
public int getTicksLived();
public void increaseAge(int ticks);
public ConfigurationCache getConfiguration();
public float getSpeedAmplifier();

View File

@ -1,23 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.checks;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.config.cache.CCTimed;
import cc.co.evenprime.bukkit.nocheat.data.ExecutionHistory;
import cc.co.evenprime.bukkit.nocheat.data.TimedData;
public abstract class TimedCheck extends Check {
public TimedCheck(NoCheat plugin, String name, String permission) {
super(plugin, name, permission);
}
public abstract void check(final NoCheatPlayer player, TimedData data, CCTimed cc);
public abstract boolean isEnabled(CCTimed cc);
@Override
protected ExecutionHistory getHistory(NoCheatPlayer player) {
return player.getData().timed.history;
}
}

View File

@ -0,0 +1,47 @@
package cc.co.evenprime.bukkit.nocheat.checks.chat;
import java.util.Locale;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;
import cc.co.evenprime.bukkit.nocheat.checks.ChatCheck;
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
import cc.co.evenprime.bukkit.nocheat.config.cache.CCChat;
import cc.co.evenprime.bukkit.nocheat.data.ChatData;
public class EmptyCheck extends ChatCheck {
public EmptyCheck(NoCheat plugin) {
super(plugin, "chat.empty", Permissions.CHAT_EMPTY);
}
public boolean check(NoCheatPlayer player, ChatData data, CCChat cc) {
boolean cancel = false;
if(data.message.trim().length() == 0) {
data.emptyVL += 1;
cancel = executeActions(player, cc.emptyActions.getActions(data.emptyVL));
}
return cancel;
}
@Override
public boolean isEnabled(CCChat cc) {
return cc.emptyCheck;
}
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", player.getData().chat.emptyVL);
default:
return super.getParameter(wildcard, player);
}
}
}

View File

@ -1,112 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.checks.timed;
import java.util.Locale;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionWithParameters.WildCard;
import cc.co.evenprime.bukkit.nocheat.checks.TimedCheck;
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
import cc.co.evenprime.bukkit.nocheat.config.cache.CCTimed;
import cc.co.evenprime.bukkit.nocheat.data.TimedData;
public class GodmodeCheck extends TimedCheck {
public GodmodeCheck(NoCheat plugin) {
super(plugin, "timed.godmode", Permissions.TIMED_GODMODE);
}
@Override
public void check(NoCheatPlayer player, TimedData data, CCTimed cc) {
// server lag(ged), skip this, or player dead, therefore it's reasonable
// for him to not move :)
if(plugin.skipCheck() || player.isDead()) {
data.ticksBehind = 0;
return;
}
final int ticksLived = player.getTicksLived();
// Haven't been checking before
if(data.ticksLived == 0) {
// setup data for next time
data.ticksLived = ticksLived;
// And give up already
return;
}
boolean cancel = false;
// How far behind is the player with his ticks
int behind = Math.min(10, (data.ticksLived + cc.tickTime) - ticksLived);
// difference should be >= tickTime for perfect synchronization
if(behind <= 1) {
// player as fast as expected, give him credit for that
data.ticksBehind -= cc.tickTime / 2;
// Reduce violation level over time
data.godmodeVL -= cc.tickTime / 2.0;
} else if(behind <= (cc.tickTime / 2) + 1) {
// close enough, let it pass
data.ticksBehind -= cc.tickTime / 4;
// Reduce violation level over time
data.godmodeVL -= cc.tickTime / 4.0;
} else {
// That's a bit suspicious, why is the player more than half the
// ticktime behind? Keep that in mind
data.ticksBehind += behind;
// Is he way too far behind, then correct that
if(data.ticksBehind > cc.godmodeTicksLimit) {
// Over the limit, start increasing VL for the player
data.godmodeVL += behind;
cancel = executeActions(player, cc.godmodeActions.getActions(data.godmodeVL));
if(cancel) {
// Catch up for at least some of the ticks
try {
player.increaseAge(cc.tickTime);
} catch(Exception e) {
e.printStackTrace();
}
// Reduce the time the player is behind accordingly
data.ticksBehind -= cc.tickTime;
}
}
}
if(data.ticksBehind < 0) {
data.ticksBehind = 0;
}
if(data.godmodeVL < 0) {
data.godmodeVL = 0;
}
// setup data for next time
data.ticksLived = player.getTicksLived();
return;
}
@Override
public boolean isEnabled(CCTimed cc) {
return cc.godmodeCheck;
}
public String getParameter(WildCard wildcard, NoCheatPlayer player) {
switch (wildcard) {
case VIOLATIONS:
return String.format(Locale.US, "%d", (int) player.getData().timed.godmodeVL);
default:
return super.getParameter(wildcard, player);
}
}
}

View File

@ -99,6 +99,10 @@ public abstract class Configuration {
public final static OptionNode CHAT_SPAM_LIMIT = new OptionNode("limit", CHAT_SPAM, DataType.INTEGER);
public final static OptionNode CHAT_SPAM_ACTIONS = new OptionNode("actions", CHAT_SPAM, DataType.ACTIONLIST);
private final static OptionNode CHAT_EMPTY = new OptionNode("empty", CHAT, DataType.PARENT);
public static final OptionNode CHAT_EMPTY_CHECK = new OptionNode("check", CHAT_EMPTY, DataType.BOOLEAN);
public static final OptionNode CHAT_EMPTY_ACTIONS = new OptionNode("actions", CHAT_EMPTY, DataType.ACTIONLIST);
private final static OptionNode FIGHT = new OptionNode("fight", ROOT, DataType.PARENT);
public final static OptionNode FIGHT_CHECK = new OptionNode("check", FIGHT, DataType.BOOLEAN);
@ -116,14 +120,6 @@ public abstract class Configuration {
public static final OptionNode FIGHT_NOSWING_CHECK = new OptionNode("check", FIGHT_NOSWING, DataType.BOOLEAN);
public static final OptionNode FIGHT_NOSWING_ACTIONS = new OptionNode("actions", FIGHT_NOSWING, DataType.ACTIONLIST);
private static final OptionNode TIMED = new OptionNode("timed", ROOT, DataType.PARENT);
public static final OptionNode TIMED_CHECK = new OptionNode("check", TIMED, DataType.BOOLEAN);
private static final OptionNode TIMED_GODMODE = new OptionNode("godmode", TIMED, DataType.PARENT);
public static final OptionNode TIMED_GODMODE_CHECK = new OptionNode("check", TIMED_GODMODE, DataType.BOOLEAN);
public static final OptionNode TIMED_GODMODE_TICKSLIMIT = new OptionNode("tickslimit", TIMED_GODMODE, DataType.INTEGER);
public static final OptionNode TIMED_GODMODE_ACTIONS = new OptionNode("actions", TIMED_GODMODE, DataType.ACTIONLIST);
private final Map<OptionNode, Object> values;
private final Configuration defaults;

View File

@ -141,9 +141,15 @@ public class DefaultConfiguration extends Configuration {
setValue(CHAT_SPAM_LIMIT, 5);
ActionList spamActionList = new ActionList();
spamActionList.setActions(0, action.getActions("spamLog spamCancel".split(" ")));
spamActionList.setActions(50, action.getActions("spamLog spamCancel spamkick".split(" ")));
spamActionList.setActions(0, action.getActions("spamLog chatCancel".split(" ")));
spamActionList.setActions(50, action.getActions("spamLog chatCancel spamkick".split(" ")));
setValue(CHAT_SPAM_ACTIONS, spamActionList);
setValue(CHAT_EMPTY_CHECK, true);
ActionList emptyActionList = new ActionList();
emptyActionList.setActions(0, action.getActions("emptyChatLog chatCancel emptyChatKick".split(" ")));
setValue(CHAT_EMPTY_ACTIONS, emptyActionList);
}
/*** FIGHT ***/
@ -171,19 +177,6 @@ public class DefaultConfiguration extends Configuration {
noswingActionList.setActions(0, action.getActions("noswingLog fightCancel".split(" ")));
setValue(FIGHT_NOSWING_ACTIONS, noswingActionList);
}
/*** TIMED ***/
{
setValue(TIMED_CHECK, true);
setValue(TIMED_GODMODE_CHECK, true);
setValue(TIMED_GODMODE_TICKSLIMIT, 50);
ActionList directionActionList = new ActionList();
directionActionList.setActions(0, action.getActions("godmodeCancel".split(" ")));
directionActionList.setActions(100, action.getActions("godmodeLog godmodeCancel".split(" ")));
setValue(TIMED_GODMODE_ACTIONS, directionActionList);
}
}
public static void writeActionFile(File file) {
@ -259,11 +252,10 @@ public class DefaultConfiguration extends Configuration {
w(w, "# Some other log messages that are limited a bit by default, to avoid too extreme spam");
w(w, "log reachLog 0 5 med [player] failed [check]: tried to interact with a block over distance [reachdistance]. VL [violations]");
w(w, "log directionLog 2 5 med [player] failed [check]: tried to interact with a block out of line of sight. VL [violations]");
w(w, "log onliquidLog 2 5 med [player] failed [check]: tried to place a [blocktype] block at [placelocation] against block at [placeagainst]. VL [violations]");
w(w, "log spamLog 0 5 med [player] failed [check]: Last sent message \"[text]\". VL [violations]");
w(w, "log nofallLog 0 5 med [player] failed [check]: tried to avoid fall damage for ~[falldistance] blocks. VL [violations]");
w(w, "log godmodeLog 0 5 med [player] failed [check]: lagging or using godmode. VL [violations]");
w(w, "log noswingLog 2 5 med [player] failed [check]: Didn't swing arm. VL [violations]");
w(w, "log emptyChatLog 0 5 med [player] failed [check]: Sent empty chat message. VL [violations]");
w(w, "");
w(w, "");
w(w, "# Some log messages related to fighting, displaying the same text, but with different level (Info, Warning, Severe)");
@ -285,9 +277,9 @@ public class DefaultConfiguration extends Configuration {
w(w, "special blockbreakCancel 0 0");
w(w, "special blockplaceCancel 0 0");
w(w, "special spamCancel 0 0");
w(w, "special chatCancel 0 0");
w(w, "special nofallDamage 0 0");
w(w, "special fightCancel 0 0");
w(w, "special godmodeCancel 0 0");
w(w, "");
w(w, "# CONSOLECOMMAND Actions: They will execute a command as if it were typed into the console.");
w(w, "# - They start with the word 'consolecommand'");
@ -299,6 +291,7 @@ public class DefaultConfiguration extends Configuration {
w(w, "# E.g. Kick a player");
w(w, "consolecommand kick 0 1 kick [player]");
w(w, "consolecommand spamkick 0 1 kick [player]");
w(w, "consolecommand emptyChatKick 0 1 kick [player]");
w.flush();
w.close();
} catch(IOException e) {

View File

@ -84,6 +84,9 @@ public class Explainations {
set(Configuration.CHAT_SPAM_LIMIT, "How many messages per timeframe may the player send without it counting as spamming?");
set(Configuration.CHAT_SPAM_ACTIONS, "What should be done if a player is trying to spam the chat.\nUnit is number of chat messages above the limit you declared above.");
set(Configuration.CHAT_EMPTY_CHECK, "If true, check if a player is sending an empty message.");
set(Configuration.CHAT_EMPTY_ACTIONS, "What should be done if a player sends an empty message.\nUnit is number of empty chat messages sent by the player.");
set(Configuration.FIGHT_CHECK, "If true, do various checks on Events related to fighting.");
set(Configuration.FIGHT_DIRECTION_CHECK, "If true, check if a player is really looking at enemies that he attacks.");
set(Configuration.FIGHT_DIRECTION_PRECISION, "Set how precise the check should be. If you experience the check to be too zealous, increase this value. \nIf you want to make it tighter, reduce this value. Default is 100.");
@ -96,11 +99,6 @@ public class Explainations {
set(Configuration.FIGHT_NOSWING_CHECK, "If true, check if a player swung his arm before attacking, which he should have done.");
set(Configuration.FIGHT_NOSWING_ACTIONS, "What should be done if a player didn't swing his arm.\nUnit is number of attacks without armswinging.");
set(Configuration.TIMED_CHECK, "If true, do various checks on things related to server and client time.");
set(Configuration.TIMED_GODMODE_CHECK, "If true, check or prevent if a player made himself invulnerable by exploiting a time-related bug.\nThis 'godmode' exploit looks similar to a player with huge lag, so be careful when punishing people for it.");
set(Configuration.TIMED_GODMODE_TICKSLIMIT, "How many ticks may a player be behind the server time before NoCheat reacts. Default is 50.");
set(Configuration.TIMED_GODMODE_ACTIONS, "What should be done if a player is considered using 'godmode'.\nUnit is number of ticks of potential godmode usage.");
}
private static void set(OptionNode id, String text) {

View File

@ -29,6 +29,7 @@ public class Permissions {
public final static String CHAT = CHECKS + ".chat";
public final static String CHAT_SPAM = CHAT + ".spam";
public static final String CHAT_EMPTY = CHAT + ".empty";
public static final String FIGHT = CHECKS + ".fight";
public static final String FIGHT_DIRECTION = FIGHT + ".direction";

View File

@ -14,6 +14,8 @@ public class CCChat {
public final int spamTimeframe;
public final int spamLimit;
public final ActionList spamActions;
public final boolean emptyCheck;
public final ActionList emptyActions;
public CCChat(Configuration data) {
@ -23,6 +25,8 @@ public class CCChat {
spamTimeframe = data.getInteger(Configuration.CHAT_SPAM_TIMEFRAME);
spamLimit = data.getInteger(Configuration.CHAT_SPAM_LIMIT);
spamActions = data.getActionList(Configuration.CHAT_SPAM_ACTIONS);
emptyCheck = data.getBoolean(Configuration.CHAT_EMPTY_CHECK);
emptyActions = data.getActionList(Configuration.CHAT_EMPTY_ACTIONS);
}

View File

@ -1,21 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.config.cache;
import cc.co.evenprime.bukkit.nocheat.config.Configuration;
import cc.co.evenprime.bukkit.nocheat.config.util.ActionList;
public class CCTimed {
public final boolean check;
public final boolean godmodeCheck;
public final double godmodeTicksLimit;
public final ActionList godmodeActions;
public final int tickTime = 10;
public CCTimed(Configuration data) {
check = data.getBoolean(Configuration.TIMED_CHECK);
godmodeCheck = data.getBoolean(Configuration.TIMED_GODMODE_CHECK);
godmodeTicksLimit = data.getInteger(Configuration.TIMED_GODMODE_TICKSLIMIT);
godmodeActions = data.getActionList(Configuration.TIMED_GODMODE_ACTIONS);
}
}

View File

@ -18,7 +18,6 @@ public class ConfigurationCache {
public final CCChat chat;
public final CCDebug debug;
public final CCFight fight;
public final CCTimed timed;
/**
* Instantiate a config cache and populate it with the data of a
@ -35,7 +34,6 @@ public class ConfigurationCache {
logging = new CCLogging(data, worldSpecificFileLogger);
debug = new CCDebug(data);
fight = new CCFight(data);
timed = new CCTimed(data);
}
}

View File

@ -10,4 +10,5 @@ public class ChatData extends Data {
public final ExecutionHistory history = new ExecutionHistory();
public String message = "";
public int spamVL;
public int emptyVL;
}

View File

@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.player.NoCheatPlayerImpl;
import cc.co.evenprime.bukkit.nocheat.player.PlayerFactory;
/**
* Provide secure access to player-specific data objects for various checks or
@ -37,9 +36,7 @@ public class PlayerManager {
NoCheatPlayerImpl p = this.players.get(player.getName());
if(p == null) {
// PlayerFactory may create different players based on the
// MCVersion that we are running
p = PlayerFactory.createPlayer(player, plugin);
p = new NoCheatPlayerImpl(player, plugin);
this.players.put(player.getName(), p);
}

View File

@ -12,6 +12,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.checks.ChatCheck;
import cc.co.evenprime.bukkit.nocheat.checks.chat.EmptyCheck;
import cc.co.evenprime.bukkit.nocheat.checks.chat.SpamCheck;
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
import cc.co.evenprime.bukkit.nocheat.config.cache.CCChat;
@ -27,7 +28,8 @@ public class ChatEventManager extends EventManagerImpl {
super(plugin);
this.checks = new ArrayList<ChatCheck>(1);
this.checks = new ArrayList<ChatCheck>(2);
this.checks.add(new EmptyCheck(plugin));
this.checks.add(new SpamCheck(plugin));
registerListener(Event.Type.PLAYER_CHAT, Priority.Lowest, true, plugin.getPerformance(Type.CHAT));
@ -72,6 +74,8 @@ public class ChatEventManager extends EventManagerImpl {
if(cc.chat.check && cc.chat.spamCheck)
s.add("chat.spam");
if(cc.chat.check && cc.chat.emptyCheck)
s.add("chat.empty");
return s;
}
}

View File

@ -1,124 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.events;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
import java.util.LinkedList;
import java.util.List;
import net.minecraft.server.EntityPlayer;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
import cc.co.evenprime.bukkit.nocheat.checks.TimedCheck;
import cc.co.evenprime.bukkit.nocheat.checks.timed.GodmodeCheck;
import cc.co.evenprime.bukkit.nocheat.config.Permissions;
import cc.co.evenprime.bukkit.nocheat.config.cache.CCTimed;
import cc.co.evenprime.bukkit.nocheat.config.cache.ConfigurationCache;
import cc.co.evenprime.bukkit.nocheat.data.TimedData;
import cc.co.evenprime.bukkit.nocheat.debug.Performance;
import cc.co.evenprime.bukkit.nocheat.debug.PerformanceManager.Type;
public class TimedEventManager extends EventManagerImpl {
private final List<TimedCheck> checks;
private final Performance timedPerformance;
public int taskId = -1;
public TimedEventManager(final NoCheat plugin) {
super(plugin);
checks = new ArrayList<TimedCheck>(1);
checks.add(new GodmodeCheck(plugin));
this.timedPerformance = plugin.getPerformance(Type.TIMED);
// "register a listener" for passed time
this.taskId = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
private int executions = 0;
private int loopsize = 10;
private final List<EntityPlayer> entities = new ArrayList<EntityPlayer>(20);
@SuppressWarnings("unchecked")
public void run() {
executions++;
if(executions >= loopsize) {
executions = 0;
}
// For performance reasons, we take some shortcuts here
CraftServer server = (CraftServer) plugin.getServer();
try {
// Only collect the entities that we want to check this time
for(EntityPlayer p : (List<EntityPlayer>) server.getHandle().players) {
if(p.id % loopsize == executions) {
entities.add(p);
}
}
} catch(ConcurrentModificationException e) {
// Bad luck, better luck next time
} catch(Exception e) {
e.printStackTrace();
}
// Now initialize the checks one by one
for(EntityPlayer p : entities) {
try {
// Performance counter setup
long nanoTimeStart = 0;
final boolean performanceCheck = timedPerformance.isEnabled();
if(performanceCheck)
nanoTimeStart = System.nanoTime();
handleEvent(plugin.getPlayer((Player) p.getBukkitEntity()));
// store performance time
if(performanceCheck)
timedPerformance.addTime(System.nanoTime() - nanoTimeStart);
} catch(Exception e) {
e.printStackTrace();
}
}
// Clear the list for next time
entities.clear();
}
}, 0, 1);
}
private void handleEvent(final NoCheatPlayer player) {
final TimedData data = player.getData().timed;
final CCTimed cc = player.getConfiguration().timed;
if(!cc.check || player.hasPermission(Permissions.TIMED)) {
return;
}
for(TimedCheck check : checks) {
if(cc.check && !player.hasPermission(Permissions.TIMED)) {
check.check(player, data, cc);
}
}
}
public List<String> getActiveChecks(ConfigurationCache cc) {
LinkedList<String> s = new LinkedList<String>();
if(cc.timed.check && cc.timed.godmodeCheck)
s.add("timed.godmode");
return s;
}
}

View File

@ -24,11 +24,11 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
// The method that's used to artifically "fast-forward" the player
protected static Method incAge = null;
public NoCheatPlayerImpl(Player player, NoCheat plugin, BaseData data) {
public NoCheatPlayerImpl(Player player, NoCheat plugin) {
this.player = player;
this.plugin = plugin;
this.data = data;
this.data = new BaseData();
this.lastUsedTime = System.currentTimeMillis();
}
@ -40,6 +40,7 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
public boolean isDead() {
return this.player.getHealth() <= 0 || this.player.isDead();
}
public boolean hasPermission(String permission) {
if(permission == null) {
System.out.println("NoCheat: Warning, asked for null permission");
@ -68,24 +69,6 @@ public class NoCheatPlayerImpl implements NoCheatPlayer {
return player.getTicksLived();
}
public void increaseAge(int ticks) {
if(incAge == null) {
player.setTicksLived(player.getTicksLived() + ticks);
return;
}
EntityPlayer p = ((CraftPlayer) player).getHandle();
for(int i = 0; i < ticks; i++) {
try {
incAge.invoke(p, true);
} catch(Exception e) {
e.printStackTrace();
}
}
}
public float getSpeedAmplifier() {
EntityPlayer ep = ((CraftPlayer) player).getHandle();
if(ep.hasEffect(MobEffectList.FASTER_MOVEMENT)) {

View File

@ -1,23 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.player;
import net.minecraft.server.EntityPlayer;
import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.data.BaseData;
public class NoCheatPlayer_100 extends NoCheatPlayerImpl {
static {
try {
incAge = EntityPlayer.class.getMethod("a", boolean.class);
} catch(Exception e) {
System.out.println("NoCheat couldn't initialize variable incAge");
}
}
public NoCheatPlayer_100(Player player, NoCheat plugin, BaseData data) {
super(player, plugin, data);
}
}

View File

@ -1,24 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.player;
import net.minecraft.server.EntityPlayer;
import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.data.BaseData;
public class NoCheatPlayer_181 extends NoCheatPlayerImpl {
public NoCheatPlayer_181(Player player, NoCheat plugin, BaseData data) {
super(player, plugin, data);
}
static {
try {
incAge = EntityPlayer.class.getMethod("b", boolean.class);
} catch(Exception e) {
System.out.println("NoCheat couldn't initialize variable incAge");
}
}
}

View File

@ -1,21 +0,0 @@
package cc.co.evenprime.bukkit.nocheat.player;
import org.bukkit.entity.Player;
import cc.co.evenprime.bukkit.nocheat.NoCheat;
import cc.co.evenprime.bukkit.nocheat.data.BaseData;
public class PlayerFactory {
public static NoCheatPlayerImpl createPlayer(Player player, NoCheat plugin) {
switch (plugin.getMCVersion()) {
case MC100:
return new NoCheatPlayer_100(player, plugin, new BaseData());
case MC181:
return new NoCheatPlayer_181(player, plugin, new BaseData());
default:
return new NoCheatPlayerImpl(player, plugin, new BaseData());
}
}
}