Search in sources :

Example 1 with PacketPlayOutScoreboardObjective

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;
}
Also used : Field(java.lang.reflect.Field) PacketPlayOutScoreboardObjective(net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardObjective)

Example 2 with PacketPlayOutScoreboardObjective

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());
}
Also used : ScoreboardObjective(net.minecraft.server.v1_12_R1.ScoreboardObjective) PacketPlayOutScoreboardObjective(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective) Scoreboard(net.minecraft.server.v1_12_R1.Scoreboard) PacketPlayOutScoreboardTeam(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam) PacketPlayOutScoreboardObjective(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective) EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer) HashSet(java.util.HashSet) ScoreboardTeam(net.minecraft.server.v1_12_R1.ScoreboardTeam) PacketPlayOutScoreboardTeam(net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam)

Aggregations

Field (java.lang.reflect.Field)1 HashSet (java.util.HashSet)1 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)1 PacketPlayOutScoreboardObjective (net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardObjective)1 PacketPlayOutScoreboardTeam (net.minecraft.server.v1_12_R1.PacketPlayOutScoreboardTeam)1 Scoreboard (net.minecraft.server.v1_12_R1.Scoreboard)1 ScoreboardObjective (net.minecraft.server.v1_12_R1.ScoreboardObjective)1 ScoreboardTeam (net.minecraft.server.v1_12_R1.ScoreboardTeam)1 PacketPlayOutScoreboardObjective (net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardObjective)1