150 lines
6.5 KiB
Diff
150 lines
6.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
Date: Mon, 10 Apr 2023 07:52:53 -0500
|
|
Subject: [PATCH] Set multiple team settings at once
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/scores/PlayerTeam.java b/src/main/java/net/minecraft/world/scores/PlayerTeam.java
|
|
index 9464054912e19fc78dd965b71fce20a18564b351..1624a0f8ea211a4c43fd01612674ca501c10d7e6 100644
|
|
--- a/src/main/java/net/minecraft/world/scores/PlayerTeam.java
|
|
+++ b/src/main/java/net/minecraft/world/scores/PlayerTeam.java
|
|
@@ -28,6 +28,7 @@ public class PlayerTeam extends Team {
|
|
private ChatFormatting color = ChatFormatting.RESET;
|
|
private Team.CollisionRule collisionRule = Team.CollisionRule.ALWAYS;
|
|
private final Style displayNameStyle;
|
|
+ private boolean updateTeamChangeInstantly = true; // Slice
|
|
|
|
public PlayerTeam(Scoreboard scoreboard, String name) {
|
|
this.scoreboard = scoreboard;
|
|
@@ -36,6 +37,12 @@ public class PlayerTeam extends Team {
|
|
this.displayNameStyle = Style.EMPTY.withInsertion(name).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal(name)));
|
|
}
|
|
|
|
+ // Slice start
|
|
+ public void setUpdateTeamChangeInstantly(boolean updateTeamChangeInstantly) {
|
|
+ this.updateTeamChangeInstantly = updateTeamChangeInstantly;
|
|
+ }
|
|
+ // Slice end
|
|
+
|
|
public Scoreboard getScoreboard() {
|
|
return this.scoreboard;
|
|
}
|
|
@@ -64,13 +71,13 @@ public class PlayerTeam extends Team {
|
|
throw new IllegalArgumentException("Name cannot be null");
|
|
} else {
|
|
this.displayName = displayName;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
}
|
|
|
|
public void setPlayerPrefix(@Nullable Component prefix) {
|
|
this.playerPrefix = prefix == null ? CommonComponents.EMPTY : prefix;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
public Component getPlayerPrefix() {
|
|
@@ -79,7 +86,7 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setPlayerSuffix(@Nullable Component suffix) {
|
|
this.playerSuffix = suffix == null ? CommonComponents.EMPTY : suffix;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
public Component getPlayerSuffix() {
|
|
@@ -113,7 +120,7 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setAllowFriendlyFire(boolean friendlyFire) {
|
|
this.allowFriendlyFire = friendlyFire;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
@Override
|
|
@@ -123,7 +130,7 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setSeeFriendlyInvisibles(boolean showFriendlyInvisible) {
|
|
this.seeFriendlyInvisibles = showFriendlyInvisible;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
@Override
|
|
@@ -138,12 +145,12 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setNameTagVisibility(Team.Visibility nameTagVisibilityRule) {
|
|
this.nameTagVisibility = nameTagVisibilityRule;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
public void setDeathMessageVisibility(Team.Visibility deathMessageVisibilityRule) {
|
|
this.deathMessageVisibility = deathMessageVisibilityRule;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
@Override
|
|
@@ -153,7 +160,7 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setCollisionRule(Team.CollisionRule collisionRule) {
|
|
this.collisionRule = collisionRule;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
public int packOptions() {
|
|
@@ -176,7 +183,7 @@ public class PlayerTeam extends Team {
|
|
|
|
public void setColor(ChatFormatting color) {
|
|
this.color = color;
|
|
- this.scoreboard.onTeamChanged(this);
|
|
+ if (updateTeamChangeInstantly) this.scoreboard.onTeamChanged(this); // Slice
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
index fd86c1d43cccd036f60cb270b56fd33f95707720..9d81ae52f55db1c330ebe2daa2d4008ee9b845c3 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
@@ -341,6 +341,37 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
|
}
|
|
}
|
|
|
|
+ //Slice start
|
|
+ @Override
|
|
+ public void teamOptions(net.kyori.adventure.text.Component displayName,
|
|
+ net.kyori.adventure.text.Component prefix,
|
|
+ net.kyori.adventure.text.Component suffix,
|
|
+ net.kyori.adventure.text.format.NamedTextColor color,
|
|
+ java.util.List<org.apache.commons.lang3.tuple.Pair<Option, OptionStatus>> options) throws IllegalStateException {
|
|
+ checkState();
|
|
+ team.setUpdateTeamChangeInstantly(false);
|
|
+
|
|
+ if (displayName == null) displayName = net.kyori.adventure.text.Component.empty();
|
|
+ team.setDisplayName(io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName));
|
|
+
|
|
+ if (prefix == null) prefix = net.kyori.adventure.text.Component.empty();
|
|
+ team.setPlayerPrefix(io.papermc.paper.adventure.PaperAdventure.asVanilla(prefix));
|
|
+
|
|
+ if (suffix == null) suffix = net.kyori.adventure.text.Component.empty();
|
|
+ team.setPlayerSuffix(io.papermc.paper.adventure.PaperAdventure.asVanilla(suffix));
|
|
+
|
|
+ if (color == null) color = net.kyori.adventure.text.format.NamedTextColor.WHITE;
|
|
+ team.setColor(io.papermc.paper.adventure.PaperAdventure.asVanilla(color));
|
|
+
|
|
+ for (org.apache.commons.lang3.tuple.Pair<Option, OptionStatus> pair : options) {
|
|
+ setOption(pair.getLeft(), pair.getRight());
|
|
+ }
|
|
+
|
|
+ team.setUpdateTeamChangeInstantly(true);
|
|
+ team.getScoreboard().onTeamChanged(team);
|
|
+ }
|
|
+ //Slice end
|
|
+
|
|
// Paper start
|
|
@Override
|
|
public void addEntity(org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException {
|