aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJoseph Hirschfeld <[email protected]>2016-02-22 21:31:24 -0600
committerZach Brown <[email protected]>2016-02-22 21:31:56 -0600
commitc04cff4f82d5fdca22c33d7ece826bc06b06871d (patch)
treec24fbb986b05ffe3627e4d535f19667dbfc51e4c
parent1182e4135162a35a9e5023e1f7383caa76757c1c (diff)
downloadPaper-c04cff4f82d5fdca22c33d7ece826bc06b06871d.tar.gz
Paper-c04cff4f82d5fdca22c33d7ece826bc06b06871d.zip
Add velocity warnings
Issues #12 & #18
-rw-r--r--Spigot-Server-Patches/0098-Add-velocity-warnings.patch52
1 files changed, 52 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0098-Add-velocity-warnings.patch b/Spigot-Server-Patches/0098-Add-velocity-warnings.patch
new file mode 100644
index 0000000000..22366066f3
--- /dev/null
+++ b/Spigot-Server-Patches/0098-Add-velocity-warnings.patch
@@ -0,0 +1,52 @@
+From 34a2d7adb137bd4481b238bc5a80aaf0cbbbc7db Mon Sep 17 00:00:00 2001
+From: Joseph Hirschfeld <[email protected]>
+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 5df3476..4f91799 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+@@ -25,6 +25,7 @@ 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() {
+@@ -205,6 +206,15 @@ 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 ea5a427..d6d9899 100644
+--- a/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
++++ b/src/main/java/org/github/paperspigot/PaperSpigotConfig.java
+@@ -216,4 +216,10 @@ public class PaperSpigotConfig
+ e.printStackTrace();
+ }
+ }
++
++ public static boolean warnForExcessiveVelocity;
++ private static void excessiveVelocityWarning()
++ {
++ warnForExcessiveVelocity = getBoolean("warnWhenSettingExcessiveVelocity", true);
++ }
+ }
+--
+2.7.1
+