2017-03-25 05:22:02 +00:00
|
|
|
From 836675371c732b2c7d7977874436f4f5b20dece0 Mon Sep 17 00:00:00 2001
|
2016-02-29 23:09:49 +00:00
|
|
|
From: Joseph Hirschfeld <joe@ibj.io>
|
|
|
|
Date: Thu, 3 Mar 2016 02:48:12 -0600
|
|
|
|
Subject: [PATCH] Add velocity warnings
|
|
|
|
|
|
|
|
|
2017-01-08 22:43:08 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
2017-03-25 05:22:02 +00:00
|
|
|
index 03bc0171b..c61752bc3 100644
|
2017-01-08 22:43:08 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
|
|
@@ -173,6 +173,7 @@ public final class CraftServer implements Server {
|
|
|
|
private final UUID invalidUserUUID = UUID.nameUUIDFromBytes("InvalidUsername".getBytes(Charsets.UTF_8));
|
|
|
|
private final List<CraftPlayer> playerView;
|
|
|
|
public int reloadCount;
|
|
|
|
+ public static Exception excessiveVelEx; // Paper - Velocity warnings
|
|
|
|
|
|
|
|
private final class BooleanWrapper {
|
|
|
|
private boolean value = true;
|
2016-02-29 23:09:49 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2017-03-25 05:22:02 +00:00
|
|
|
index 6497905b9..463289199 100644
|
2016-02-29 23:09:49 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
2017-01-08 22:43:08 +00:00
|
|
|
@@ -229,6 +229,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
2016-02-29 23:09:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setVelocity(Vector vel) {
|
|
|
|
+ // Paper start - Warn server owners when plugins try to set super high velocities
|
2016-04-17 18:32:19 +00:00
|
|
|
+ if (!(this instanceof org.bukkit.entity.Projectile) && (vel.getX() > 4 || vel.getX() < -4 || vel.getY() > 4 || vel.getY() < -4 || vel.getZ() > 4 || vel.getZ() < -4)) {
|
2017-01-08 22:43:08 +00:00
|
|
|
+ CraftServer.excessiveVelEx = new Exception("Excessive velocity set detected: tried to set velocity of entity #" + getEntityId() + " to (" + vel.getX() + "," + vel.getY() + "," + vel.getZ() + ").");
|
2016-02-29 23:09:49 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
entity.motX = vel.getX();
|
|
|
|
entity.motY = vel.getY();
|
|
|
|
entity.motZ = vel.getZ();
|
2017-01-08 22:43:08 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
2017-03-25 05:22:02 +00:00
|
|
|
index 3ed983cc0..6384d50e7 100644
|
2017-01-08 22:43:08 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
|
|
@@ -66,7 +66,19 @@ public class WatchdogThread extends Thread
|
|
|
|
log.log( Level.SEVERE, "During the run of the server, a physics stackoverflow was supressed" );
|
|
|
|
log.log( Level.SEVERE, "near " + net.minecraft.server.World.blockLocation);
|
|
|
|
}
|
|
|
|
- //
|
|
|
|
+ // Paper start - Warn in watchdog if an excessive velocity was ever set
|
|
|
|
+ if ( org.bukkit.craftbukkit.CraftServer.excessiveVelEx != null )
|
|
|
|
+ {
|
|
|
|
+ log.log( Level.SEVERE, "------------------------------" );
|
|
|
|
+ log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" );
|
|
|
|
+ log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" );
|
|
|
|
+ log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
|
|
|
|
+ for ( StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace() )
|
|
|
|
+ {
|
|
|
|
+ log.log( Level.SEVERE, "\t\t" + stack );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
log.log( Level.SEVERE, "------------------------------" );
|
|
|
|
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" );
|
|
|
|
dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().primaryThread.getId(), Integer.MAX_VALUE ), log );
|
2016-02-29 23:09:49 +00:00
|
|
|
--
|
2017-03-25 05:22:02 +00:00
|
|
|
2.12.0.windows.1
|
2016-02-29 23:09:49 +00:00
|
|
|
|