From bc1dc457e7bdeeb7d98c5c6dfc04193a90eeceb4 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Mon, 30 Jul 2018 16:36:15 -0400 Subject: [PATCH] Initial scoreboard objects We need to make these nicer, but for internal use they're fine. --- .../proxy/data/scoreboard/Objective.java | 49 ++++++++++ .../proxy/data/scoreboard/Score.java | 43 +++++++++ .../proxy/data/scoreboard/Scoreboard.java | 43 +++++++++ .../proxy/data/scoreboard/Team.java | 89 +++++++++++++++++++ 4 files changed, 224 insertions(+) create mode 100644 src/main/java/com/velocitypowered/proxy/data/scoreboard/Objective.java create mode 100644 src/main/java/com/velocitypowered/proxy/data/scoreboard/Score.java create mode 100644 src/main/java/com/velocitypowered/proxy/data/scoreboard/Scoreboard.java create mode 100644 src/main/java/com/velocitypowered/proxy/data/scoreboard/Team.java diff --git a/src/main/java/com/velocitypowered/proxy/data/scoreboard/Objective.java b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Objective.java new file mode 100644 index 000000000..eea29dbd8 --- /dev/null +++ b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Objective.java @@ -0,0 +1,49 @@ +package com.velocitypowered.proxy.data.scoreboard; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class Objective { + private final String id; + private String displayName; + private String type; + private final List teams = new ArrayList<>(); + private final Map scores = new HashMap<>(); + + public Objective(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public String getDisplayName() { + return displayName; + } + + public String getType() { + return type; + } + + public List getTeams() { + return teams; + } + + public Map getScores() { + return scores; + } + + @Override + public String toString() { + return "Objective{" + + "id='" + id + '\'' + + ", displayName='" + displayName + '\'' + + ", type='" + type + '\'' + + ", teams=" + teams + + ", scores=" + scores + + '}'; + } +} diff --git a/src/main/java/com/velocitypowered/proxy/data/scoreboard/Score.java b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Score.java new file mode 100644 index 000000000..40a95bb2d --- /dev/null +++ b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Score.java @@ -0,0 +1,43 @@ +package com.velocitypowered.proxy.data.scoreboard; + +import java.util.Objects; + +public class Score { + private final String target; + private final int value; + + public Score(String target, int value) { + this.target = target; + this.value = value; + } + + public String getTarget() { + return target; + } + + public int getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Score score = (Score) o; + return value == score.value && + Objects.equals(target, score.target); + } + + @Override + public int hashCode() { + return Objects.hash(target, value); + } + + @Override + public String toString() { + return "Score{" + + "target='" + target + '\'' + + ", value=" + value + + '}'; + } +} diff --git a/src/main/java/com/velocitypowered/proxy/data/scoreboard/Scoreboard.java b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Scoreboard.java new file mode 100644 index 000000000..fa3c95260 --- /dev/null +++ b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Scoreboard.java @@ -0,0 +1,43 @@ +package com.velocitypowered.proxy.data.scoreboard; + +import java.util.ArrayList; +import java.util.List; + +public class Scoreboard { + private String name; + private byte position; + private final List objectives = new ArrayList<>(); + + public Scoreboard() { + + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public byte getPosition() { + return position; + } + + public void setPosition(byte position) { + this.position = position; + } + + public List getObjectives() { + return objectives; + } + + @Override + public String toString() { + return "Scoreboard{" + + "name='" + name + '\'' + + ", position=" + position + + ", objectives=" + objectives + + '}'; + } +} diff --git a/src/main/java/com/velocitypowered/proxy/data/scoreboard/Team.java b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Team.java new file mode 100644 index 000000000..a03f3b1fd --- /dev/null +++ b/src/main/java/com/velocitypowered/proxy/data/scoreboard/Team.java @@ -0,0 +1,89 @@ +package com.velocitypowered.proxy.data.scoreboard; + +import java.util.Collection; +import java.util.HashSet; + +public class Team { + private final String id; + private String prefix; + private String suffix; + private byte flags; + private String nameTagVisibility; + private String collision; + private byte color; + private final Collection players = new HashSet<>(); + + public Team(String id) { + this.id = id; + } + + public String getId() { + return id; + } + + public String getPrefix() { + return prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + public String getSuffix() { + return suffix; + } + + public void setSuffix(String suffix) { + this.suffix = suffix; + } + + public byte getFlags() { + return flags; + } + + public void setFlags(byte flags) { + this.flags = flags; + } + + public String getNameTagVisibility() { + return nameTagVisibility; + } + + public void setNameTagVisibility(String nameTagVisibility) { + this.nameTagVisibility = nameTagVisibility; + } + + public String getCollision() { + return collision; + } + + public void setCollision(String collision) { + this.collision = collision; + } + + public byte getColor() { + return color; + } + + public void setColor(byte color) { + this.color = color; + } + + public Collection getPlayers() { + return players; + } + + @Override + public String toString() { + return "Team{" + + "id='" + id + '\'' + + ", prefix='" + prefix + '\'' + + ", suffix='" + suffix + '\'' + + ", flags=" + flags + + ", nameTagVisibility='" + nameTagVisibility + '\'' + + ", collision='" + collision + '\'' + + ", color=" + color + + ", players=" + players + + '}'; + } +}