Paper/Spigot-Server-Patches/0102-Configurable-Player-Collision.patch
Zach Brown a2ad49b22f
Update upstream BD/B/CB/S
Note to other developers: This commit may require you to wipe your
workspace as a result of the changes to BD.

--- work/BuildData
Submodule work/BuildData f527a8ff..d56672db:
  > Mappings Update

--- work/Bukkit
Submodule work/Bukkit 0c1d258bb..db06c80d7:
  > Add list of entities to EntityTransformEvent
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks

---work/CraftBukkit
Submodule work/CraftBukkit 6a398ac44..068dab5be:
  > Enable optional source JAR shading via profile shadeSourcesJar
  > Use ImmutableList rather than AbstractList for CraftMetaBook
  > Fix setRecipes(List) not setting Knowledge Book recipes.
  > Mappings Update
  > Add list of entities to EntityTransformEvent & move die calls
  > SPIGOT-4347: Add API to allow storing arbitrary values on ItemStacks
  > Add Vanilla help to default permissions

--- work/Spigot
Submodule work/Spigot a1f2566f6..e769fe4d9:
  > Mappings Update
  > Rebuild patches
2018-12-08 05:09:55 -05:00

119 lines
6.3 KiB
Diff

From deefbc94ab507f4a70b73a4006ece70e4e9c657f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 13 Apr 2016 02:10:49 -0400
Subject: [PATCH] Configurable Player Collision
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index b4dba7247..1d32b93c8 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -233,4 +233,9 @@ public class PaperConfig {
private static void regionFileCacheSize() {
regionFileCacheSize = getInt("settings.region-file-cache-size", 256);
}
+
+ public static boolean enablePlayerCollisions = true;
+ private static void enablePlayerCollisions() {
+ enablePlayerCollisions = getBoolean("settings.enable-player-collisions", true);
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 7793626b5..bdd2c4b85 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -425,6 +425,19 @@ public abstract class MinecraftServer implements IAsyncTaskHandler, IMojangStati
this.a(this.getWorldServer(DimensionManager.OVERWORLD).worldMaps);
// CraftBukkit end
+ // Paper start - Handle collideRule team for player collision toggle
+ final Scoreboard scoreboard = this.getScoreboard();
+ final java.util.Collection<String> toRemove = scoreboard.getTeams().stream().filter(team -> team.getName().startsWith("collideRule_")).map(ScoreboardTeam::getName).collect(java.util.stream.Collectors.toList());
+ for (String teamName : toRemove) {
+ scoreboard.removeTeam(scoreboard.getTeam(teamName)); // Clean up after ourselves
+ }
+
+ if (!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions) {
+ this.getPlayerList().collideRuleTeamName = org.apache.commons.lang3.StringUtils.left("collideRule_" + java.util.concurrent.ThreadLocalRandom.current().nextInt(), 16);
+ ScoreboardTeam collideTeam = scoreboard.createTeam(this.getPlayerList().collideRuleTeamName);
+ collideTeam.setCanSeeFriendlyInvisibles(false); // Because we want to mimic them not being on a team at all
+ }
+ // Paper end
}
protected void a(File file, WorldData worlddata) {
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
index f7a9b9d88..7befd80cf 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
@@ -92,7 +92,7 @@ public class PacketPlayOutScoreboardTeam implements Packet<PacketListenerPlayOut
packetdataserializer.a(this.b);
packetdataserializer.writeByte(this.j);
packetdataserializer.a(this.e);
- packetdataserializer.a(this.f);
+ packetdataserializer.a(!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions ? "never" : this.f); // Paper
packetdataserializer.a((Enum)this.g);
packetdataserializer.a(this.c);
packetdataserializer.a(this.d);
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index 2cb5869ae..143c7c1be 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -74,6 +74,7 @@ public abstract class PlayerList {
// CraftBukkit start
private CraftServer cserver;
private final Map<String,EntityPlayer> playersByName = new org.spigotmc.CaseInsensitiveMap<EntityPlayer>();
+ @Nullable String collideRuleTeamName; // Paper - Team name used for collideRule
public PlayerList(MinecraftServer minecraftserver) {
this.cserver = minecraftserver.server = new CraftServer(minecraftserver, this);
@@ -231,6 +232,13 @@ public abstract class PlayerList {
}
entityplayer.syncInventory();
+ // Paper start - Add to collideRule team if needed
+ final Scoreboard scoreboard = this.getServer().getWorldServer(DimensionManager.OVERWORLD).getScoreboard();
+ final ScoreboardTeam collideRuleTeam = scoreboard.getTeam(collideRuleTeamName);
+ if (this.collideRuleTeamName != null && collideRuleTeam != null && entityplayer.getTeam() == null) {
+ scoreboard.addPlayerToTeam(entityplayer.getName(), collideRuleTeam);
+ }
+ // Paper end
// CraftBukkit - Moved from above, added world
PlayerList.f.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.world.worldData.getName(), entityplayer.locX, entityplayer.locY, entityplayer.locZ);
}
@@ -424,6 +432,16 @@ public abstract class PlayerList {
entityplayer.playerTick();// SPIGOT-924
// CraftBukkit end
+ // Paper start - Remove from collideRule team if needed
+ if (this.collideRuleTeamName != null) {
+ final Scoreboard scoreBoard = this.server.getWorldServer(DimensionManager.OVERWORLD).getScoreboard();
+ final ScoreboardTeam team = scoreBoard.getTeam(this.collideRuleTeamName);
+ if (entityplayer.getTeam() == team && team != null) {
+ scoreBoard.removePlayerFromTeam(entityplayer.getName(), team);
+ }
+ }
+ // Paper end
+
this.savePlayerFile(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -1306,7 +1324,13 @@ public abstract class PlayerList {
player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
}
// CraftBukkit end
-
+ // Paper start - Remove collideRule team if it exists
+ if (this.collideRuleTeamName != null) {
+ final Scoreboard scoreboard = this.getServer().getWorldServer(DimensionManager.OVERWORLD).getScoreboard();
+ final ScoreboardTeam team = scoreboard.getTeam(this.collideRuleTeamName);
+ if (team != null) scoreboard.removeTeam(team);
+ }
+ // Paper end
}
// CraftBukkit start
--
2.19.2