use of net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective in project FireAPI by FireBlade-Serv.
the class FireScoreboard method getScoreboardObjective.
private PacketPlayOutScoreboardObjective getScoreboardObjective(int mode) throws IllegalArgumentException, IllegalAccessException {
PacketPlayOutScoreboardObjective pso = new PacketPlayOutScoreboardObjective();
Field name = FireReflection.getField(pso.getClass(), "a");
name.set(pso, this.p.getName());
Field display = FireReflection.getField(pso.getClass(), "b");
display.set(pso, this.title);
Field dtype = FireReflection.getField(pso.getClass(), "c");
dtype.set(pso, EnumScoreboardHealthDisplay.INTEGER);
Field smode = FireReflection.getField(pso.getClass(), "d");
smode.set(pso, mode);
return pso;
}
use of net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective in project PaperDev by Kamillaova.
the class CraftScoreboardManager method setPlayerBoard.
// CraftBukkit method
public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) throws IllegalArgumentException {
Validate.isTrue(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard");
CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard;
net.minecraft.server.v1_12_R1.Scoreboard oldboard = getPlayerBoard(player).getHandle();
net.minecraft.server.v1_12_R1.Scoreboard newboard = scoreboard.getHandle();
EntityPlayer entityplayer = player.getHandle();
if (oldboard == newboard) {
return;
}
if (scoreboard == mainScoreboard) {
playerBoards.remove(player);
} else {
playerBoards.put(player, (CraftScoreboard) scoreboard);
}
// Old objective tracking
HashSet<ScoreboardObjective> removed = new HashSet<ScoreboardObjective>();
for (int i = 0; i < 3; ++i) {
ScoreboardObjective scoreboardobjective = oldboard.getObjectiveForSlot(i);
if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) {
entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1));
removed.add(scoreboardobjective);
}
}
// Old team tracking
Iterator<?> iterator = oldboard.getTeams().iterator();
while (iterator.hasNext()) {
ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next();
entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 1));
}
// The above is the reverse of the below method.
server.getPlayerList().sendScoreboard((ScoreboardServer) newboard, player.getHandle());
}
Aggregations