mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-12 17:07:55 -04:00
Teams 1.13+
This commit is contained in:
parent
0fa5037375
commit
b4fc991572
@ -29,7 +29,13 @@ public enum ChatColor {
|
||||
RED(0x0C),
|
||||
PURPLE(0x0D),
|
||||
YELLOW(0x0E),
|
||||
WHITE(0x0F);
|
||||
WHITE(0x0F),
|
||||
OBFUSCATED(16),
|
||||
BOLD(17),
|
||||
STRIKETHROUGH(18),
|
||||
UNDERLINED(19),
|
||||
ITALIC(20),
|
||||
RESET(21);
|
||||
|
||||
|
||||
final int color;
|
||||
|
@ -13,6 +13,8 @@
|
||||
|
||||
package de.bixilon.minosoft.game.datatypes.scoreboard;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -20,13 +22,13 @@ import java.util.List;
|
||||
public class Team {
|
||||
final String name;
|
||||
final List<String> players;
|
||||
String displayName;
|
||||
TextComponent displayName;
|
||||
String prefix;
|
||||
String suffix;
|
||||
boolean friendlyFire;
|
||||
boolean seeFriendlyInvisibles;
|
||||
|
||||
public Team(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, String[] players) {
|
||||
public Team(String name, TextComponent displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, String[] players) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.prefix = prefix;
|
||||
@ -36,7 +38,7 @@ public class Team {
|
||||
this.players = new ArrayList<>(Arrays.asList(players));
|
||||
}
|
||||
|
||||
public void updateInformation(String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles) {
|
||||
public void updateInformation(TextComponent displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles) {
|
||||
this.displayName = displayName;
|
||||
this.prefix = prefix;
|
||||
this.suffix = suffix;
|
||||
@ -48,7 +50,7 @@ public class Team {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
public TextComponent getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ import de.bixilon.minosoft.util.BitByte;
|
||||
public class PacketTeams implements ClientboundPacket {
|
||||
String name;
|
||||
TeamActions action;
|
||||
String displayName;
|
||||
TextComponent displayName;
|
||||
String prefix;
|
||||
String suffix;
|
||||
boolean friendlyFire;
|
||||
@ -42,7 +42,7 @@ public class PacketTeams implements ClientboundPacket {
|
||||
name = buffer.readString();
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readString();
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
setFriendlyFireByLegacy(buffer.readByte());
|
||||
@ -59,7 +59,7 @@ public class PacketTeams implements ClientboundPacket {
|
||||
name = buffer.readString();
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readString();
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
setFriendlyFireByLegacy(buffer.readByte());
|
||||
@ -81,7 +81,7 @@ public class PacketTeams implements ClientboundPacket {
|
||||
name = buffer.readString();
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readString();
|
||||
displayName = buffer.readTextComponent();
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
byte friendlyFireRaw = buffer.readByte();
|
||||
@ -99,6 +99,28 @@ public class PacketTeams implements ClientboundPacket {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case VERSION_1_13_2:
|
||||
name = buffer.readString();
|
||||
action = TeamActions.byId(buffer.readByte());
|
||||
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||
displayName = buffer.readTextComponent();
|
||||
byte friendlyFireRaw = buffer.readByte();
|
||||
friendlyFire = BitByte.isBitMask(friendlyFireRaw, 0x01);
|
||||
seeFriendlyInvisibles = BitByte.isBitMask(friendlyFireRaw, 0x02);
|
||||
nameTagVisibility = TeamNameTagVisibilities.byName(buffer.readString());
|
||||
collisionRule = TeamCollisionRules.byName(buffer.readString());
|
||||
color = TextComponent.ChatAttributes.byColor(ChatColor.byId(buffer.readByte()));
|
||||
prefix = buffer.readString();
|
||||
suffix = buffer.readString();
|
||||
}
|
||||
if (action == TeamActions.CREATE || action == TeamActions.PLAYER_ADD || action == TeamActions.PLAYER_REMOVE) {
|
||||
int playerCount = buffer.readVarInt();
|
||||
playerNames = new String[playerCount];
|
||||
for (int i = 0; i < playerCount; i++) {
|
||||
playerNames[i] = buffer.readString();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -106,7 +128,7 @@ public class PacketTeams implements ClientboundPacket {
|
||||
|
||||
@Override
|
||||
public void log() {
|
||||
Log.protocol(String.format("Received scoreboard Team update (name=\"%s\", action=%s, displayName=\"%s\", prefix=\"%s\", suffix=\"%s\", friendlyFire=%s, seeFriendlyInvisibiles=%s, playerCount=%s)", name, action.name(), displayName, prefix, suffix, friendlyFire, seeFriendlyInvisibles, ((playerNames == null) ? "null" : playerNames.length)));
|
||||
Log.protocol(String.format("Received scoreboard Team update (name=\"%s\", action=%s, displayName=\"%s\", prefix=\"%s\", suffix=\"%s\", friendlyFire=%s, seeFriendlyInvisibiles=%s, playerCount=%s)", name, action.name(), displayName.getColoredMessage(), prefix, suffix, friendlyFire, seeFriendlyInvisibles, ((playerNames == null) ? "null" : playerNames.length)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -122,7 +144,7 @@ public class PacketTeams implements ClientboundPacket {
|
||||
return action;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
public TextComponent getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user