mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-13 17:37:58 -04:00
PacketTeams (1.9)
This commit is contained in:
parent
a875bde2ac
commit
06d33d0f27
@ -16,7 +16,7 @@ package de.bixilon.minosoft.game.datatypes.scoreboard;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ScoreboardManager {
|
public class ScoreboardManager {
|
||||||
final HashMap<String, ScoreboardTeam> teams;
|
final HashMap<String, Team> teams;
|
||||||
final HashMap<String, ScoreboardObjective> objectives;
|
final HashMap<String, ScoreboardObjective> objectives;
|
||||||
|
|
||||||
|
|
||||||
@ -25,11 +25,11 @@ public class ScoreboardManager {
|
|||||||
objectives = new HashMap<>();
|
objectives = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTeam(ScoreboardTeam team) {
|
public void addTeam(Team team) {
|
||||||
teams.put(team.getName(), team);
|
teams.put(team.getName(), team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScoreboardTeam getTeam(String name) {
|
public Team getTeam(String name) {
|
||||||
return teams.get(name);
|
return teams.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,34 +13,35 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.game.datatypes.scoreboard;
|
package de.bixilon.minosoft.game.datatypes.scoreboard;
|
||||||
|
|
||||||
import de.bixilon.minosoft.protocol.packets.clientbound.play.PacketScoreboardTeams;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ScoreboardTeam {
|
public class Team {
|
||||||
final String name;
|
final String name;
|
||||||
|
final List<String> players;
|
||||||
String displayName;
|
String displayName;
|
||||||
String prefix;
|
String prefix;
|
||||||
String suffix;
|
String suffix;
|
||||||
PacketScoreboardTeams.ScoreboardFriendlyFire friendlyFire;
|
boolean friendlyFire;
|
||||||
final List<String> players;
|
boolean seeFriendlyInvisibles;
|
||||||
|
|
||||||
public ScoreboardTeam(String name, String displayName, String prefix, String suffix, PacketScoreboardTeams.ScoreboardFriendlyFire friendlyFire, String[] players) {
|
public Team(String name, String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles, String[] players) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.suffix = suffix;
|
this.suffix = suffix;
|
||||||
this.friendlyFire = friendlyFire;
|
this.friendlyFire = friendlyFire;
|
||||||
|
this.seeFriendlyInvisibles = seeFriendlyInvisibles;
|
||||||
this.players = new ArrayList<>(Arrays.asList(players));
|
this.players = new ArrayList<>(Arrays.asList(players));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInformation(String displayName, String prefix, String suffix, PacketScoreboardTeams.ScoreboardFriendlyFire friendlyFire) {
|
public void updateInformation(String displayName, String prefix, String suffix, boolean friendlyFire, boolean seeFriendlyInvisibles) {
|
||||||
this.displayName = displayName;
|
this.displayName = displayName;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.suffix = suffix;
|
this.suffix = suffix;
|
||||||
this.friendlyFire = friendlyFire;
|
this.friendlyFire = friendlyFire;
|
||||||
|
this.seeFriendlyInvisibles = seeFriendlyInvisibles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -59,10 +60,14 @@ public class ScoreboardTeam {
|
|||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PacketScoreboardTeams.ScoreboardFriendlyFire getFriendlyFire() {
|
public boolean isFriendlyFireEnabled() {
|
||||||
return friendlyFire;
|
return friendlyFire;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSeeingFriendlyInvisibles() {
|
||||||
|
return seeFriendlyInvisibles;
|
||||||
|
}
|
||||||
|
|
||||||
public void addPlayers(List<String> list) {
|
public void addPlayers(List<String> list) {
|
||||||
players.addAll(list);
|
players.addAll(list);
|
||||||
}
|
}
|
@ -60,15 +60,15 @@ public class PacketBlockAction implements ClientboundPacket {
|
|||||||
clazz = ChestAction.class;
|
clazz = ChestAction.class;
|
||||||
break;
|
break;
|
||||||
case 138:
|
case 138:
|
||||||
// chest
|
// beacon
|
||||||
clazz = BeaconAction.class;
|
clazz = BeaconAction.class;
|
||||||
break;
|
break;
|
||||||
case 52:
|
case 52:
|
||||||
// chest
|
// mob spawner
|
||||||
clazz = MobSpawnerAction.class;
|
clazz = MobSpawnerAction.class;
|
||||||
break;
|
break;
|
||||||
case 209:
|
case 209:
|
||||||
// chest
|
// end gateway
|
||||||
clazz = EndGatewayAction.class;
|
clazz = EndGatewayAction.class;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1,197 +0,0 @@
|
|||||||
/*
|
|
||||||
* Codename Minosoft
|
|
||||||
* Copyright (C) 2020 Moritz Zwerger
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
|
||||||
|
|
||||||
import de.bixilon.minosoft.game.datatypes.ChatColor;
|
|
||||||
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
|
||||||
import de.bixilon.minosoft.logging.Log;
|
|
||||||
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
|
||||||
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
|
||||||
|
|
||||||
public class PacketScoreboardTeams implements ClientboundPacket {
|
|
||||||
String name;
|
|
||||||
ScoreboardTeamAction action;
|
|
||||||
String displayName;
|
|
||||||
String prefix;
|
|
||||||
String suffix;
|
|
||||||
ScoreboardFriendlyFire friendlyFire;
|
|
||||||
ScoreboardNameTagVisibility nameTagVisibility;
|
|
||||||
TextComponent.ChatAttributes color;
|
|
||||||
String[] playerNames;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean read(InPacketBuffer buffer) {
|
|
||||||
switch (buffer.getVersion()) {
|
|
||||||
case VERSION_1_7_10:
|
|
||||||
name = buffer.readString();
|
|
||||||
action = ScoreboardTeamAction.byId(buffer.readByte());
|
|
||||||
if (action == ScoreboardTeamAction.CREATE || action == ScoreboardTeamAction.INFORMATION_UPDATE) {
|
|
||||||
displayName = buffer.readString();
|
|
||||||
prefix = buffer.readString();
|
|
||||||
suffix = buffer.readString();
|
|
||||||
friendlyFire = ScoreboardFriendlyFire.byId(buffer.readByte());
|
|
||||||
// default values
|
|
||||||
nameTagVisibility = ScoreboardNameTagVisibility.ALWAYS;
|
|
||||||
color = TextComponent.ChatAttributes.WHITE;
|
|
||||||
}
|
|
||||||
if (action == ScoreboardTeamAction.CREATE || action == ScoreboardTeamAction.PLAYER_ADD || action == ScoreboardTeamAction.PLAYER_REMOVE) {
|
|
||||||
short playerCount = buffer.readShort();
|
|
||||||
playerNames = new String[playerCount];
|
|
||||||
for (int i = 0; i < playerCount; i++) {
|
|
||||||
playerNames[i] = buffer.readString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case VERSION_1_8:
|
|
||||||
name = buffer.readString();
|
|
||||||
action = ScoreboardTeamAction.byId(buffer.readByte());
|
|
||||||
if (action == ScoreboardTeamAction.CREATE || action == ScoreboardTeamAction.INFORMATION_UPDATE) {
|
|
||||||
displayName = buffer.readString();
|
|
||||||
prefix = buffer.readString();
|
|
||||||
suffix = buffer.readString();
|
|
||||||
friendlyFire = ScoreboardFriendlyFire.byId(buffer.readByte());
|
|
||||||
nameTagVisibility = ScoreboardNameTagVisibility.byName(buffer.readString());
|
|
||||||
color = TextComponent.ChatAttributes.byColor(ChatColor.byId(buffer.readByte()));
|
|
||||||
}
|
|
||||||
if (action == ScoreboardTeamAction.CREATE || action == ScoreboardTeamAction.PLAYER_ADD || action == ScoreboardTeamAction.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void log() {
|
|
||||||
Log.protocol(String.format("Received scoreboard Team update (name=\"%s\", action=%s, displayName=\"%s\", prefix=\"%s\", suffix=\"%s\", friendlyFire=%s, playerCount=%s)", name, action.name(), displayName, prefix, suffix, (friendlyFire == null ? "null" : friendlyFire.name()), ((playerNames == null) ? "null" : playerNames.length)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(PacketHandler h) {
|
|
||||||
h.handle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScoreboardTeamAction getAction() {
|
|
||||||
return action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDisplayName() {
|
|
||||||
return displayName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrefix() {
|
|
||||||
return prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSuffix() {
|
|
||||||
return suffix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScoreboardFriendlyFire getFriendlyFire() {
|
|
||||||
return friendlyFire;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getPlayerNames() {
|
|
||||||
return playerNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ScoreboardTeamAction {
|
|
||||||
CREATE(0),
|
|
||||||
REMOVE(1),
|
|
||||||
INFORMATION_UPDATE(2),
|
|
||||||
PLAYER_ADD(3),
|
|
||||||
PLAYER_REMOVE(4);
|
|
||||||
|
|
||||||
final int id;
|
|
||||||
|
|
||||||
ScoreboardTeamAction(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScoreboardTeamAction byId(int id) {
|
|
||||||
for (ScoreboardTeamAction a : values()) {
|
|
||||||
if (a.getId() == id) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ScoreboardFriendlyFire {
|
|
||||||
OFF(0),
|
|
||||||
ON(1),
|
|
||||||
SEE_FRIENDLY_INVISIBLES(3);
|
|
||||||
|
|
||||||
final int id;
|
|
||||||
|
|
||||||
ScoreboardFriendlyFire(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScoreboardFriendlyFire byId(int id) {
|
|
||||||
for (ScoreboardFriendlyFire f : values()) {
|
|
||||||
if (f.getId() == id) {
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ScoreboardNameTagVisibility {
|
|
||||||
ALWAYS("always"),
|
|
||||||
HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
|
|
||||||
HIDE_FOR_OWN_TEAM("hideForOwnTeam"),
|
|
||||||
NEVER("never");
|
|
||||||
|
|
||||||
final String name;
|
|
||||||
|
|
||||||
ScoreboardNameTagVisibility(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ScoreboardNameTagVisibility byName(String name) {
|
|
||||||
for (ScoreboardNameTagVisibility v : values()) {
|
|
||||||
if (v.getName().equals(name)) {
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,252 @@
|
|||||||
|
/*
|
||||||
|
* Codename Minosoft
|
||||||
|
* Copyright (C) 2020 Moritz Zwerger
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.bixilon.minosoft.protocol.packets.clientbound.play;
|
||||||
|
|
||||||
|
import de.bixilon.minosoft.game.datatypes.ChatColor;
|
||||||
|
import de.bixilon.minosoft.game.datatypes.TextComponent;
|
||||||
|
import de.bixilon.minosoft.logging.Log;
|
||||||
|
import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.InPacketBuffer;
|
||||||
|
import de.bixilon.minosoft.protocol.protocol.PacketHandler;
|
||||||
|
import de.bixilon.minosoft.util.BitByte;
|
||||||
|
|
||||||
|
public class PacketTeams implements ClientboundPacket {
|
||||||
|
String name;
|
||||||
|
TeamActions action;
|
||||||
|
String displayName;
|
||||||
|
String prefix;
|
||||||
|
String suffix;
|
||||||
|
boolean friendlyFire;
|
||||||
|
boolean seeFriendlyInvisibles;
|
||||||
|
TeamCollisionRules collisionRule = TeamCollisionRules.NEVER;
|
||||||
|
TeamNameTagVisibilities nameTagVisibility = TeamNameTagVisibilities.ALWAYS;
|
||||||
|
TextComponent.ChatAttributes color = TextComponent.ChatAttributes.WHITE;
|
||||||
|
String[] playerNames;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean read(InPacketBuffer buffer) {
|
||||||
|
switch (buffer.getVersion()) {
|
||||||
|
case VERSION_1_7_10:
|
||||||
|
name = buffer.readString();
|
||||||
|
action = TeamActions.byId(buffer.readByte());
|
||||||
|
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||||
|
displayName = buffer.readString();
|
||||||
|
prefix = buffer.readString();
|
||||||
|
suffix = buffer.readString();
|
||||||
|
setFriendlyFireByLegacy(buffer.readByte());
|
||||||
|
}
|
||||||
|
if (action == TeamActions.CREATE || action == TeamActions.PLAYER_ADD || action == TeamActions.PLAYER_REMOVE) {
|
||||||
|
short playerCount = buffer.readShort();
|
||||||
|
playerNames = new String[playerCount];
|
||||||
|
for (int i = 0; i < playerCount; i++) {
|
||||||
|
playerNames[i] = buffer.readString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case VERSION_1_8:
|
||||||
|
name = buffer.readString();
|
||||||
|
action = TeamActions.byId(buffer.readByte());
|
||||||
|
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||||
|
displayName = buffer.readString();
|
||||||
|
prefix = buffer.readString();
|
||||||
|
suffix = buffer.readString();
|
||||||
|
setFriendlyFireByLegacy(buffer.readByte());
|
||||||
|
nameTagVisibility = TeamNameTagVisibilities.byName(buffer.readString());
|
||||||
|
color = TextComponent.ChatAttributes.byColor(ChatColor.byId(buffer.readByte()));
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
case VERSION_1_9_4:
|
||||||
|
name = buffer.readString();
|
||||||
|
action = TeamActions.byId(buffer.readByte());
|
||||||
|
if (action == TeamActions.CREATE || action == TeamActions.INFORMATION_UPDATE) {
|
||||||
|
displayName = buffer.readString();
|
||||||
|
prefix = buffer.readString();
|
||||||
|
suffix = buffer.readString();
|
||||||
|
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()));
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(PacketHandler h) {
|
||||||
|
h.handle(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeamActions getAction() {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDisplayName() {
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix() {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSuffix() {
|
||||||
|
return suffix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFriendlyFireEnabled() {
|
||||||
|
return friendlyFire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeeingFriendlyInvisibles() {
|
||||||
|
return seeFriendlyInvisibles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextComponent.ChatAttributes getColor() {
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeamCollisionRules getCollisionRule() {
|
||||||
|
return collisionRule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeamNameTagVisibilities getNameTagVisibility() {
|
||||||
|
return nameTagVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getPlayerNames() {
|
||||||
|
return playerNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setFriendlyFireByLegacy(byte raw) {
|
||||||
|
switch (raw) {
|
||||||
|
case 0:
|
||||||
|
friendlyFire = false;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
friendlyFire = true;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
friendlyFire = false;
|
||||||
|
seeFriendlyInvisibles = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//ToDo: seeFriendlyInvisibles for case 0 and 1
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TeamActions {
|
||||||
|
CREATE(0),
|
||||||
|
REMOVE(1),
|
||||||
|
INFORMATION_UPDATE(2),
|
||||||
|
PLAYER_ADD(3),
|
||||||
|
PLAYER_REMOVE(4);
|
||||||
|
|
||||||
|
final int id;
|
||||||
|
|
||||||
|
TeamActions(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TeamActions byId(int id) {
|
||||||
|
for (TeamActions a : values()) {
|
||||||
|
if (a.getId() == id) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TeamNameTagVisibilities {
|
||||||
|
ALWAYS("always"),
|
||||||
|
HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
|
||||||
|
HIDE_FOR_OWN_TEAM("hideForOwnTeam"),
|
||||||
|
NEVER("never");
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
TeamNameTagVisibilities(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TeamNameTagVisibilities byName(String name) {
|
||||||
|
for (TeamNameTagVisibilities v : values()) {
|
||||||
|
if (v.getName().equals(name)) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TeamCollisionRules {
|
||||||
|
ALWAYS("always"),
|
||||||
|
PUSH_OTHER_TEAMS("pushOtherTeams"),
|
||||||
|
PUSH_OWN_TEAM("pushOwnOwnTeam"),
|
||||||
|
NEVER("never");
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
|
||||||
|
TeamCollisionRules(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TeamCollisionRules byName(String name) {
|
||||||
|
for (TeamCollisionRules rule : values()) {
|
||||||
|
if (rule.getName().equals(name)) {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,7 +21,7 @@ import de.bixilon.minosoft.game.datatypes.player.PlayerInfo;
|
|||||||
import de.bixilon.minosoft.game.datatypes.player.PlayerInfoBulk;
|
import de.bixilon.minosoft.game.datatypes.player.PlayerInfoBulk;
|
||||||
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardObjective;
|
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardObjective;
|
||||||
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardScore;
|
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardScore;
|
||||||
import de.bixilon.minosoft.game.datatypes.scoreboard.ScoreboardTeam;
|
import de.bixilon.minosoft.game.datatypes.scoreboard.Team;
|
||||||
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
import de.bixilon.minosoft.game.datatypes.world.BlockPosition;
|
||||||
import de.bixilon.minosoft.logging.Log;
|
import de.bixilon.minosoft.logging.Log;
|
||||||
import de.bixilon.minosoft.protocol.network.Connection;
|
import de.bixilon.minosoft.protocol.network.Connection;
|
||||||
@ -474,13 +474,13 @@ public class PacketHandler {
|
|||||||
//ToDo
|
//ToDo
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(PacketScoreboardTeams pkg) {
|
public void handle(PacketTeams pkg) {
|
||||||
switch (pkg.getAction()) {
|
switch (pkg.getAction()) {
|
||||||
case CREATE:
|
case CREATE:
|
||||||
connection.getPlayer().getScoreboardManager().addTeam(new ScoreboardTeam(pkg.getName(), pkg.getDisplayName(), pkg.getPrefix(), pkg.getSuffix(), pkg.getFriendlyFire(), pkg.getPlayerNames()));
|
connection.getPlayer().getScoreboardManager().addTeam(new Team(pkg.getName(), pkg.getDisplayName(), pkg.getPrefix(), pkg.getSuffix(), pkg.isFriendlyFireEnabled(), pkg.isSeeingFriendlyInvisibles(), pkg.getPlayerNames()));
|
||||||
break;
|
break;
|
||||||
case INFORMATION_UPDATE:
|
case INFORMATION_UPDATE:
|
||||||
connection.getPlayer().getScoreboardManager().getTeam(pkg.getName()).updateInformation(pkg.getDisplayName(), pkg.getPrefix(), pkg.getSuffix(), pkg.getFriendlyFire());
|
connection.getPlayer().getScoreboardManager().getTeam(pkg.getName()).updateInformation(pkg.getDisplayName(), pkg.getPrefix(), pkg.getSuffix(), pkg.isFriendlyFireEnabled(), pkg.isSeeingFriendlyInvisibles());
|
||||||
break;
|
break;
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
connection.getPlayer().getScoreboardManager().removeTeam(pkg.getName());
|
connection.getPlayer().getScoreboardManager().removeTeam(pkg.getName());
|
||||||
|
@ -127,7 +127,7 @@ public abstract class Protocol implements ProtocolInterface {
|
|||||||
packetClassMapping.put(Packets.Clientbound.PLAY_EFFECT, PacketEffect.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_EFFECT, PacketEffect.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SCOREBOARD_OBJECTIVE, PacketScoreboardObjective.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SCOREBOARD_OBJECTIVE, PacketScoreboardObjective.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_SCORE, PacketScoreboardUpdateScore.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_UPDATE_SCORE, PacketScoreboardUpdateScore.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_TEAMS, PacketScoreboardTeams.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_TEAMS, PacketTeams.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_DISPLAY_SCOREBOARD, PacketScoreboardDisplayScoreboard.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_DISPLAY_SCOREBOARD, PacketScoreboardDisplayScoreboard.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_MAP_DATA, PacketMapData.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_MAP_DATA, PacketMapData.class);
|
||||||
packetClassMapping.put(Packets.Clientbound.PLAY_SERVER_DIFFICULTY, PacketServerDifficulty.class);
|
packetClassMapping.put(Packets.Clientbound.PLAY_SERVER_DIFFICULTY, PacketServerDifficulty.class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user