Always cleanup collideRule teams at startup

Fixes GH-463
This commit is contained in:
Zach Brown 2016-11-05 13:34:18 -05:00
parent 1e1de2ffa8
commit d7276f6ffd
No known key found for this signature in database
GPG key ID: CC9DA35FC5450B76
4 changed files with 23 additions and 17 deletions

View file

@ -1,4 +1,4 @@
From 55150e10ff8e9ecfc60e5f3fe405b2e198ac923a Mon Sep 17 00:00:00 2001
From b422187190500a2c81f4ef240839151357180fae 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
@ -37,18 +37,24 @@ index 8e5419d..64a3495 100644
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index e35341b..01325b3 100644
index e35341b..01044c8 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -324,6 +324,14 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -324,6 +324,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 = this.getWorld().getScoreboard().createTeam(this.getPlayerList().collideRuleTeamName);
+ 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
@ -69,7 +75,7 @@ index d8ec504..eb45d3c 100644
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
index d26da3a..eb846cf 100644
index e044c40..0661974 100644
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -68,6 +68,7 @@ public abstract class PlayerList {
@ -126,5 +132,5 @@ index d26da3a..eb846cf 100644
// CraftBukkit start
--
2.9.3
2.10.2

View file

@ -1,4 +1,4 @@
From 26895c2866c74f0e2c1c9c8972c0f7270513b667 Mon Sep 17 00:00:00 2001
From 4b3a97b25bd70dbc2b2e96bcbbd77177ef7d9f60 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 28 Apr 2016 00:57:27 -0400
Subject: [PATCH] remove null possibility for getServer singleton
@ -6,7 +6,7 @@ Subject: [PATCH] remove null possibility for getServer singleton
to stop IDE complaining about potential NPE
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 01325b3..9455475 100644
index 01044c8..9348ae7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -49,6 +49,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
@ -25,7 +25,7 @@ index 01325b3..9455475 100644
io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
this.e = proxy;
this.U = yggdrasilauthenticationservice;
@@ -1603,7 +1605,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -1609,7 +1611,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// CraftBukkit start
@Deprecated
public static MinecraftServer getServer() {
@ -35,5 +35,5 @@ index 01325b3..9455475 100644
// CraftBukkit end
}
--
2.9.3
2.10.2

View file

@ -1,4 +1,4 @@
From 763ff325102685fbab2b700723e50c07de30dc02 Mon Sep 17 00:00:00 2001
From ea4d053f5b63ae0f7b6a1cfc4b375eced1f7b47e Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 16 May 2016 20:47:41 -0400
Subject: [PATCH] Optimize UserCache / Thread Safe
@ -10,10 +10,10 @@ Additionally, move Saving of the User cache to be done async, incase
the user never changed the default setting for Spigot's save on stop only.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 9455475..a4f7e4d 100644
index 9348ae7..807ec58 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -508,7 +508,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -514,7 +514,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// Spigot start
if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
LOGGER.info("Saving usercache.json");
@ -96,5 +96,5 @@ index ccfc755..989758c 100644
}
--
2.9.3
2.10.2

View file

@ -1,4 +1,4 @@
From 62796acb6d14f2865b036decbdef62089e4870a1 Mon Sep 17 00:00:00 2001
From 7009c675aa0448da9b79227a32c72afccfaf79c4 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 19 Sep 2016 23:16:39 -0400
Subject: [PATCH] Auto Save Improvements
@ -80,7 +80,7 @@ index 3828da7..7e53fee 100644
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index a4f7e4d..fb06496 100644
index 807ec58..b398ef1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -114,6 +114,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@ -91,7 +91,7 @@ index a4f7e4d..fb06496 100644
// CraftBukkit end
public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
@@ -745,22 +746,26 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -751,22 +752,26 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.q.b().a(agameprofile);
}