Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
835bc39b03
Updated Upstream (Bukkit/CraftBukkit/Spigot) Bukkit Changes: 2dcc44dc SPIGOT-4307: Fix hacky API for banners on shields e0fc6572 SPIGOT-4309: Add "forced" display of particles efeeab2f Add index to README.md for easier navigation f502bc6f Update to Minecraft 1.13.1 CraftBukkit Changes:d0bb0a1d
Fix some tests randomly failing997d378d
Fix client stall in specific teleportation scenariosb3dc2366
SPIGOT-4307: Fix hacky API for banners on shields2a271162
SPIGOT-4301: Fix more invalid enchants5d0d83bb
SPIGOT-4309: Add "forced" display of particlesa6772578
Add additional tests for CraftBlockDatace1af0c3
Update to Minecraft 1.13.1 Spigot Changes: 2440e189 Rebuild patches 4ecffced Update to Minecraft 1.13.1
96 Zeilen
4.7 KiB
Diff
96 Zeilen
4.7 KiB
Diff
From 3adf13e17f92b08fbb27e257a72a0b0627ce6a89 Mon Sep 17 00:00:00 2001
|
|
From: Joseph Hirschfeld <joe@ibj.io>
|
|
Date: Thu, 3 Mar 2016 02:48:12 -0600
|
|
Subject: [PATCH] Add velocity warnings
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index 6a7bdb9ab6..bd99aa72c4 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -192,6 +192,7 @@ public final class CraftServer implements Server {
|
|
public boolean ignoreVanillaPermissions = false;
|
|
private final List<CraftPlayer> playerView;
|
|
public int reloadCount;
|
|
+ public static Exception excessiveVelEx; // Paper - Velocity warnings
|
|
|
|
private final class BooleanWrapper {
|
|
private boolean value = true;
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
index 249d8115e8..dedf1526e6 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
|
@@ -262,12 +262,44 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|
public void setVelocity(Vector velocity) {
|
|
Preconditions.checkArgument(velocity != null, "velocity");
|
|
velocity.checkFinite();
|
|
+
|
|
+ // Paper start - Warn server owners when plugins try to set super high velocities
|
|
+ if (!(this instanceof org.bukkit.entity.Projectile) && isUnsafeVelocity(velocity)) {
|
|
+ CraftServer.excessiveVelEx = new Exception("Excessive velocity set detected: tried to set velocity of entity " + entity.getName() + " id #" + getEntityId() + " to (" + velocity.getX() + "," + velocity.getY() + "," + velocity.getZ() + ").");
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
entity.motX = velocity.getX();
|
|
entity.motY = velocity.getY();
|
|
entity.motZ = velocity.getZ();
|
|
entity.velocityChanged = true;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ /**
|
|
+ * Checks if the given velocity is not necessarily safe in all situations.
|
|
+ * This function returning true does not mean the velocity is dangerous or to be avoided, only that it may be
|
|
+ * a detriment to performance on the server.
|
|
+ *
|
|
+ * It is not to be used as a hard rule of any sort.
|
|
+ * Paper only uses it to warn server owners in watchdog crashes.
|
|
+ *
|
|
+ * @param vel incoming velocity to check
|
|
+ * @return if the velocity has the potential to be a performance detriment
|
|
+ */
|
|
+ private static boolean isUnsafeVelocity(Vector vel) {
|
|
+ final double x = vel.getX();
|
|
+ final double y = vel.getY();
|
|
+ final double z = vel.getZ();
|
|
+
|
|
+ if (x > 4 || x < -4 || y > 4 || y < -4 || z > 4 || z < -4) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public double getHeight() {
|
|
return getHandle().length;
|
|
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
|
index 91b8aa6a16..0c106ea9c5 100644
|
|
--- 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 );
|
|
--
|
|
2.18.0
|
|
|