aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0447-Restrict-vanilla-teleport-command-to-valid-locations.patch
blob: ed7ce57a14322470631b44343ec7286156bcff67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach@zachbr.io>
Date: Thu, 16 Apr 2020 20:07:29 -0500
Subject: [PATCH] Restrict vanilla teleport command to valid locations

Fixes GH-3165, GH-3575

diff --git a/src/main/java/net/minecraft/server/commands/CommandTeleport.java b/src/main/java/net/minecraft/server/commands/CommandTeleport.java
index b59763643def065cd998fa3005523c37973613fd..dcc92b0c9a7a0214a3e803d714c5e7078c17a039 100644
--- a/src/main/java/net/minecraft/server/commands/CommandTeleport.java
+++ b/src/main/java/net/minecraft/server/commands/CommandTeleport.java
@@ -142,6 +142,12 @@ public class CommandTeleport {
 
     private static void a(CommandListenerWrapper commandlistenerwrapper, Entity entity, WorldServer worldserver, double d0, double d1, double d2, Set<PacketPlayOutPosition.EnumPlayerTeleportFlags> set, float f, float f1, @Nullable CommandTeleport.a commandteleport_a) throws CommandSyntaxException {
         BlockPosition blockposition = new BlockPosition(d0, d1, d2);
+        // Paper start - Don't allow teleport command to invalid locations
+        if (d0 <= -30000000 || d2 <= -30000000 || d0 > 30000000 || d2 > 30000000 || d1 > 30000000 || d1 <= -30000000) { // Copy/pasta from BaseBlockPosition#isValidLocation
+            org.bukkit.Bukkit.getLogger().warning("Refused to teleport " + entity.getName() + " to " + d0 + ", " + d1 + ", " + d2);
+            return;
+        }
+        // Paper end
 
         if (!World.l(blockposition)) {
             throw CommandTeleport.a.create();