Files
Purpur/patches/server/0085-Add-option-to-teleport-to-spawn-if-outside-world-bor.patch
BillyGalbreath d93887a156 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
5b20df6bf added PlayerNameEntityEvent
ff9c82444 Add worldborder events
616b1f3cd consider enchants for destroy speed
aaef1d5cc fix file conversion
674d8f7f7 Make discovered maps config work in treasure maps from loot tables too
be1687914 stop firing pressure plate EntityInteractEvent for ignored entities (fixes #4962)
7d56f38ed Do not use the bukkit singleton for the GUI (Fixes #5301)
4c9bdf53a Updated Upstream (Bukkit/CraftBukkit/Spigot) (#5299)
8647bd130 Improve ServerGUI
fcc6d3359 Throw proper exception on empty JsonList file
17d2e1291 Fix interact event in adventure mode
964e0bf42 MC-29274: Fix Wither hostility towards players
9e24a5213 Fixed furnace cook-speed multiplier losing precision when calculating cook time
c7e42faa3 Do not create unnecessary copies of the passenger list
40881ad67 added tnt minecarts to the tnt height nerf
26be708f4 Remove streams from SensorNearest
5b5989b21 fix nullability of playerlist header/footer, closes #5290
45bc531dd Fix Material#getTranslationKey for Block Materials (#5294)
2021-03-04 21:45:44 -06:00

66 lines
3.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Mon, 13 Jul 2020 11:40:00 -0500
Subject: [PATCH] Add option to teleport to spawn if outside world border
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 8bc0fb58ef18ce7828451857a97460bbde567c6b..a8cd7f0abf58e69d276e469bd7d5ef6ae619263d 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -281,6 +281,7 @@ public abstract class EntityLiving extends Entity {
double d1 = this.world.getWorldBorder().getDamageAmount();
if (d1 > 0.0D) {
+ if (world.purpurConfig.teleportIfOutsideBorder && this instanceof EntityPlayer) { ((EntityPlayer) this).teleport(MCUtil.toLocation(world, world.getSpawn())); return; } // Purpur
this.damageEntity(DamageSource.STUCK, (float) Math.max(1, MathHelper.floor(-d0 * d1)));
}
}
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 56d8ad52abfcedffc0baebba9e250177fce7153b..fcf8f988c1dbc7798e3c1b837de33b3049b33a2f 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -2414,4 +2414,26 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
return (CraftPlayer) super.getBukkitEntity();
}
// CraftBukkit end
+
+ // Purpur start
+ public void teleport(Location to) {
+ this.ejectPassengers();
+ this.stopRiding(true);
+
+ if (this.isSleeping()) {
+ this.wakeup(true, false);
+ }
+
+ if (this.activeContainer != this.defaultContainer) {
+ this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT);
+ }
+
+ WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();
+ if (this.world == toWorld) {
+ this.playerConnection.teleport(to);
+ } else {
+ this.server.getPlayerList().moveToWorld(this, toWorld, true, to, !toWorld.paperConfig.disableTeleportationSuffocationCheck);
+ }
+ }
+ // Purpur end
}
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 2e3fee6bc4f3af7ad07a0db5657ffb3238e77e96..5d35651f43de81c8cf047479ad9c88c4b3f1c38c 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -196,6 +196,11 @@ public class PurpurWorldConfig {
playerInvulnerableWhileAcceptingResourcePack = getBoolean("gameplay-mechanics.player.invulnerable-while-accepting-resource-pack", playerInvulnerableWhileAcceptingResourcePack);
}
+ public boolean teleportIfOutsideBorder = false;
+ private void teleportIfOutsideBorder() {
+ teleportIfOutsideBorder = getBoolean("gameplay-mechanics.player.teleport-if-outside-border", teleportIfOutsideBorder);
+ }
+
public boolean silkTouchEnabled = false;
public String silkTouchSpawnerName = "Spawner";
public List<String> silkTouchSpawnerLore = new ArrayList<>();