Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.kopara.kguild.tablist;
- import com.comphenix.packetwrapper.WrapperPlayServerScoreboardTeam;
- import pl.kopara.kguild.utils.Util;
- public class TabCell
- {
- private final Tab tab;
- private String prefix;
- private final String name;
- private String suffix;
- private int ping;
- protected boolean sent;
- protected boolean teamExists;
- protected boolean toRemove;
- public TabCell(final Tab tab, final String prefix, final String name, final String suffix, final int ping) {
- super();
- this.tab = tab;
- this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
- this.name = Util.fixColor(name.substring(0, Math.min(name.length(), 16)));
- this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
- this.ping = ping;
- this.teamExists = true;
- this.sent = false;
- }
- public TabCell(final Tab tab, final String name) {
- super();
- this.tab = tab;
- this.name = Util.fixColor(name.substring(0, Math.min(name.length(), 16)));
- this.teamExists = false;
- this.sent = false;
- }
- public void createPrefixAndSuffix(final String prefix, final String suffix) {
- if (this.toRemove || this.teamExists) {
- return;
- }
- this.teamExists = true;
- this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
- this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
- final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
- w.setTeamName(this.name);
- w.setTeamDisplayName(this.name);
- w.setTeamPrefix(this.prefix);
- w.setTeamSuffix(this.suffix);
- w.setPacketMode((byte)0);
- w.sendPacket(this.tab.getPlayer());
- }
- public void updatePrefixAndSuffix(final String prefix, final String suffix) {
- if (this.toRemove || !this.teamExists) {
- return;
- }
- this.prefix = Util.fixColor(prefix.substring(0, Math.min(prefix.length(), 16)));
- this.suffix = Util.fixColor(suffix.substring(0, Math.min(suffix.length(), 16)));
- final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
- w.setTeamName(this.name);
- w.setTeamDisplayName(this.name);
- w.setTeamPrefix(this.prefix);
- w.setTeamSuffix(this.suffix);
- w.setPacketMode((byte)2);
- w.sendPacket(this.tab.getPlayer());
- }
- public void removePrefixAndSuffix() {
- if (this.toRemove || !this.teamExists) {
- return;
- }
- this.teamExists = false;
- final WrapperPlayServerScoreboardTeam w = new WrapperPlayServerScoreboardTeam();
- w.setTeamName(this.name);
- w.setPacketMode((byte)1);
- w.sendPacket(this.tab.getPlayer());
- }
- public Tab getTab() {
- return this.tab;
- }
- public String getPrefix() {
- return this.prefix;
- }
- public String getName() {
- return this.name;
- }
- public String getSuffix() {
- return this.suffix;
- }
- public int getPing() {
- return this.ping;
- }
- public boolean isSent() {
- return this.sent;
- }
- public boolean isTeamExists() {
- return this.teamExists;
- }
- public boolean isToRemove() {
- return this.toRemove;
- }
- public void setPrefix(final String prefix) {
- this.prefix = prefix;
- }
- public void setSuffix(final String suffix) {
- this.suffix = suffix;
- }
- public void setPing(final int ping) {
- this.ping = ping;
- }
- public void setSent(final boolean sent) {
- this.sent = sent;
- }
- public void setTeamExists(final boolean teamExists) {
- this.teamExists = teamExists;
- }
- public void setToRemove(final boolean toRemove) {
- this.toRemove = toRemove;
- }
- }
Add Comment
Please, Sign In to add comment