diff --git a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch index 2db5ba1a18..6228bbaaa2 100644 --- a/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch +++ b/patches/minecraft/net/minecraft/server/players/PlayerList.java.patch @@ -271,7 +271,7 @@ if (compoundtag1.hasUUID("Attach")) { uuid = compoundtag1.getUUID("Attach"); } else { -@@ -239,6 +_,9 @@ +@@ -239,9 +_,12 @@ } p_11263_.initInventoryMenu(); @@ -280,7 +280,11 @@ + LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", p_11263_.getName().getString(), s1, p_11263_.getId(), serverlevel1.serverLevelData.getLevelName(), p_11263_.getX(), p_11263_.getY(), p_11263_.getZ()); } - protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { +- protected void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { ++ public void updateEntireScoreboard(ServerScoreboard p_11274_, ServerPlayer p_11275_) { + Set set = Sets.newHashSet(); + + for(PlayerTeam playerteam : p_11274_.getPlayerTeams()) { @@ -262,25 +_,26 @@ } diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftCriteria.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftCriteria.java index 10627e8375..9fd863a3d1 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftCriteria.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftCriteria.java @@ -2,8 +2,8 @@ import com.google.common.collect.ImmutableMap; import java.util.Map; -import net.minecraft.world.scores.ScoreboardObjective; -import net.minecraft.world.scores.criteria.IScoreboardCriteria; +import net.minecraft.world.scores.Objective; +import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.bukkit.scoreboard.Criteria; import org.bukkit.scoreboard.RenderType; @@ -14,9 +14,9 @@ public final class CraftCriteria implements Criteria { static { ImmutableMap.Builder defaults = ImmutableMap.builder(); - for (Map.Entry entry : IScoreboardCriteria.CRITERIA_CACHE.entrySet()) { + for (Map.Entry entry : ObjectiveCriteria.CRITERIA_CACHE.entrySet()) { String name = entry.getKey(); - IScoreboardCriteria criteria = entry.getValue(); + ObjectiveCriteria criteria = entry.getValue(); defaults.put(name, new CraftCriteria(criteria)); } @@ -25,7 +25,7 @@ public final class CraftCriteria implements Criteria { DUMMY = DEFAULTS.get("dummy"); } - final IScoreboardCriteria criteria; + final ObjectiveCriteria criteria; final String bukkitName; private CraftCriteria(String bukkitName) { @@ -33,7 +33,7 @@ private CraftCriteria(String bukkitName) { this.criteria = DUMMY.criteria; } - private CraftCriteria(IScoreboardCriteria criteria) { + private CraftCriteria(ObjectiveCriteria criteria) { this.criteria = criteria; this.bukkitName = criteria.getName(); } @@ -53,7 +53,7 @@ public RenderType getDefaultRenderType() { return RenderType.values()[criteria.getDefaultRenderType().ordinal()]; } - static CraftCriteria getFromNMS(ScoreboardObjective objective) { + static CraftCriteria getFromNMS(Objective objective) { return DEFAULTS.get(objective.getCriteria().getName()); } @@ -63,7 +63,7 @@ public static CraftCriteria getFromBukkit(String name) { return criteria; } - return IScoreboardCriteria.byName(name).map(CraftCriteria::new).orElseGet(() -> new CraftCriteria(name)); + return ObjectiveCriteria.byName(name).map(CraftCriteria::new).orElseGet(() -> new CraftCriteria(name)); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftObjective.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftObjective.java index 3319dd9ec3..7d3988535d 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftObjective.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftObjective.java @@ -2,7 +2,6 @@ import com.google.common.base.Preconditions; import net.minecraft.world.scores.Scoreboard; -import net.minecraft.world.scores.ScoreboardObjective; import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_20_R2.util.CraftChatMessage; import org.bukkit.scoreboard.Criteria; @@ -12,16 +11,16 @@ import org.bukkit.scoreboard.Score; final class CraftObjective extends CraftScoreboardComponent implements Objective { - private final ScoreboardObjective objective; + private final net.minecraft.world.scores.Objective objective; private final CraftCriteria criteria; - CraftObjective(CraftScoreboard scoreboard, ScoreboardObjective objective) { + CraftObjective(CraftScoreboard scoreboard, net.minecraft.world.scores.Objective objective) { super(scoreboard); this.objective = objective; this.criteria = CraftCriteria.getFromNMS(objective); } - ScoreboardObjective getHandle() { + net.minecraft.world.scores.Objective getHandle() { return objective; } @@ -72,7 +71,7 @@ public boolean isModifiable() { public void setDisplaySlot(DisplaySlot slot) { CraftScoreboard scoreboard = checkState(); Scoreboard board = scoreboard.board; - ScoreboardObjective objective = this.objective; + net.minecraft.world.scores.Objective objective = this.objective; for (net.minecraft.world.scores.DisplaySlot i : net.minecraft.world.scores.DisplaySlot.values()) { if (board.getDisplayObjective(i) == objective) { @@ -89,7 +88,7 @@ public void setDisplaySlot(DisplaySlot slot) { public DisplaySlot getDisplaySlot() { CraftScoreboard scoreboard = checkState(); Scoreboard board = scoreboard.board; - ScoreboardObjective objective = this.objective; + net.minecraft.world.scores.Objective objective = this.objective; for (net.minecraft.world.scores.DisplaySlot i : net.minecraft.world.scores.DisplaySlot.values()) { if (board.getDisplayObjective(i) == objective) { diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScore.java index 8ba741965a..b2ded979a5 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScore.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScore.java @@ -2,8 +2,6 @@ import java.util.Map; import net.minecraft.world.scores.Scoreboard; -import net.minecraft.world.scores.ScoreboardObjective; -import net.minecraft.world.scores.ScoreboardScore; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.scoreboard.Objective; @@ -44,8 +42,8 @@ public int getScore() { Scoreboard board = objective.checkState().board; if (board.getTrackedPlayers().contains(entry)) { // Lazy - Map scores = board.getPlayerScores(entry); - ScoreboardScore score = scores.get(objective.getHandle()); + Map scores = board.getPlayerScores(entry); + net.minecraft.world.scores.Score score = scores.get(objective.getHandle()); if (score != null) { // Lazy return score.getScore(); } diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboard.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboard.java index cafbabf8ed..9abc1431c5 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboard.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboard.java @@ -5,8 +5,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import net.minecraft.world.scores.Scoreboard; -import net.minecraft.world.scores.ScoreboardObjective; -import net.minecraft.world.scores.ScoreboardTeam; +import net.minecraft.world.scores.PlayerTeam; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.craftbukkit.v1_20_R2.util.CraftChatMessage; @@ -53,14 +52,14 @@ public CraftObjective registerNewObjective(String name, Criteria criteria, Strin Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "The name '%s' is longer than the limit of 32767 characters (%s)", name, name.length()); Preconditions.checkArgument(board.getObjective(name) == null, "An objective of name '%s' already exists", name); - ScoreboardObjective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); + net.minecraft.world.scores.Objective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); return new CraftObjective(this, objective); } @Override public Objective getObjective(String name) { Preconditions.checkArgument(name != null, "Objective name cannot be null"); - ScoreboardObjective nms = board.getObjective(name); + net.minecraft.world.scores.Objective nms = board.getObjective(name); return nms == null ? null : new CraftObjective(this, nms); } @@ -69,7 +68,7 @@ public ImmutableSet getObjectivesByCriteria(String criteria) { Preconditions.checkArgument(criteria != null, "Criteria name cannot be null"); ImmutableSet.Builder objectives = ImmutableSet.builder(); - for (ScoreboardObjective netObjective : this.board.getObjectives()) { + for (net.minecraft.world.scores.Objective netObjective : this.board.getObjectives()) { CraftObjective objective = new CraftObjective(this, netObjective); if (objective.getCriteria().equals(criteria)) { objectives.add(objective); @@ -83,7 +82,7 @@ public ImmutableSet getObjectivesByCriteria(Criteria criteria) { Preconditions.checkArgument(criteria != null, "Criteria cannot be null"); ImmutableSet.Builder objectives = ImmutableSet.builder(); - for (ScoreboardObjective netObjective : board.getObjectives()) { + for (net.minecraft.world.scores.Objective netObjective : board.getObjectives()) { CraftObjective objective = new CraftObjective(this, netObjective); if (objective.getTrackedCriteria().equals(criteria)) { objectives.add(objective); @@ -95,13 +94,13 @@ public ImmutableSet getObjectivesByCriteria(Criteria criteria) { @Override public ImmutableSet getObjectives() { - return ImmutableSet.copyOf(Iterables.transform(this.board.getObjectives(), (Function) input -> new CraftObjective(CraftScoreboard.this, input))); + return ImmutableSet.copyOf(Iterables.transform(this.board.getObjectives(), (Function) input -> new CraftObjective(CraftScoreboard.this, input))); } @Override public Objective getObjective(DisplaySlot slot) { Preconditions.checkArgument(slot != null, "Display slot cannot be null"); - ScoreboardObjective objective = board.getDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot)); + net.minecraft.world.scores.Objective objective = board.getDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot)); if (objective == null) { return null; } @@ -120,7 +119,7 @@ public ImmutableSet getScores(String entry) { Preconditions.checkArgument(entry != null, "Entry cannot be null"); ImmutableSet.Builder scores = ImmutableSet.builder(); - for (ScoreboardObjective objective : this.board.getObjectives()) { + for (net.minecraft.world.scores.Objective objective : this.board.getObjectives()) { scores.add(new CraftScore(new CraftObjective(this, objective), entry)); } return scores.build(); @@ -137,7 +136,7 @@ public void resetScores(OfflinePlayer player) { public void resetScores(String entry) { Preconditions.checkArgument(entry != null, "Entry cannot be null"); - for (ScoreboardObjective objective : this.board.getObjectives()) { + for (net.minecraft.world.scores.Objective objective : this.board.getObjectives()) { board.resetPlayerScore(entry, objective); } } @@ -146,7 +145,7 @@ public void resetScores(String entry) { public Team getPlayerTeam(OfflinePlayer player) { Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); - ScoreboardTeam team = board.getPlayersTeam(player.getName()); + PlayerTeam team = board.getPlayersTeam(player.getName()); return team == null ? null : new CraftTeam(this, team); } @@ -154,7 +153,7 @@ public Team getPlayerTeam(OfflinePlayer player) { public Team getEntryTeam(String entry) { Preconditions.checkArgument(entry != null, "Entry cannot be null"); - ScoreboardTeam team = board.getPlayersTeam(entry); + PlayerTeam team = board.getPlayersTeam(entry); return team == null ? null : new CraftTeam(this, team); } @@ -162,13 +161,13 @@ public Team getEntryTeam(String entry) { public Team getTeam(String teamName) { Preconditions.checkArgument(teamName != null, "Team name cannot be null"); - ScoreboardTeam team = board.getPlayerTeam(teamName); + PlayerTeam team = board.getPlayerTeam(teamName); return team == null ? null : new CraftTeam(this, team); } @Override public ImmutableSet getTeams() { - return ImmutableSet.copyOf(Iterables.transform(this.board.getPlayerTeams(), (Function) input -> new CraftTeam(CraftScoreboard.this, input))); + return ImmutableSet.copyOf(Iterables.transform(this.board.getPlayerTeams(), (Function) input -> new CraftTeam(CraftScoreboard.this, input))); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardManager.java index 3d8e2bbd7a..2e1bb6ecef 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardManager.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardManager.java @@ -7,16 +7,16 @@ import java.util.Iterator; import java.util.Map; import java.util.function.Consumer; -import net.minecraft.network.protocol.game.PacketPlayOutScoreboardObjective; -import net.minecraft.network.protocol.game.PacketPlayOutScoreboardTeam; +import net.minecraft.network.protocol.game.ClientboundSetObjectivePacket; +import net.minecraft.network.protocol.game.ClientboundSetPlayerTeamPacket; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.ScoreboardServer; -import net.minecraft.server.level.EntityPlayer; +import net.minecraft.server.ServerScoreboard; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.scores.Scoreboard; -import net.minecraft.world.scores.ScoreboardObjective; -import net.minecraft.world.scores.ScoreboardScore; -import net.minecraft.world.scores.ScoreboardTeam; -import net.minecraft.world.scores.criteria.IScoreboardCriteria; +import net.minecraft.world.scores.Objective; +import net.minecraft.world.scores.Score; +import net.minecraft.world.scores.PlayerTeam; +import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_20_R2.util.WeakCollection; import org.bukkit.entity.Player; @@ -41,7 +41,7 @@ public CraftScoreboard getMainScoreboard() { @Override public CraftScoreboard getNewScoreboard() { - CraftScoreboard scoreboard = new CraftScoreboard(new ScoreboardServer(server)); + CraftScoreboard scoreboard = new CraftScoreboard(new ServerScoreboard(server)); scoreboards.add(scoreboard); return scoreboard; } @@ -59,7 +59,7 @@ public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard; net.minecraft.world.scores.Scoreboard oldboard = getPlayerBoard(player).getHandle(); net.minecraft.world.scores.Scoreboard newboard = scoreboard.getHandle(); - EntityPlayer entityplayer = player.getHandle(); + ServerPlayer entityplayer = player.getHandle(); if (oldboard == newboard) { return; @@ -72,24 +72,24 @@ public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard } // Old objective tracking - HashSet removed = new HashSet<>(); + HashSet removed = new HashSet<>(); for (int i = 0; i < 3; ++i) { - ScoreboardObjective scoreboardobjective = oldboard.getDisplayObjective(net.minecraft.world.scores.DisplaySlot.BY_ID.apply(i)); + Objective scoreboardobjective = oldboard.getDisplayObjective(net.minecraft.world.scores.DisplaySlot.BY_ID.apply(i)); if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) { - entityplayer.connection.send(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1)); + entityplayer.connection.send(new ClientboundSetObjectivePacket(scoreboardobjective, 1)); removed.add(scoreboardobjective); } } // Old team tracking - Iterator iterator = oldboard.getPlayerTeams().iterator(); + Iterator iterator = oldboard.getPlayerTeams().iterator(); while (iterator.hasNext()) { - ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next(); - entityplayer.connection.send(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam)); + PlayerTeam scoreboardteam = iterator.next(); + entityplayer.connection.send(ClientboundSetPlayerTeamPacket.createRemovePacket(scoreboardteam)); } // The above is the reverse of the below method. - server.getPlayerList().updateEntireScoreboard((ScoreboardServer) newboard, player.getHandle()); + server.getPlayerList().updateEntireScoreboard((ServerScoreboard) newboard, player.getHandle()); } // CraftBukkit method @@ -98,7 +98,7 @@ public void removePlayer(Player player) { } // CraftBukkit method - public void getScoreboardScores(IScoreboardCriteria criteria, String name, Consumer consumer) { + public void getScoreboardScores(ObjectiveCriteria criteria, String name, Consumer consumer) { for (CraftScoreboard scoreboard : scoreboards) { Scoreboard board = scoreboard.board; board.forAllObjectives(criteria, name, (score) -> consumer.accept(score)); diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardTranslations.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardTranslations.java index 9255791e8a..888a511249 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardTranslations.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftScoreboardTranslations.java @@ -1,7 +1,7 @@ package org.bukkit.craftbukkit.v1_20_R2.scoreboard; import com.google.common.collect.ImmutableBiMap; -import net.minecraft.world.scores.criteria.IScoreboardCriteria; +import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.RenderType; @@ -39,11 +39,11 @@ static net.minecraft.world.scores.DisplaySlot fromBukkitSlot(DisplaySlot slot) { return net.minecraft.world.scores.DisplaySlot.CODEC.byName(SLOTS.get(slot)); } - static RenderType toBukkitRender(IScoreboardCriteria.EnumScoreboardHealthDisplay display) { + static RenderType toBukkitRender(ObjectiveCriteria.RenderType display) { return RenderType.valueOf(display.name()); } - static IScoreboardCriteria.EnumScoreboardHealthDisplay fromBukkitRender(RenderType render) { - return IScoreboardCriteria.EnumScoreboardHealthDisplay.valueOf(render.name()); + static ObjectiveCriteria.RenderType fromBukkitRender(RenderType render) { + return ObjectiveCriteria.RenderType.valueOf(render.name()); } } diff --git a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftTeam.java index 77b1bc65fe..1ce6c2bd00 100644 --- a/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/v1_20_R2/scoreboard/CraftTeam.java @@ -3,9 +3,7 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import java.util.Set; -import net.minecraft.world.scores.ScoreboardTeam; -import net.minecraft.world.scores.ScoreboardTeamBase; -import net.minecraft.world.scores.ScoreboardTeamBase.EnumNameTagVisibility; +import net.minecraft.world.scores.PlayerTeam; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; @@ -14,9 +12,9 @@ import org.bukkit.scoreboard.Team; final class CraftTeam extends CraftScoreboardComponent implements Team { - private final ScoreboardTeam team; + private final PlayerTeam team; - CraftTeam(CraftScoreboard scoreboard, ScoreboardTeam team) { + CraftTeam(CraftScoreboard scoreboard, PlayerTeam team) { super(scoreboard); this.team = team; } @@ -235,35 +233,36 @@ public void setOption(Option option, OptionStatus status) { switch (option) { case NAME_TAG_VISIBILITY: - team.setNameTagVisibility(EnumNameTagVisibility.values()[status.ordinal()]); + team.setNameTagVisibility(net.minecraft.world.scores.Team.Visibility.values()[status.ordinal()]); break; case DEATH_MESSAGE_VISIBILITY: - team.setDeathMessageVisibility(EnumNameTagVisibility.values()[status.ordinal()]); + team.setDeathMessageVisibility(net.minecraft.world.scores.Team.Visibility.values()[status.ordinal()]); break; case COLLISION_RULE: - team.setCollisionRule(ScoreboardTeamBase.EnumTeamPush.values()[status.ordinal()]); + team.setCollisionRule(net.minecraft.world.scores.Team.CollisionRule.values()[status.ordinal()]); break; default: throw new IllegalArgumentException("Unrecognised option " + option); } } - public static EnumNameTagVisibility bukkitToNotch(NameTagVisibility visibility) { + public static net.minecraft.world.scores.Team.Visibility bukkitToNotch(NameTagVisibility visibility) { switch (visibility) { case ALWAYS: - return EnumNameTagVisibility.ALWAYS; + return net.minecraft.world.scores.Team.Visibility.ALWAYS; case NEVER: - return EnumNameTagVisibility.NEVER; + return net.minecraft.world.scores.Team.Visibility.NEVER; case HIDE_FOR_OTHER_TEAMS: - return EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS; + return net.minecraft.world.scores.Team.Visibility.HIDE_FOR_OTHER_TEAMS; case HIDE_FOR_OWN_TEAM: - return EnumNameTagVisibility.HIDE_FOR_OWN_TEAM; + return net.minecraft.world.scores.Team.Visibility.HIDE_FOR_OWN_TEAM; default: throw new IllegalArgumentException("Unknown visibility level " + visibility); } } - public static NameTagVisibility notchToBukkit(EnumNameTagVisibility visibility) { + @SuppressWarnings("deprecation")//Kettle + public static NameTagVisibility notchToBukkit(net.minecraft.world.scores.Team.Visibility visibility) { switch (visibility) { case ALWAYS: return NameTagVisibility.ALWAYS;