mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-30 04:02:50 +01:00
Add ScoreboardServer from mc-dev for diff visibility
This commit is contained in:
parent
0c6b9bba15
commit
3f637d1724
1 changed files with 204 additions and 0 deletions
204
src/main/java/net/minecraft/server/ScoreboardServer.java
Normal file
204
src/main/java/net/minecraft/server/ScoreboardServer.java
Normal file
|
@ -0,0 +1,204 @@
|
||||||
|
package net.minecraft.server;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ScoreboardServer extends Scoreboard {
|
||||||
|
|
||||||
|
private final MinecraftServer a;
|
||||||
|
private final Set b = new HashSet();
|
||||||
|
private ScoreboardSaveData c;
|
||||||
|
|
||||||
|
public ScoreboardServer(MinecraftServer minecraftserver) {
|
||||||
|
this.a = minecraftserver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleScoreChanged(ScoreboardScore scoreboardscore) {
|
||||||
|
super.handleScoreChanged(scoreboardscore);
|
||||||
|
if (this.b.contains(scoreboardscore.getObjective())) {
|
||||||
|
this.a.getPlayerList().sendAll(new Packet207SetScoreboardScore(scoreboardscore, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handlePlayerRemoved(String s) {
|
||||||
|
super.handlePlayerRemoved(s);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet207SetScoreboardScore(s));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisplaySlot(int i, ScoreboardObjective scoreboardobjective) {
|
||||||
|
ScoreboardObjective scoreboardobjective1 = this.getObjectiveForSlot(i);
|
||||||
|
|
||||||
|
super.setDisplaySlot(i, scoreboardobjective);
|
||||||
|
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
|
||||||
|
if (this.h(scoreboardobjective1) > 0) {
|
||||||
|
this.a.getPlayerList().sendAll(new Packet208SetScoreboardDisplayObjective(i, scoreboardobjective));
|
||||||
|
} else {
|
||||||
|
this.g(scoreboardobjective1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scoreboardobjective != null) {
|
||||||
|
if (this.b.contains(scoreboardobjective)) {
|
||||||
|
this.a.getPlayerList().sendAll(new Packet208SetScoreboardDisplayObjective(i, scoreboardobjective));
|
||||||
|
} else {
|
||||||
|
this.e(scoreboardobjective);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||||
|
super.addPlayerToTeam(s, scoreboardteam);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet209SetScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 3));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
|
||||||
|
super.removePlayerFromTeam(s, scoreboardteam);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet209SetScoreboardTeam(scoreboardteam, Arrays.asList(new String[] { s}), 4));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleObjectiveAdded(ScoreboardObjective scoreboardobjective) {
|
||||||
|
super.handleObjectiveAdded(scoreboardobjective);
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleObjectiveChanged(ScoreboardObjective scoreboardobjective) {
|
||||||
|
super.handleObjectiveChanged(scoreboardobjective);
|
||||||
|
if (this.b.contains(scoreboardobjective)) {
|
||||||
|
this.a.getPlayerList().sendAll(new Packet206SetScoreboardObjective(scoreboardobjective, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleObjectiveRemoved(ScoreboardObjective scoreboardobjective) {
|
||||||
|
super.handleObjectiveRemoved(scoreboardobjective);
|
||||||
|
if (this.b.contains(scoreboardobjective)) {
|
||||||
|
this.g(scoreboardobjective);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleTeamAdded(ScoreboardTeam scoreboardteam) {
|
||||||
|
super.handleTeamAdded(scoreboardteam);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet209SetScoreboardTeam(scoreboardteam, 0));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleTeamChanged(ScoreboardTeam scoreboardteam) {
|
||||||
|
super.handleTeamChanged(scoreboardteam);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet209SetScoreboardTeam(scoreboardteam, 2));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void handleTeamRemoved(ScoreboardTeam scoreboardteam) {
|
||||||
|
super.handleTeamRemoved(scoreboardteam);
|
||||||
|
this.a.getPlayerList().sendAll(new Packet209SetScoreboardTeam(scoreboardteam, 1));
|
||||||
|
this.b();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void a(ScoreboardSaveData scoreboardsavedata) {
|
||||||
|
this.c = scoreboardsavedata;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void b() {
|
||||||
|
if (this.c != null) {
|
||||||
|
this.c.c();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getScoreboardScorePacketsForObjective(ScoreboardObjective scoreboardobjective) {
|
||||||
|
ArrayList arraylist = new ArrayList();
|
||||||
|
|
||||||
|
arraylist.add(new Packet206SetScoreboardObjective(scoreboardobjective, 0));
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
if (this.getObjectiveForSlot(i) == scoreboardobjective) {
|
||||||
|
arraylist.add(new Packet208SetScoreboardDisplayObjective(i, scoreboardobjective));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iterator = this.getScoresForObjective(scoreboardobjective).iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next();
|
||||||
|
|
||||||
|
arraylist.add(new Packet207SetScoreboardScore(scoreboardscore, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
return arraylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void e(ScoreboardObjective scoreboardobjective) {
|
||||||
|
List list = this.getScoreboardScorePacketsForObjective(scoreboardobjective);
|
||||||
|
Iterator iterator = this.a.getPlayerList().players.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||||
|
Iterator iterator1 = list.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
Packet packet = (Packet) iterator1.next();
|
||||||
|
|
||||||
|
entityplayer.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b.add(scoreboardobjective);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List f(ScoreboardObjective scoreboardobjective) {
|
||||||
|
ArrayList arraylist = new ArrayList();
|
||||||
|
|
||||||
|
arraylist.add(new Packet206SetScoreboardObjective(scoreboardobjective, 1));
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
if (this.getObjectiveForSlot(i) == scoreboardobjective) {
|
||||||
|
arraylist.add(new Packet208SetScoreboardDisplayObjective(i, scoreboardobjective));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return arraylist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void g(ScoreboardObjective scoreboardobjective) {
|
||||||
|
List list = this.f(scoreboardobjective);
|
||||||
|
Iterator iterator = this.a.getPlayerList().players.iterator();
|
||||||
|
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
|
||||||
|
Iterator iterator1 = list.iterator();
|
||||||
|
|
||||||
|
while (iterator1.hasNext()) {
|
||||||
|
Packet packet = (Packet) iterator1.next();
|
||||||
|
|
||||||
|
entityplayer.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.b.remove(scoreboardobjective);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int h(ScoreboardObjective scoreboardobjective) {
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (int j = 0; j < 3; ++j) {
|
||||||
|
if (this.getObjectiveForSlot(j) == scoreboardobjective) {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue