• Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!

Prefix bekommt immer nur der neuste Spieler

OllerSchmoller1

Minecrafter
Registriert
16 April 2023
Beiträge
1
Diamanten
50
Guten Tag, ich habe ein Prefixsystem und ein Scoreboard mit Packets programmiert. Leider bekommt der Prefix immer nur der Spieler, der als letztes gejoint ist. Die anderen Spieler sind weiß. Woran kann das liegen? In der Console kommen keine Fehler! Danke schon einmal im Voraus!

public class Tablist {

static Scoreboard scoreboard;

public static void loadTablist() {
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();

scoreboard.registerNewTeam("admin").setPrefix("§4Admin §7| §4");
scoreboard.registerNewTeam("developer").setPrefix("§bDev §7| §b");
scoreboard.registerNewTeam("srmoderator").setPrefix("§cSrMod §7| §c");
scoreboard.registerNewTeam("moderator").setPrefix("§cMod §7| §c");
scoreboard.registerNewTeam("supporter").setPrefix("§9Sup §7| §9");
scoreboard.registerNewTeam("youtuber").setPrefix("§5");
scoreboard.registerNewTeam("premiumplus").setPrefix("§e");
scoreboard.registerNewTeam("premium").setPrefix("§6");
scoreboard.registerNewTeam("spieler").setPrefix("§a");

}

@SuppressWarnings("deprecation")
public static void setPrefix(Player p) {
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(p.getUniqueId());
String group = user.getPrimaryGroup();

String team = "";
if(group.equalsIgnoreCase("Administrator")) {
team = "admin";
} else if(group.equalsIgnoreCase("Developer")) {
team = "developer";
} else if(group.equalsIgnoreCase("SrModerator")) {
team = "srmoderator";
} else if(group.equalsIgnoreCase("Moderator")) {
team = "moderator";
} else if(group.equalsIgnoreCase("Supporter")) {
team = "supporter";
} else if(group.equalsIgnoreCase("YouTuber")) {
team = "youtuber";
} else if(group.equalsIgnoreCase("PremiumPlus")) {
team = "premiumplus";
} else if(group.equalsIgnoreCase("Premium")) {
team = "premium";
} else {
team = "spieler";
}

scoreboard.getTeam(team).addPlayer(p);
p.setDisplayName(scoreboard.getTeam(team).getPrefix() + p.getName());

for(Player a : Bukkit.getOnlinePlayers()) {
a.setScoreboard(scoreboard);
}
}

}

package de.LeaBauserver.Prefixe;

import java.util.UUID;

import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.scoreboard.Team;

import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.model.user.User;
import net.minecraft.server.v1_8_R3.IScoreboardCriteria;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardDisplayObjective;
import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardObjective;
import net.minecraft.server.v1_8_R3.PacketPlayOutScoreboardScore;
import net.minecraft.server.v1_8_R3.Scoreboard;
import net.minecraft.server.v1_8_R3.ScoreboardObjective;
import net.minecraft.server.v1_8_R3.ScoreboardScore;

public class ScoreboardManager implements Listener {

public static void setBoardLobby(Player p) {
LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(p.getUniqueId());
String group = user.getPrimaryGroup();

Scoreboard scoreboard = new Scoreboard();
ScoreboardObjective obj = scoreboard.registerObjective("zagd", IScoreboardCriteria.b);
obj.setDisplayName("§3§lMarvCraft.de");
PacketPlayOutScoreboardObjective createPacket = new PacketPlayOutScoreboardObjective(obj, 0);
PacketPlayOutScoreboardDisplayObjective display = new PacketPlayOutScoreboardDisplayObjective(1, obj);

ScoreboardScore s1 = new ScoreboardScore(scoreboard, obj, "§7§2 ");
ScoreboardScore s2 = new ScoreboardScore(scoreboard, obj, "§8▏ §7Dein Name");
ScoreboardScore s3 = new ScoreboardScore(scoreboard, obj, "§8➥ §6" + p.getName());
ScoreboardScore s4 = new ScoreboardScore(scoreboard, obj, "§7§0 ");
ScoreboardScore s5 = new ScoreboardScore(scoreboard, obj, "§8▏ §7Dein Rang");
ScoreboardScore s6 = null;

if (group.equalsIgnoreCase("Administrator")) {
s6 = new ScoreboardScore(scoreboard, obj, "§4Administrator");

} else if (group.equalsIgnoreCase("Developer")) {
s6 = new ScoreboardScore(scoreboard, obj, "§bDeveloper");

} else if (group.equalsIgnoreCase("SrModerator")) {
s6 = new ScoreboardScore(scoreboard, obj, "§cSrModerator");

} else if (group.equalsIgnoreCase("Moderator")) {
s6 = new ScoreboardScore(scoreboard, obj, "§cModerator");

} else if (group.equalsIgnoreCase("Supporter")) {
s6 = new ScoreboardScore(scoreboard, obj, "§9Supporter");

} else if (group.equalsIgnoreCase("YouTuber")) {
s6 = new ScoreboardScore(scoreboard, obj, "§5YouTuber");

} else if (group.equalsIgnoreCase("PremiumPlus")) {
s6 = new ScoreboardScore(scoreboard, obj, "§ePremiumPlus");

} else if (group.equalsIgnoreCase("Premium")) {
s6 = new ScoreboardScore(scoreboard, obj, "§6Premium");

} else if (group.equalsIgnoreCase("default")) {
s6 = new ScoreboardScore(scoreboard, obj, "§aSpieler");

}

@SuppressWarnings("unused")
UUID uuid = null;
ScoreboardScore s7 = new ScoreboardScore(scoreboard, obj, "§7§9 ");
ScoreboardScore s8 = new ScoreboardScore(scoreboard, obj, "§8▏ §7Deine Coins");
ScoreboardScore s9 = new ScoreboardScore(scoreboard, obj, "§8➥ §6");
ScoreboardScore s10 = new ScoreboardScore(scoreboard, obj, "§7§9 ");
ScoreboardScore s11 = new ScoreboardScore(scoreboard, obj, "§8▏ §7TeamSpeak");
ScoreboardScore s12 = new ScoreboardScore(scoreboard, obj, "§8➥ §6KeineAhnung.de");
ScoreboardScore s13 = new ScoreboardScore(scoreboard, obj, "§0 ");

s1.setScore(11);
s2.setScore(10);
s3.setScore(9);
s4.setScore(8);
s5.setScore(7);
s6.setScore(6);
s7.setScore(5);
s8.setScore(4);
s9.setScore(3);
s10.setScore(2);
s11.setScore(1);
s12.setScore(0);
s13.setScore(-1);

PacketPlayOutScoreboardObjective removePacket = new PacketPlayOutScoreboardObjective(obj, 1);
PacketPlayOutScoreboardScore pa1 = new PacketPlayOutScoreboardScore(s1);
PacketPlayOutScoreboardScore pa2 = new PacketPlayOutScoreboardScore(s2);
PacketPlayOutScoreboardScore pa3 = new PacketPlayOutScoreboardScore(s3);
PacketPlayOutScoreboardScore pa4 = new PacketPlayOutScoreboardScore(s4);
PacketPlayOutScoreboardScore pa5 = new PacketPlayOutScoreboardScore(s5);
PacketPlayOutScoreboardScore pa6 = new PacketPlayOutScoreboardScore(s6);
PacketPlayOutScoreboardScore pa7 = new PacketPlayOutScoreboardScore(s7);
PacketPlayOutScoreboardScore pa8 = new PacketPlayOutScoreboardScore(s8);
PacketPlayOutScoreboardScore pa9 = new PacketPlayOutScoreboardScore(s9);
PacketPlayOutScoreboardScore pa10 = new PacketPlayOutScoreboardScore(s10);
PacketPlayOutScoreboardScore pa11 = new PacketPlayOutScoreboardScore(s11);
PacketPlayOutScoreboardScore pa12 = new PacketPlayOutScoreboardScore(s12);
PacketPlayOutScoreboardScore pa13 = new PacketPlayOutScoreboardScore(s13);

sendPacket(removePacket, p);
sendPacket(createPacket, p);
sendPacket(display, p);

sendPacket(pa1, p);
sendPacket(pa2, p);
sendPacket(pa3, p);
sendPacket(pa4, p);
sendPacket(pa5, p);
sendPacket(pa6, p);
sendPacket(pa7, p);
sendPacket(pa8, p);
sendPacket(pa9, p);
sendPacket(pa10, p);
sendPacket(pa11, p);
sendPacket(pa12, p);
sendPacket(pa13, p);
}

private static void sendPacket(@SuppressWarnings("rawtypes") Packet packet, Player p) {
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
}

public static org.bukkit.scoreboard.Scoreboard board;

public static Team getTeamNormal(org.bukkit.scoreboard.Scoreboard board, Player p) {

LuckPerms api = LuckPermsProvider.get();
User user = api.getUserManager().getUser(p.getUniqueId());
String group = user.getPrimaryGroup();

if (group.equalsIgnoreCase("Administrator")) {
return board.getTeam("administrator");

} else if (group.equalsIgnoreCase("Developer")) {
return board.getTeam("developer");

} else if (group.equalsIgnoreCase("SrModerator")) {
return board.getTeam("srmoderator");

} else if (group.equalsIgnoreCase("Moderator")) {
return board.getTeam("moderator");

} else if (group.equalsIgnoreCase("Supporter")) {
return board.getTeam("supporter");

} else if (group.equalsIgnoreCase("YouTuber")) {
return board.getTeam("youtuber");

} else if (group.equalsIgnoreCase("PremiumPlus")) {
return board.getTeam("premiumplus");

} else if (group.equalsIgnoreCase("Premium")) {
return board.getTeam("premium");

} else {
return board.getTeam("default");

}

}

public static void setStandardTablist(Player p) {
board = Bukkit.getScoreboardManager().getNewScoreboard();

Team Admin = board.registerNewTeam("administrator");
Team Developer = board.registerNewTeam("developer");
Team SrModerator = board.registerNewTeam("srmoderator");
Team Moderator = board.registerNewTeam("moderator");
Team Supporter = board.registerNewTeam("supporter");
Team YouTuber = board.registerNewTeam("youtuber");
Team PremiumPlus = board.registerNewTeam("premiumplus");
Team Premium = board.registerNewTeam("premium");
Team Spieler = board.registerNewTeam("default");

Admin.setPrefix("§4Admin §7| §4");
Developer.setPrefix("§bDev §7| §b");
SrModerator.setPrefix("§cSrMod §7| §c");
Moderator.setPrefix("§cMod §7| §c");
Supporter.setPrefix("§9Sup §7| §9");
YouTuber.setPrefix("§5");
PremiumPlus.setPrefix("§e");
Premium.setPrefix("§6");
Spieler.setPrefix("§a");

for (Player all : Bukkit.getOnlinePlayers()) {
Team playerteam = ScoreboardManager.getTeamNormal(board, all);
if (playerteam.hasEntry(all.getName()))
continue;
playerteam.addEntry(all.getName());
}

p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
p.setScoreboard(board);
}

@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
setBoardLobby(p);
Tablist.loadTablist();
Tablist.setPrefix(p);
}

}
 
Oben