Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Chiss 2014-10-09 10:47:47 +11:00
commit 4bed45c48c
6 changed files with 580 additions and 0 deletions

View File

@ -0,0 +1,121 @@
package net.minecraft.server.v1_7_R4;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
public class PacketPlayOutScoreboardTeam
extends Packet
{
private String a = "";
private String b = "";
private String c = "";
private String d = "";
private String _nameTagVisibility;
private Collection e = new ArrayList();
private int f;
private int g;
public PacketPlayOutScoreboardTeam() {}
public PacketPlayOutScoreboardTeam(ScoreboardTeam scoreboardteam, int i)
{
this.a = scoreboardteam.getName();
this.f = i;
if ((i == 0) || (i == 2))
{
this.b = scoreboardteam.getDisplayName();
this.c = scoreboardteam.getPrefix();
this.d = scoreboardteam.getSuffix();
this.g = scoreboardteam.packOptionData();
this._nameTagVisibility = scoreboardteam.getNametagVisibility();
}
if (i == 0) {
this.e.addAll(scoreboardteam.getPlayerNameSet());
}
}
public PacketPlayOutScoreboardTeam(ScoreboardTeam scoreboardteam, Collection collection, int i)
{
if ((i != 3) && (i != 4)) {
throw new IllegalArgumentException("Method must be join or leave for player constructor");
}
if ((collection != null) && (!collection.isEmpty()))
{
this.f = i;
this.a = scoreboardteam.getName();
this.e.addAll(collection);
this._nameTagVisibility = _nameTagVisibility;
}
else
{
throw new IllegalArgumentException("Players cannot be null/empty");
}
}
public void a(PacketDataSerializer packetdataserializer)
throws IOException
{
this.a = packetdataserializer.c(16);
this.f = packetdataserializer.readByte();
if ((this.f == 0) || (this.f == 2))
{
this.b = packetdataserializer.c(32);
this.c = packetdataserializer.c(16);
this.d = packetdataserializer.c(16);
this.g = packetdataserializer.readByte();
}
if ((this.f == 0) || (this.f == 3) || (this.f == 4))
{
short short1 = packetdataserializer.readShort();
for (int i = 0; i < short1; i++) {
this.e.add(packetdataserializer.c(40));
}
}
}
public void b(PacketDataSerializer packetdataserializer)
throws IOException
{
packetdataserializer.a(this.a);
packetdataserializer.writeByte(this.f);
if ((this.f == 0) || (this.f == 2))
{
packetdataserializer.a(this.b);
packetdataserializer.a(this.c);
packetdataserializer.a(this.d);
packetdataserializer.writeByte(this.g);
if (packetdataserializer.version >= 16)
{
packetdataserializer.a(_nameTagVisibility);
packetdataserializer.writeByte(EnumChatFormat.WHITE.ordinal());
}
}
if ((this.f == 0) || (this.f == 3) || (this.f == 4))
{
if (packetdataserializer.version < 16) {
packetdataserializer.writeShort(this.e.size());
} else {
packetdataserializer.b(this.e.size());
}
Iterator iterator = this.e.iterator();
while (iterator.hasNext())
{
String s = (String)iterator.next();
packetdataserializer.a(s);
}
}
}
public void a(PacketPlayOutListener packetplayoutlistener)
{
packetplayoutlistener.a(this);
}
public void handle(PacketListener packetlistener)
{
a((PacketPlayOutListener)packetlistener);
}
}

View File

@ -0,0 +1,135 @@
package net.minecraft.server.v1_7_R4;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class ScoreboardTeam
extends ScoreboardTeamBase
{
private final Scoreboard a;
private final String b;
private final Set c = new HashSet();
private String d;
private String e = "";
private String f = "";
private String _nametagVisibility = "always";
private boolean g = true;
private boolean h = true;
public ScoreboardTeam(Scoreboard paramScoreboard, String paramString)
{
this.a = paramScoreboard;
this.b = paramString;
this.d = paramString;
}
public String getName()
{
return this.b;
}
public String getDisplayName()
{
return this.d;
}
public void setDisplayName(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Name cannot be null");
}
this.d = paramString;
this.a.handleTeamChanged(this);
}
public Collection getPlayerNameSet()
{
return this.c;
}
public String getPrefix()
{
return this.e;
}
public void setPrefix(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Prefix cannot be null");
}
this.e = paramString;
this.a.handleTeamChanged(this);
}
public String getSuffix()
{
return this.f;
}
public void setSuffix(String paramString)
{
if (paramString == null) {
throw new IllegalArgumentException("Suffix cannot be null");
}
this.f = paramString;
this.a.handleTeamChanged(this);
}
public String getFormattedName(String paramString)
{
return getPrefix() + paramString + getSuffix();
}
public static String getPlayerDisplayName(ScoreboardTeamBase paramScoreboardTeamBase, String paramString)
{
if (paramScoreboardTeamBase == null) {
return paramString;
}
return paramScoreboardTeamBase.getFormattedName(paramString);
}
public boolean allowFriendlyFire()
{
return this.g;
}
public void setAllowFriendlyFire(boolean paramBoolean)
{
this.g = paramBoolean;
this.a.handleTeamChanged(this);
}
public boolean canSeeFriendlyInvisibles()
{
return this.h;
}
public void setCanSeeFriendlyInvisibles(boolean paramBoolean)
{
this.h = paramBoolean;
this.a.handleTeamChanged(this);
}
public String getNametagVisibility()
{
return _nametagVisibility;
}
public void setNametagVisibility(String visibility)
{
_nametagVisibility = visibility;
}
public int packOptionData()
{
int i = 0;
if (allowFriendlyFire()) {
i |= 0x1;
}
if (canSeeFriendlyInvisibles()) {
i |= 0x2;
}
return i;
}
}

View File

@ -0,0 +1,225 @@
package org.bukkit.craftbukkit.v1_7_R4.scoreboard;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.scoreboard.Team;
import org.bukkit.scoreboard.TeamNameTagVisibility;
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
import com.google.common.collect.ImmutableSet;
import org.apache.commons.lang.Validate;
final class CraftTeam
extends CraftScoreboardComponent
implements Team
{
private final ScoreboardTeam team;
CraftTeam(CraftScoreboard scoreboard, ScoreboardTeam team)
{
super(scoreboard);
this.team = team;
scoreboard.teams.put(team.getName(), this);
}
public String getName()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getName();
}
public String getDisplayName()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getDisplayName();
}
public void setDisplayName(String displayName)
throws IllegalStateException
{
Validate.notNull(displayName, "Display name cannot be null");
Validate.isTrue(displayName.length() <= 32, "Display name '" + displayName + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setDisplayName(displayName);
}
public String getPrefix()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getPrefix();
}
public void setPrefix(String prefix)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(prefix, "Prefix cannot be null");
Validate.isTrue(prefix.length() <= 32, "Prefix '" + prefix + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setPrefix(prefix);
}
public String getSuffix()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getSuffix();
}
public void setSuffix(String suffix)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(suffix, "Suffix cannot be null");
Validate.isTrue(suffix.length() <= 32, "Suffix '" + suffix + "' is longer than the limit of 32 characters");
CraftScoreboard scoreboard = checkState();
this.team.setSuffix(suffix);
}
public boolean allowFriendlyFire()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.allowFriendlyFire();
}
// Mineplex
@Override
public void setNameTagVisibility(TeamNameTagVisibility visibility) throws IllegalStateException
{
this.team.setNametagVisibility(visibility.toString());
}
public void setAllowFriendlyFire(boolean enabled)
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
this.team.setAllowFriendlyFire(enabled);
}
public boolean canSeeFriendlyInvisibles()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.canSeeFriendlyInvisibles();
}
public void setCanSeeFriendlyInvisibles(boolean enabled)
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
this.team.setCanSeeFriendlyInvisibles(enabled);
}
public Set<OfflinePlayer> getPlayers()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder();
for (Object o : this.team.getPlayerNameSet()) {
players.add(Bukkit.getOfflinePlayer(o.toString()));
}
return players.build();
}
public Set<String> getEntries()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
ImmutableSet.Builder<String> entries = ImmutableSet.builder();
for (Object o : this.team.getPlayerNameSet()) {
entries.add(o.toString());
}
return entries.build();
}
public int getSize()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
return this.team.getPlayerNameSet().size();
}
public void addPlayer(OfflinePlayer player)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
addEntry(player.getName());
}
public void addEntry(String entry)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(entry, "Entry cannot be null");
CraftScoreboard scoreboard = checkState();
scoreboard.board.addPlayerToTeam(entry, this.team.getName());
}
public boolean removePlayer(OfflinePlayer player)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
return removeEntry(player.getName());
}
public boolean removeEntry(String entry)
throws IllegalStateException, IllegalArgumentException
{
Validate.notNull(entry, "Entry cannot be null");
CraftScoreboard scoreboard = checkState();
if (!this.team.getPlayerNameSet().contains(entry)) {
return false;
}
scoreboard.board.removePlayerFromTeam(entry, this.team);
return true;
}
public boolean hasPlayer(OfflinePlayer player)
throws IllegalArgumentException, IllegalStateException
{
Validate.notNull(player, "OfflinePlayer cannot be null");
return hasEntry(player.getName());
}
public boolean hasEntry(String entry)
throws IllegalArgumentException, IllegalStateException
{
Validate.notNull("Entry cannot be null");
CraftScoreboard scoreboard = checkState();
return this.team.getPlayerNameSet().contains(entry);
}
public void unregister()
throws IllegalStateException
{
CraftScoreboard scoreboard = checkState();
scoreboard.board.removeTeam(this.team);
scoreboard.teams.remove(this.team.getName());
setUnregistered();
}
}

View File

@ -0,0 +1,77 @@
package org.bukkit.scoreboard;
import java.util.Set;
import org.bukkit.OfflinePlayer;
public abstract interface Team
{
public abstract String getName()
throws IllegalStateException;
public abstract String getDisplayName()
throws IllegalStateException;
public abstract void setDisplayName(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract String getPrefix()
throws IllegalStateException;
public abstract void setPrefix(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract String getSuffix()
throws IllegalStateException;
public abstract void setSuffix(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean allowFriendlyFire()
throws IllegalStateException;
// Mineplex
public abstract void setNameTagVisibility(TeamNameTagVisibility visibility)
throws IllegalStateException;
public abstract void setAllowFriendlyFire(boolean paramBoolean)
throws IllegalStateException;
public abstract boolean canSeeFriendlyInvisibles()
throws IllegalStateException;
public abstract void setCanSeeFriendlyInvisibles(boolean paramBoolean)
throws IllegalStateException;
public abstract Set<OfflinePlayer> getPlayers()
throws IllegalStateException;
public abstract Set<String> getEntries()
throws IllegalStateException;
public abstract int getSize()
throws IllegalStateException;
public abstract Scoreboard getScoreboard();
public abstract void addPlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalStateException, IllegalArgumentException;
public abstract void addEntry(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean removePlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalStateException, IllegalArgumentException;
public abstract boolean removeEntry(String paramString)
throws IllegalStateException, IllegalArgumentException;
public abstract void unregister()
throws IllegalStateException;
public abstract boolean hasPlayer(OfflinePlayer paramOfflinePlayer)
throws IllegalArgumentException, IllegalStateException;
public abstract boolean hasEntry(String paramString)
throws IllegalArgumentException, IllegalStateException;
}

View File

@ -0,0 +1,22 @@
package org.bukkit.scoreboard;
/**
* Created by shaun on 14-10-05.
*/
public enum TeamNameTagVisibility
{
NEVER("never"), HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"), HIDE_FOR_OWN_TEAM("hideForOwnTeam"), ALWAYS("always");
private String _keyword;
TeamNameTagVisibility(String keyword)
{
_keyword = keyword;
}
@Override
public String toString()
{
return _keyword;
}
}

Binary file not shown.