2016-10-21 23:08:34 +02:00
|
|
|
From 55150e10ff8e9ecfc60e5f3fe405b2e198ac923a Mon Sep 17 00:00:00 2001
|
2016-04-13 08:11:40 +02:00
|
|
|
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
|
2016-09-15 23:36:57 +02:00
|
|
|
index 1b9c852..a3f4c1f 100644
|
2016-04-13 08:11:40 +02:00
|
|
|
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
2016-09-11 04:42:47 +02:00
|
|
|
@@ -210,4 +210,9 @@ public class PaperConfig {
|
2016-04-13 08:11:40 +02:00
|
|
|
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);
|
|
|
|
+ }
|
|
|
|
}
|
2016-09-15 23:36:57 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/CommandScoreboard.java b/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
|
|
index 8e5419d..64a3495 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/CommandScoreboard.java
|
|
|
|
@@ -182,6 +182,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);
|
|
|
|
}
|
|
|
|
}
|
2016-09-05 00:29:25 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2016-10-21 22:42:49 +02:00
|
|
|
index e35341b..01325b3 100644
|
2016-09-05 00:29:25 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2016-09-15 23:36:57 +02:00
|
|
|
@@ -324,6 +324,14 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
|
2016-09-05 00:29:25 +02:00
|
|
|
this.v.setPlayerFileData(this.worldServer);
|
|
|
|
this.a(this.getDifficulty());
|
|
|
|
this.l();
|
|
|
|
+
|
|
|
|
+ // Paper start - Handle collideRule team for player collision toggle
|
|
|
|
+ if (!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions) {
|
|
|
|
+ this.getPlayerList().collideRuleTeamName = org.apache.commons.lang3.StringUtils.left("collideRule_" + this.getWorld().random.nextInt(), 16);
|
2016-09-15 23:36:57 +02:00
|
|
|
+ ScoreboardTeam collideTeam = this.getWorld().getScoreboard().createTeam(this.getPlayerList().collideRuleTeamName);
|
|
|
|
+ collideTeam.setCanSeeFriendlyInvisibles(false); // Because we want to mimic them not being on a team at all
|
2016-09-05 00:29:25 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void l() {
|
2016-04-13 08:11:40 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java b/src/main/java/net/minecraft/server/PacketPlayOutScoreboardTeam.java
|
2016-06-09 05:57:14 +02:00
|
|
|
index d8ec504..eb45d3c 100644
|
2016-04-13 08:11:40 +02:00
|
|
|
--- 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);
|
|
|
|
}
|
|
|
|
|
2016-09-05 00:29:25 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
2016-10-21 22:42:49 +02:00
|
|
|
index d26da3a..eb846cf 100644
|
2016-09-05 00:29:25 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
2016-10-21 22:42:49 +02:00
|
|
|
@@ -68,6 +68,7 @@ public abstract class PlayerList {
|
2016-09-05 00:29:25 +02:00
|
|
|
// 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);
|
2016-10-21 22:42:49 +02:00
|
|
|
@@ -235,6 +236,12 @@ public abstract class PlayerList {
|
2016-09-05 00:29:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
entityplayer.syncInventory();
|
|
|
|
+ // Paper start - Add to collideRule team if needed
|
2016-09-08 19:39:40 +02:00
|
|
|
+ final Scoreboard scoreboard = this.getServer().getWorld().getScoreboard();
|
|
|
|
+ if (this.collideRuleTeamName != null && scoreboard.getTeam(collideRuleTeamName) != null && entityplayer.getTeam() == null) {
|
|
|
|
+ scoreboard.addPlayerToTeam(entityplayer.getName(), collideRuleTeamName);
|
2016-09-05 00:29:25 +02:00
|
|
|
+ }
|
|
|
|
+ // 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 + ")");
|
|
|
|
}
|
2016-10-21 22:42:49 +02:00
|
|
|
@@ -405,6 +412,16 @@ public abstract class PlayerList {
|
2016-09-05 00:29:25 +02:00
|
|
|
entityplayer.k_();// SPIGOT-924 // PAIL: rename - playerTick
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
+ // Paper start - Remove from collideRule team if needed
|
|
|
|
+ if (this.collideRuleTeamName != null) {
|
2016-09-08 19:39:40 +02:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2016-09-05 00:29:25 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
this.savePlayerFile(entityplayer);
|
|
|
|
if (entityplayer.isPassenger()) {
|
|
|
|
Entity entity = entityplayer.getVehicle();
|
2016-10-21 22:42:49 +02:00
|
|
|
@@ -1304,7 +1321,13 @@ public abstract class PlayerList {
|
2016-09-06 19:33:47 +02:00
|
|
|
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) {
|
2016-09-08 19:39:40 +02:00
|
|
|
+ final Scoreboard scoreboard = this.getServer().getWorld().getScoreboard();
|
|
|
|
+ final ScoreboardTeam team = scoreboard.getTeam(this.collideRuleTeamName);
|
2016-09-06 19:33:47 +02:00
|
|
|
+ if (team != null) scoreboard.removeTeam(team);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2016-04-13 08:11:40 +02:00
|
|
|
--
|
2016-10-21 22:28:44 +02:00
|
|
|
2.9.3
|
2016-04-13 08:11:40 +02:00
|
|
|
|