mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-27 01:41:28 +01:00
New optional bugfix for teleporting out of beds + removed now useless
code + changed some default values
This commit is contained in:
parent
8c11e72095
commit
2e711e4f44
@ -3,5 +3,5 @@ name: NoCheatPlugin
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
||||
version: 0.6.2
|
||||
version: 0.6.3
|
||||
|
||||
|
@ -28,6 +28,7 @@ public class NoCheatConfiguration {
|
||||
public static boolean movingCheckActive;
|
||||
public static boolean airbuildCheckActive;
|
||||
public static boolean dupebydeathCheckActive;
|
||||
public static boolean bedteleportCheckActive;
|
||||
|
||||
// Limits for the speedhack check
|
||||
public static int speedhackLimitLow;
|
||||
@ -101,7 +102,8 @@ public class NoCheatConfiguration {
|
||||
speedhackCheckActive = c.getBoolean("active.speedhack", true);
|
||||
movingCheckActive = c.getBoolean("active.moving", true);
|
||||
airbuildCheckActive = c.getBoolean("active.airbuild", false);
|
||||
dupebydeathCheckActive = c.getBoolean("active.dupebydeath", false);
|
||||
dupebydeathCheckActive = c.getBoolean("active.dupebydeath", true);
|
||||
bedteleportCheckActive = c.getBoolean("active.bedteleport", true);
|
||||
|
||||
speedhackLimitLow = c.getInt("speedhack.limits.low", 30);
|
||||
speedhackLimitMed = c.getInt("speedhack.limits.med", 45);
|
||||
@ -160,7 +162,8 @@ public class NoCheatConfiguration {
|
||||
w.write(" speedhack: true"); w.newLine();
|
||||
w.write(" moving: true"); w.newLine();
|
||||
w.write(" airbuild: false"); w.newLine();
|
||||
w.write(" dupebydeath: false"); w.newLine();
|
||||
w.write(" dupebydeath: true"); w.newLine();
|
||||
w.write(" bedteleport: true"); w.newLine();
|
||||
w.write("# Speedhack specific options"); w.newLine();
|
||||
w.write("speedhack:"); w.newLine();
|
||||
w.write(" limits:"); w.newLine();
|
||||
@ -169,9 +172,9 @@ public class NoCheatConfiguration {
|
||||
w.write(" high: 60"); w.newLine();
|
||||
w.write("# Speedhack Action, one or more of loglow logmed loghigh reset"); w.newLine();
|
||||
w.write(" action:"); w.newLine();
|
||||
w.write(" low: loglow"); w.newLine();
|
||||
w.write(" med: logmed"); w.newLine();
|
||||
w.write(" high: loghigh"); w.newLine();
|
||||
w.write(" low: loglow reset"); w.newLine();
|
||||
w.write(" med: logmed reset"); w.newLine();
|
||||
w.write(" high: loghigh reset"); w.newLine();
|
||||
w.write("# Moving specific optionse") ;w.newLine();
|
||||
w.write("moving:"); w.newLine();
|
||||
w.write(" freemoves: 10"); w.newLine();
|
||||
@ -186,6 +189,9 @@ public class NoCheatConfiguration {
|
||||
w.write(" action: logmed deny"); w.newLine();
|
||||
w.write("# Dupebydeath specific options (none exist yet)"); w.newLine();
|
||||
w.write("dupebydeath:"); w.newLine();
|
||||
w.write("# Bedteleport specific options (none exist yet)"); w.newLine();
|
||||
w.write("bedteleport:"); w.newLine();
|
||||
|
||||
w.flush(); w.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatBlockListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatEntityListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatPlayerListener;
|
||||
import cc.co.evenprime.bukkit.nocheat.listeners.NoCheatVehicleListener;
|
||||
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
@ -34,7 +33,6 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
|
||||
// Various listeners needed for different Checks
|
||||
private NoCheatPlayerListener playerListener;
|
||||
private NoCheatVehicleListener vehicleListener;
|
||||
private NoCheatBlockListener blockListener;
|
||||
private NoCheatEntityListener entityListener;
|
||||
|
||||
@ -86,7 +84,6 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
// Create our listeners and feed them with neccessary information
|
||||
playerListener = new NoCheatPlayerListener();
|
||||
vehicleListener = new NoCheatVehicleListener(playerListener);
|
||||
blockListener = new NoCheatBlockListener();
|
||||
entityListener = new NoCheatEntityListener();
|
||||
|
||||
@ -95,10 +92,9 @@ public class NoCheatPlugin extends JavaPlugin {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, playerListener, Priority.Lowest, this); // needed for speedhack and moving checks
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this); // used to delete old data of users
|
||||
pm.registerEvent(Event.Type.VEHICLE_EXIT, vehicleListener, Priority.Monitor, this); // used for moving check
|
||||
pm.registerEvent(Event.Type.VEHICLE_DAMAGE, vehicleListener, Priority.Monitor, this); // used for moving check
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACED, blockListener, Priority.Low, this); // used for airbuild check
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Highest, this); // used for dupebydeath check
|
||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, playerListener, Priority.Lowest, this); // used for teleportfrombed check
|
||||
|
||||
PluginDescriptionFile pdfFile = this.getDescription();
|
||||
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.checks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
|
||||
public class BedteleportCheck {
|
||||
|
||||
|
||||
public static void check(PlayerMoveEvent event) {
|
||||
|
||||
// Should we check at all
|
||||
if(NoCheatPlugin.Permissions != null && NoCheatPlugin.Permissions.has(event.getPlayer(), "nocheat.bedteleport")) {
|
||||
return;
|
||||
}
|
||||
else if(NoCheatPlugin.Permissions == null && event.getPlayer().isOp() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getFrom().getWorld().getBlockTypeIdAt(event.getFrom()) == Material.BED_BLOCK.getId()) {
|
||||
double yRest = Math.floor(event.getFrom().getY()) - event.getFrom().getY();
|
||||
if(yRest > 0.099 && yRest < 0.101)
|
||||
// Don't allow the teleport
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -142,6 +142,7 @@ public class MovingCheck {
|
||||
Location from = event.getFrom();
|
||||
Location to = event.getTo();
|
||||
|
||||
System.out.println(from.getY() + " " + to.getY());
|
||||
// First check the distance the player has moved horizontally
|
||||
// TODO: Make this check much more precise
|
||||
double xDistance = Math.abs(from.getX() - to.getX());
|
||||
|
@ -1,12 +1,8 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.DupebydeathCheck;
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatConfiguration;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatData;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlugin;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||
import cc.co.evenprime.bukkit.nocheat.checks.SpeedhackCheck;
|
||||
|
||||
@ -43,12 +44,7 @@ public class NoCheatPlayerListener extends PlayerListener {
|
||||
|
||||
// Get the player-specific data
|
||||
NoCheatData data = NoCheatPlugin.getPlayerData(event.getPlayer());
|
||||
|
||||
if(data.movingIgnoreNextXEvents > 0 ) {
|
||||
data.movingIgnoreNextXEvents--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!event.isCancelled() && NoCheatConfiguration.speedhackCheckActive)
|
||||
SpeedhackCheck.check(data, event);
|
||||
|
||||
@ -56,4 +52,11 @@ public class NoCheatPlayerListener extends PlayerListener {
|
||||
MovingCheck.check(data, event);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
||||
|
||||
if(!event.isCancelled() && NoCheatConfiguration.bedteleportCheckActive) {
|
||||
BedteleportCheck.check(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||
|
||||
|
||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.event.vehicle.VehicleListener;
|
||||
|
||||
|
||||
/**
|
||||
* Handle events for all Player related events
|
||||
*
|
||||
* @author Evenprime
|
||||
*/
|
||||
|
||||
public class NoCheatVehicleListener extends VehicleListener {
|
||||
|
||||
private final NoCheatPlayerListener playerListener;
|
||||
|
||||
public NoCheatVehicleListener(NoCheatPlayerListener playerListener) {
|
||||
this.playerListener = playerListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
playerListener.ingoreNextXEvents(event.getExited(), 1);
|
||||
|
||||
}
|
||||
|
||||
public void onVehicleDamage(VehicleDamageEvent event) {
|
||||
playerListener.ingoreNextXEvents(event.getVehicle().getPassenger(), 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user