use of net.minecraft.server.v1_16_R3.ScoreboardTeam in project Citizens2 by CitizensDev.
the class NMSImpl method sendTeamPacket.
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(team);
if (TEAM_FIELD == null) {
TEAM_FIELD = NMS.getGetter(team.getClass(), "team");
}
try {
ScoreboardTeam nmsTeam = (ScoreboardTeam) TEAM_FIELD.invoke(team);
sendPacket(recipient, new PacketPlayOutScoreboardTeam(nmsTeam, mode));
} catch (Throwable e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R3.ScoreboardTeam 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());
}
use of net.minecraft.server.v1_16_R3.ScoreboardTeam in project Citizens2 by CitizensDev.
the class NMSImpl method setTeamNameTagVisible.
@Override
public void setTeamNameTagVisible(Team team, boolean visible) {
if (TEAM_FIELD == null) {
TEAM_FIELD = NMS.getField(team.getClass(), "team");
}
ScoreboardTeam nmsTeam;
try {
nmsTeam = (ScoreboardTeam) TEAM_FIELD.get(team);
nmsTeam.setNameTagVisibility(visible ? EnumNameTagVisibility.ALWAYS : EnumNameTagVisibility.NEVER);
} catch (Throwable e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R3.ScoreboardTeam in project Citizens2 by CitizensDev.
the class NMSImpl method sendTeamPacket.
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(team);
if (TEAM_FIELD == null) {
TEAM_FIELD = NMS.getField(team.getClass(), "team");
}
try {
ScoreboardTeam nmsTeam = (ScoreboardTeam) TEAM_FIELD.get(team);
sendPacket(recipient, new PacketPlayOutScoreboardTeam(nmsTeam, mode));
} catch (Throwable e) {
e.printStackTrace();
}
}
use of net.minecraft.server.v1_16_R3.ScoreboardTeam in project Citizens2 by CitizensDev.
the class NMSImpl method sendTeamPacket.
@Override
public void sendTeamPacket(Player recipient, Team team, int mode) {
Preconditions.checkNotNull(recipient);
Preconditions.checkNotNull(team);
if (TEAM_FIELD == null) {
TEAM_FIELD = NMS.getGetter(team.getClass(), "team");
}
try {
ScoreboardTeam nmsTeam = (ScoreboardTeam) TEAM_FIELD.invoke(team);
sendPacket(recipient, new PacketPlayOutScoreboardTeam(nmsTeam, mode));
} catch (Throwable e) {
e.printStackTrace();
}
}
Aggregations