From 84c8e980548f41f96ba7ea3f69ffe1cc98b9d828 Mon Sep 17 00:00:00 2001 From: Evenprime Date: Sun, 12 Jun 2011 11:35:03 +0200 Subject: [PATCH] Potential fix for World<->Nether teleports Potential fix for Vehicle destruction problems --- plugin.yml | 2 +- .../bukkit/nocheat/checks/MovingCheck.java | 20 +++++----- .../bukkit/nocheat/checks/SpeedhackCheck.java | 7 +++- .../bukkit/nocheat/data/MovingData.java | 3 +- .../listeners/MovingPlayerMonitor.java | 6 ++- .../bukkit/nocheat/wizard/Wizard.java | 3 -- .../nocheat/wizard/gui/ParentOptionGui.java | 37 ++++++++++++++++--- 7 files changed, 52 insertions(+), 26 deletions(-) diff --git a/plugin.yml b/plugin.yml index c4154814..3e13a79e 100644 --- a/plugin.yml +++ b/plugin.yml @@ -3,7 +3,7 @@ name: NoCheat author: Evenprime main: cc.co.evenprime.bukkit.nocheat.NoCheat -version: 1.03 +version: 1.04 softdepend: [ Permissions, CraftIRC ] diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java index f987b259..ea42b6cc 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/MovingCheck.java @@ -92,6 +92,7 @@ public class MovingCheck extends Check { // Should we check at all if(skipCheck(player)) { return; } + final long startTime = System.nanoTime(); // Get the player-specific data @@ -110,7 +111,7 @@ public class MovingCheck extends Check { statisticTotalEvents++; return; } - + /**** Horizontal movement check START ****/ // First check the distance the player has moved horizontally @@ -382,6 +383,10 @@ public class MovingCheck extends Check { final double z = from.getZ(); final Location l = data.lastLocation; + // Player is currently changing worlds + if(data.worldChanged) { + return true; + } if(x == to.getX() && z == to.getZ() && y == to.getY() ) { return true; } @@ -394,13 +399,8 @@ public class MovingCheck extends Check { data.respawned = false; return true; } - // Player respawned just before, this causes all kinds of weirdness - better ignore it - else if(data.worldChanged > 0) { - data.worldChanged--; - return true; - } // Player is inside a vehicle, this causes all kinds of weirdness - better ignore it - else if(player.isInsideVehicle()) { + else if(data.insideVehicle || player.isInsideVehicle()) { return true; } return false; @@ -453,10 +453,8 @@ public class MovingCheck extends Check { data.teleportTo = event.getTo(); data.jumpPhase = 0; data.setBackPoint = event.getTo(); - - if(!event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName())) { - data.worldChanged = 2; // ignore two events, because teleporting through nether portals is really weird -.- - } + + data.worldChanged = !event.getFrom().getWorld().getName().equals(event.getTo().getWorld().getName()); } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java b/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java index 9e1e0a8b..100a78d2 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java +++ b/src/cc/co/evenprime/bukkit/nocheat/checks/SpeedhackCheck.java @@ -49,13 +49,16 @@ public class SpeedhackCheck extends Check { // Should we check at all? if(skipCheck(player)) return; - - // Ignore events of players in vehicles (these can be the cause of event spam between server and client) // Ignore events if the player has positive y-Velocity (these can be the cause of event spam between server and client) if(player.isInsideVehicle() || player.getVelocity().getY() > 0.0D) { return; } + + // During world transfers many events of same location get sent, ignore them all + if(event.getFrom().getX() == event.getTo().getX() && event.getFrom().getZ() == event.getTo().getZ() && event.getFrom().getY() == event.getTo().getY()) { + return; + } // Get the player-specific data SpeedhackData data = SpeedhackData.get(player); diff --git a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java index 983586b8..2655849b 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java +++ b/src/cc/co/evenprime/bukkit/nocheat/data/MovingData.java @@ -29,8 +29,9 @@ public class MovingData { public double sneakingLastDistance = 0.0D; public double swimmingLastDistance = 0.0D; - public int worldChanged = 0; + public boolean worldChanged = false; public boolean respawned = false; + public boolean insideVehicle = false; // WORKAROUND for changed PLAYER_MOVE logic public Location teleportTo = null; diff --git a/src/cc/co/evenprime/bukkit/nocheat/listeners/MovingPlayerMonitor.java b/src/cc/co/evenprime/bukkit/nocheat/listeners/MovingPlayerMonitor.java index b0ea83bb..6e29e31e 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/listeners/MovingPlayerMonitor.java +++ b/src/cc/co/evenprime/bukkit/nocheat/listeners/MovingPlayerMonitor.java @@ -39,10 +39,12 @@ public class MovingPlayerMonitor extends PlayerListener { @Override public void onPlayerMove(PlayerMoveEvent event) { - if(!event.isCancelled() && !event.getPlayer().isInsideVehicle()) { + if(!event.isCancelled()) { MovingData data = MovingData.get(event.getPlayer()); data.lastLocation = event.getTo(); - + if(!event.getPlayer().isInsideVehicle()) { + data.insideVehicle = false; + } check.updateVelocity(event.getPlayer().getVelocity(), data); } } diff --git a/src/cc/co/evenprime/bukkit/nocheat/wizard/Wizard.java b/src/cc/co/evenprime/bukkit/nocheat/wizard/Wizard.java index 2d3c226f..2b78b0fe 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/wizard/Wizard.java +++ b/src/cc/co/evenprime/bukkit/nocheat/wizard/Wizard.java @@ -47,9 +47,6 @@ public class Wizard extends JFrame { @Override public void actionPerformed(ActionEvent arg0) { - String s = config.getRoot().toYAMLString(""); - - NoCheatConfiguration.writeConfigFile(new File("NoCheat/nocheat.yml"), config); diff --git a/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ParentOptionGui.java b/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ParentOptionGui.java index 876502a2..738749cf 100644 --- a/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ParentOptionGui.java +++ b/src/cc/co/evenprime/bukkit/nocheat/wizard/gui/ParentOptionGui.java @@ -3,6 +3,7 @@ package cc.co.evenprime.bukkit.nocheat.wizard.gui; import java.awt.Color; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.LinkedList; @@ -12,6 +13,7 @@ import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; @@ -119,8 +121,8 @@ public class ParentOptionGui extends JPanel { c.gridx = 0; c.gridy = line; - c.gridwidth = 3; // Spans over three columns - if(this.option.isEditable()) c.gridwidth = 4; // Spans over four columns + c.gridwidth = 4; // Spans over three columns + if(this.option.isEditable()) c.gridwidth = 5; // Spans over four columns c.anchor = GridBagConstraints.WEST; c.ipadx = 5; c.ipady = 15; @@ -142,7 +144,7 @@ public class ParentOptionGui extends JPanel { this.add(new JLabel(child.getIdentifier() + ":"), c); - c.gridx = 1; + c.gridx++; c.gridy = line; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; @@ -153,8 +155,32 @@ public class ParentOptionGui extends JPanel { JComponent tmp = ChildOptionGuiFactory.create((ChildOption)child); this.add(tmp, c); + /* + c.gridx++; + c.gridy = line; + c.gridwidth = 1; + c.anchor = GridBagConstraints.CENTER; + c.ipadx = 0; + c.insets = new Insets(0, 5, 0, 5); + c.weightx = 0; + + JButton help = new JButton("?"); + + help.addActionListener(new ActionListener() { - c.gridx = 2; + @Override + public void actionPerformed(ActionEvent arg0) { + + JOptionPane.showMessageDialog(null, "get help", "help is here", JOptionPane.INFORMATION_MESSAGE); + + } + + }); + + help.setMargin(new Insets(0, 0, 0, 0)); + this.add(help, c);*/ + + c.gridx++; c.gridy = line; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; @@ -165,7 +191,7 @@ public class ParentOptionGui extends JPanel { this.add(Box.createHorizontalGlue(), c); if(this.option.isEditable()) { - c.gridx = 3; + c.gridx++; c.gridy = line; c.gridwidth = 1; c.anchor = GridBagConstraints.WEST; @@ -185,7 +211,6 @@ public class ParentOptionGui extends JPanel { this.add(removeButton, c); } - } }