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 da6e2f40a9
commit f3fd0471f2

View file

@ -46,9 +46,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
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