mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
50 lines
2.4 KiB
Diff
50 lines
2.4 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Joseph Hirschfeld <joe@ibj.io>
|
||
|
Date: Mon, 22 Feb 2016 16:05:32 -0500
|
||
|
Subject: [PATCH] Add velocity warnings
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||
|
@@ -0,0 +0,0 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
|
||
|
import org.bukkit.permissions.ServerOperator;
|
||
|
import org.bukkit.plugin.Plugin;
|
||
|
import org.bukkit.util.Vector;
|
||
|
+import org.github.paperspigot.PaperSpigotConfig;
|
||
|
|
||
|
public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||
|
private static final PermissibleBase perm = new PermissibleBase(new ServerOperator() {
|
||
|
@@ -0,0 +0,0 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||
|
}
|
||
|
|
||
|
public void setVelocity(Vector vel) {
|
||
|
+ // Paper start - warn server owners when plugins try to set super high velocities
|
||
|
+ if (PaperSpigotConfig.warnForExcessiveVelocity) {
|
||
|
+ if(vel.getX() > 4 || vel.getX() < -4 || vel.getY() > 4 || vel.getY() < -4 || vel.getZ() > 4 || vel.getZ() < -4) {
|
||
|
+ getServer().getLogger().warning("Excessive velocity set detected: tried to set velocity of entity #"+getEntityId()+" to ("+vel.getX()+","+vel.getY()+","+vel.getZ()+").");
|
||
|
+ Thread.dumpStack();
|
||
|
+ }
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
+
|
||
|
entity.motX = vel.getX();
|
||
|
entity.motY = vel.getY();
|
||
|
entity.motZ = vel.getZ();
|
||
|
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||
|
--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
||
|
+++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
|
||
|
@@ -0,0 +0,0 @@ public class PaperSpigotConfig
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
+
|
||
|
+ public static boolean warnForExcessiveVelocity;
|
||
|
+ private static void excessiveVelocityWarning()
|
||
|
+ {
|
||
|
+ warnForExcessiveVelocity = getBoolean("warnWhenSettingExcessiveVelocity", true);
|
||
|
+ }
|
||
|
}
|
||
|
--
|