use of net.minecraft.server.v1_12_R1.ScoreboardObjective in project PaperDev by Kamillaova.
the class CraftObjective method getDisplaySlot.
public DisplaySlot getDisplaySlot() throws IllegalStateException {
CraftScoreboard scoreboard = checkState();
Scoreboard board = scoreboard.board;
ScoreboardObjective objective = this.objective;
for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
if (board.getObjectiveForSlot(i) == objective) {
return CraftScoreboardTranslations.toBukkitSlot(i);
}
}
return null;
}
use of net.minecraft.server.v1_12_R1.ScoreboardObjective in project PaperDev by Kamillaova.
the class CraftObjective method setDisplaySlot.
public void setDisplaySlot(DisplaySlot slot) throws IllegalStateException {
CraftScoreboard scoreboard = checkState();
Scoreboard board = scoreboard.board;
ScoreboardObjective objective = this.objective;
for (int i = 0; i < CraftScoreboardTranslations.MAX_DISPLAY_SLOT; i++) {
if (board.getObjectiveForSlot(i) == objective) {
board.setDisplaySlot(i, null);
}
}
if (slot != null) {
int slotNumber = CraftScoreboardTranslations.fromBukkitSlot(slot);
board.setDisplaySlot(slotNumber, getHandle());
}
}
use of net.minecraft.server.v1_12_R1.ScoreboardObjective in project PaperDev by Kamillaova.
the class CraftScore method getScore.
public int getScore() throws IllegalStateException {
Scoreboard board = objective.checkState().board;
if (board.getPlayers().contains(entry)) {
// Lazy
Map<ScoreboardObjective, ScoreboardScore> scores = board.getPlayerObjectives(entry);
ScoreboardScore score = scores.get(objective.getHandle());
if (score != null) {
// Lazy
return score.getScore();
}
}
// Lazy
return 0;
}
use of net.minecraft.server.v1_12_R1.ScoreboardObjective in project PaperDev by Kamillaova.
the class CraftScoreboard method getScores.
public ImmutableSet<Score> getScores(String entry) throws IllegalArgumentException {
Validate.notNull(entry, "Entry cannot be null");
ImmutableSet.Builder<Score> scores = ImmutableSet.builder();
for (ScoreboardObjective objective : (Collection<ScoreboardObjective>) this.board.getObjectives()) {
scores.add(new CraftScore(new CraftObjective(this, objective), entry));
}
return scores.build();
}
use of net.minecraft.server.v1_12_R1.ScoreboardObjective 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