mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 16:50:17 +01:00
136 lines
7.1 KiB
Diff
136 lines
7.1 KiB
Diff
From fd4bdb80419297c9ba4b02f9f1f6aabe04e0665f 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 6b694705b..ee884ba57 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
@@ -224,4 +224,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/CommandScoreboard.java b/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
index ab9aa132a..f9f59e559 100644
|
|
--- a/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
+++ b/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
@@ -183,6 +183,13 @@ public class CommandScoreboard extends CommandAbstract {
|
|
throw new ExceptionUsage("commands.scoreboard.teams.option.usage", new Object[0]);
|
|
}
|
|
|
|
+ // Paper start - Block setting options on our collideRule team as it is not persistent
|
|
+ if (astring[2].equals(MinecraftServer.getServer().getPlayerList().collideRuleTeamName)) {
|
|
+ icommandlistener.sendMessage(new ChatMessage("You cannot set team options on the collideRule team"));
|
|
+ return;
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
this.c(icommandlistener, astring, 2, minecraftserver);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 33d23f4b2..988439a0a 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -331,6 +331,20 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
|
this.v.setPlayerFileData(this.worldServer);
|
|
this.a(this.getDifficulty());
|
|
this.l();
|
|
+
|
|
+ // Paper start - Handle collideRule team for player collision toggle
|
|
+ final Scoreboard scoreboard = this.getWorld().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_" + this.getWorld().random.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 l() {
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
|
|
index d8ec50455..eb45d3cf2 100644
|
|
--- a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
|
|
+++ b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
|
|
@@ -96,7 +96,7 @@ public class PacketPlayOutScoreboardTeam implements Packet<PacketListenerPlayOut
|
|
packetdataserializer.a(this.d);
|
|
packetdataserializer.writeByte(this.j);
|
|
packetdataserializer.a(this.e);
|
|
- packetdataserializer.a(this.f);
|
|
+ packetdataserializer.a(!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions ? "never" : this.f); // Paper
|
|
packetdataserializer.writeByte(this.g);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
|
index a55a6fca0..be67df061 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
@@ -71,6 +71,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);
|
|
@@ -228,6 +229,12 @@ public abstract class PlayerList {
|
|
}
|
|
|
|
entityplayer.syncInventory();
|
|
+ // Paper start - Add to collideRule team if needed
|
|
+ final Scoreboard scoreboard = this.getServer().getWorld().getScoreboard();
|
|
+ if (this.collideRuleTeamName != null && scoreboard.getTeam(collideRuleTeamName) != null && entityplayer.getTeam() == null) {
|
|
+ scoreboard.addPlayerToTeam(entityplayer.getName(), collideRuleTeamName);
|
|
+ }
|
|
+ // Paper end
|
|
// CraftBukkit - Moved from above, added world
|
|
PlayerList.f.info(entityplayer.getName() + "[" + s1 + "] logged in with entity id " + entityplayer.getId() + " at ([" + entityplayer.world.worldData.getName() + "]" + entityplayer.locX + ", " + entityplayer.locY + ", " + entityplayer.locZ + ")");
|
|
}
|
|
@@ -399,6 +406,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.getWorld().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.getVehicle();
|
|
@@ -1312,7 +1329,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().getWorld().getScoreboard();
|
|
+ final ScoreboardTeam team = scoreboard.getTeam(this.collideRuleTeamName);
|
|
+ if (team != null) scoreboard.removeTeam(team);
|
|
+ }
|
|
+ // Paper end
|
|
}
|
|
|
|
// CraftBukkit start
|
|
--
|
|
2.12.0.windows.1
|
|
|