Potential fix for World<->Nether teleports

Potential fix for Vehicle destruction problems
This commit is contained in:
Evenprime 2011-06-12 11:35:03 +02:00
parent 2c8de34864
commit 84c8e98054
7 changed files with 52 additions and 26 deletions

View File

@ -3,7 +3,7 @@ name: NoCheat
author: Evenprime
main: cc.co.evenprime.bukkit.nocheat.NoCheat
version: 1.03
version: 1.04
softdepend: [ Permissions, CraftIRC ]

View File

@ -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());
}
}

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);
}
}
}