mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-03 01:00:20 +01:00
Removed Itemdupe check (no longer needed)
Readded water ladder support (optional by config file)
This commit is contained in:
parent
a039edcfaf
commit
2c8de34864
@ -3,7 +3,7 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 1.02
|
||||
version: 1.03
|
||||
|
||||
softdepend: [ Permissions, CraftIRC ]
|
||||
|
||||
|
@ -20,7 +20,6 @@ import cc.co.evenprime.bukkit.nocheat.checks.AirbuildCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.BogusitemsCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.Check;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.ItemdupeCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.SpeedhackCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||
@ -45,7 +44,6 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
private BedteleportCheck bedteleportCheck;
|
||||
private SpeedhackCheck speedhackCheck;
|
||||
private AirbuildCheck airbuildCheck;
|
||||
private ItemdupeCheck itemdupeCheck;
|
||||
private BogusitemsCheck bogusitemsCheck;
|
||||
|
||||
private Check[] checks;
|
||||
@ -141,11 +139,10 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
bedteleportCheck = new BedteleportCheck(this, config);
|
||||
speedhackCheck = new SpeedhackCheck(this, config);
|
||||
airbuildCheck = new AirbuildCheck(this, config);
|
||||
itemdupeCheck = new ItemdupeCheck(this, config);
|
||||
bogusitemsCheck = new BogusitemsCheck(this, config);
|
||||
|
||||
// just for convenience
|
||||
checks = new Check[] { movingCheck, bedteleportCheck, speedhackCheck, airbuildCheck, itemdupeCheck, bogusitemsCheck };
|
||||
checks = new Check[] { movingCheck, bedteleportCheck, speedhackCheck, airbuildCheck, bogusitemsCheck };
|
||||
|
||||
if(!allowFlightSet && movingCheck.isActive()) {
|
||||
Logger.getLogger("Minecraft").warning( "[NoCheat] you have set \"allow-flight=false\" in your server.properties file. That builtin anti-flying-mechanism will likely conflict with this plugin. Please consider deactivating it by setting it to \"true\"");
|
||||
@ -332,8 +329,6 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
this.consoleLevel = config.getLogLevelValue("logging.logtoconsole");
|
||||
this.ircTag = config.getStringValue("logging.logtoirctag");
|
||||
} catch (ConfigurationException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
this.setEnabled(false);
|
||||
}
|
||||
|
||||
@ -366,6 +361,7 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
|
||||
s = s + (movingCheck.isActive() && !movingCheck.allowFlying ? "flying " : "");
|
||||
s = s + (movingCheck.isActive() && !movingCheck.allowFakeSneak ? "fakesneak " : "");
|
||||
s = s + (movingCheck.isActive() && !movingCheck.allowFastSwim ? "fastswim " : "");
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -381,6 +377,8 @@ public class NoCheat extends JavaPlugin implements CommandSender {
|
||||
|
||||
s = s + (!movingCheck.isActive() || movingCheck.allowFlying ? "flying* " : (hasPermission(p, PermissionData.PERMISSION_FLYING) ? "flying " : ""));
|
||||
s = s + (!movingCheck.isActive() || movingCheck.allowFakeSneak ? "fakesneak* " : (hasPermission(p, PermissionData.PERMISSION_FAKESNEAK) ? "fakesneak " : ""));
|
||||
s = s + (!movingCheck.isActive() || movingCheck.allowFastSwim ? "fastswim* " : (hasPermission(p, PermissionData.PERMISSION_FASTSWIM) ? "fastswim " : ""));
|
||||
|
||||
s = s + (hasPermission(p, PermissionData.PERMISSION_NOTIFY) ? "notify " : "");
|
||||
|
||||
return s;
|
||||
|
@ -1,55 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.ConfigurationException;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.config.NoCheatConfiguration;
|
||||
import cc.co.evenprime.bukkit.nocheat.data.PermissionData;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.ItemdupeEntityListener;
|
||||
|
||||
public class ItemdupeCheck extends Check {
|
||||
|
||||
public ItemdupeCheck(NoCheat plugin, NoCheatConfiguration config){
|
||||
super(plugin, "itemdupe", PermissionData.PERMISSION_ITEMDUPE, config);
|
||||
}
|
||||
|
||||
|
||||
public void check(EntityDeathEvent event) {
|
||||
|
||||
if(event.getEntity() instanceof CraftPlayer) {
|
||||
if(skipCheck((CraftPlayer)event.getEntity())) return;
|
||||
|
||||
((CraftPlayer)event.getEntity()).getHandle().x(); // close all inventory screens
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(NoCheatConfiguration config) {
|
||||
|
||||
try {
|
||||
setActive(config.getBooleanValue("active.itemdupe"));
|
||||
} catch (ConfigurationException e) {
|
||||
setActive(false);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerListeners() {
|
||||
PluginManager pm = Bukkit.getServer().getPluginManager();
|
||||
|
||||
// Register listeners for itemdupe check
|
||||
Listener itemdupePlayerListener = new ItemdupeEntityListener(this);
|
||||
|
||||
// Register listeners for itemdupe check
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, itemdupePlayerListener, Priority.Lowest, plugin);
|
||||
|
||||
}
|
||||
}
|
@ -61,7 +61,10 @@ public class MovingCheck extends Check {
|
||||
|
||||
public boolean allowFlying;
|
||||
public boolean allowFakeSneak;
|
||||
private boolean allowFastSwim;
|
||||
public boolean allowFastSwim;
|
||||
|
||||
|
||||
private boolean waterElevators;
|
||||
|
||||
private String logMessage;
|
||||
private String summaryMessage;
|
||||
@ -107,7 +110,7 @@ public class MovingCheck extends Check {
|
||||
statisticTotalEvents++;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**** Horizontal movement check START ****/
|
||||
|
||||
// First check the distance the player has moved horizontally
|
||||
@ -247,12 +250,12 @@ public class MovingCheck extends Check {
|
||||
private int getSneakingViolationLevel(final double combined, final MovingData data, final Player player) {
|
||||
|
||||
int violationLevelSneaking = -1;
|
||||
|
||||
|
||||
// Maybe the player is allowed to sneak faster than usual?
|
||||
final boolean canFakeSneak = allowFakeSneak || plugin.hasPermission(player, PermissionData.PERMISSION_FAKESNEAK);
|
||||
|
||||
if(!canFakeSneak) {
|
||||
|
||||
|
||||
// Explaination blob:
|
||||
// When a player starts to sneak, he may have a phase where he is still moving faster than he
|
||||
// should be, e.g. because he is in air, on slippery ground, ...
|
||||
@ -287,14 +290,14 @@ public class MovingCheck extends Check {
|
||||
private int getSwimmingViolationLevel( final double combined, final MovingData data, final boolean isSwimming, final Player player) {
|
||||
|
||||
int violationLevelSwimming = -1;
|
||||
|
||||
|
||||
// Maybe the player is allowed to swim faster than usual?
|
||||
final boolean canFastSwim = allowFastSwim || plugin.hasPermission(player, PermissionData.PERMISSION_FASTSWIM);
|
||||
|
||||
|
||||
if(!canFastSwim) {
|
||||
|
||||
|
||||
final double limit = data.horizFreedom + swimWidth;
|
||||
|
||||
|
||||
|
||||
// Explaination blob:
|
||||
// When a player starts to swim, he may have a phase where he is still moving faster than he
|
||||
@ -312,10 +315,10 @@ public class MovingCheck extends Check {
|
||||
violationLevelSwimming = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data.swimmingLastDistance = combined;
|
||||
}
|
||||
|
||||
|
||||
if(violationLevelSwimming >= 0 && data.swimmingFreedomCounter > 0) {
|
||||
violationLevelSwimming = -1;
|
||||
}
|
||||
@ -580,7 +583,7 @@ public class MovingCheck extends Check {
|
||||
* @param l The precise location that was used for calculation of "values"
|
||||
* @return
|
||||
*/
|
||||
private static int playerIsOnGround(final Location l, final double ymod) {
|
||||
private int playerIsOnGround(final Location l, final double ymod) {
|
||||
|
||||
final int types[] = MovingData.types;
|
||||
|
||||
@ -640,6 +643,19 @@ public class MovingCheck extends Check {
|
||||
return MovingData.SOLID;
|
||||
}
|
||||
|
||||
// Water elevators - optional "feature"
|
||||
if(waterElevators) {
|
||||
result = types[w.getBlockTypeIdAt(lowerX+1, Y+1, lowerZ+1)] |
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y , lowerZ+1)] |
|
||||
types[w.getBlockTypeIdAt(lowerX, Y+1, lowerZ+1)] |
|
||||
types[w.getBlockTypeIdAt(lowerX , Y , lowerZ+1)] |
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y+1, lowerZ )] |
|
||||
types[w.getBlockTypeIdAt(lowerX+1, Y , lowerZ )] ;
|
||||
|
||||
if((result & MovingData.LIQUID) != 0) {
|
||||
return MovingData.SOLID; // Solid? Why that? Because that's closer to what the bug actually does than liquid
|
||||
}
|
||||
}
|
||||
// If nothing matches, he is somewhere in the air
|
||||
return MovingData.NONSOLID;
|
||||
}
|
||||
@ -688,6 +704,8 @@ public class MovingCheck extends Check {
|
||||
allowFlying = config.getBooleanValue("moving.allowflying");
|
||||
allowFakeSneak = config.getBooleanValue("moving.allowfakesneak");
|
||||
allowFastSwim = config.getBooleanValue("moving.allowfastswim");
|
||||
|
||||
waterElevators = config.getBooleanValue("moving.waterelevators");
|
||||
|
||||
logMessage = config.getStringValue("moving.logmessage");
|
||||
summaryMessage = config.getStringValue("moving.summarymessage");
|
||||
|
@ -103,8 +103,6 @@ public class NoCheatConfiguration {
|
||||
SimpleYaml.getBoolean("active.airbuild", false, yamlContent)));
|
||||
activeNode.add(new BooleanOption("bedteleport",
|
||||
SimpleYaml.getBoolean("active.bedteleport", true, yamlContent)));
|
||||
activeNode.add(new BooleanOption("itemdupe",
|
||||
SimpleYaml.getBoolean("active.itemdupe", true, yamlContent)));
|
||||
activeNode.add(new BooleanOption("bogusitems",
|
||||
SimpleYaml.getBoolean("active.bogusitems", false, yamlContent)));
|
||||
}
|
||||
@ -162,6 +160,8 @@ public class NoCheatConfiguration {
|
||||
SimpleYaml.getBoolean("moving.allowfakesneak", true, yamlContent)));
|
||||
movingNode.add(new BooleanOption("allowfastswim",
|
||||
SimpleYaml.getBoolean("moving.allowfastswim", false, yamlContent)));
|
||||
movingNode.add(new BooleanOption("waterelevators",
|
||||
SimpleYaml.getBoolean("moving.waterelevators", false, yamlContent)));
|
||||
|
||||
/*** MOVING ACTION section ***/
|
||||
{
|
||||
@ -215,12 +215,6 @@ public class NoCheatConfiguration {
|
||||
root.add(bedteleportNode);
|
||||
}
|
||||
|
||||
/*** ITEMDUPE section ***/
|
||||
{
|
||||
ParentOption itemdupeNode = new ParentOption("itemdupe", false);
|
||||
root.add(itemdupeNode);
|
||||
}
|
||||
|
||||
/*** BOGUSITEMS section ***/
|
||||
{
|
||||
ParentOption bogusitemsNode = new ParentOption("bogusitems", false);
|
||||
|
@ -1,21 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.ItemdupeCheck;
|
||||
|
||||
public class ItemdupeEntityListener extends EntityListener {
|
||||
|
||||
private ItemdupeCheck check;
|
||||
|
||||
public ItemdupeEntityListener(ItemdupeCheck itemdupeCheck) {
|
||||
check = itemdupeCheck;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
|
||||
check.check(event);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user