S3EPacketTeams .java

net.minecraft.network.play.server.S3EPacketTeams (class, 188 lines): members: getFriendlyFlags, friendlyFlags, getPrefix, getSuffix, prefix, suffix, color.

net.minecraft.network.play.serverclass188 linesserver5.0 KB

Implements

API Surface (12)

void readPacketData(PacketBuffer buf)
void writePacketData(PacketBuffer buf)
void processPacket(INetHandlerPlayClient handler)
String getName()
String getDisplayName()
String getPrefix()
String getSuffix()
Collection<String> getPlayers()
int getAction()
int getFriendlyFlags()
int getColor()
String getNameTagVisibility()

Fields & Constants (9)

name
displayName
prefix
suffix
nameTagVisibility
color
players
action
friendlyFlags

String literals (1)

"Players cannot be null/empty"

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

S3EPacketTeams.java188 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.network.play.server;
2
3
import com.google.common.collect.Lists;
4
import java.io.IOException;
5
import java.util.Collection;
6
import net.minecraft.network.Packet;
7
import net.minecraft.network.PacketBuffer;
8
import net.minecraft.network.play.INetHandlerPlayClient;
9
import net.minecraft.scoreboard.ScorePlayerTeam;
10
import net.minecraft.scoreboard.Team;
11
12
public class S3EPacketTeams implements Packet<INetHandlerPlayClient>
13
{
14
    private String name = "";
15
    private String displayName = "";
16
    private String prefix = "";
17
    private String suffix = "";
18
    private String nameTagVisibility;
19
    private int color;
20
    private Collection<String> players;
21
    private int action;
22
    private int friendlyFlags;
23
24
    public S3EPacketTeams()
25
    {
26
        this.nameTagVisibility = Team.EnumVisible.ALWAYS.internalName;
27
        this.color = -1;
28
        this.players = Lists.<String>newArrayList();
29
    }
30
31
    public S3EPacketTeams(ScorePlayerTeam teamIn, int actionIn)
32
    {
33
        this.nameTagVisibility = Team.EnumVisible.ALWAYS.internalName;
34
        this.color = -1;
35
        this.players = Lists.<String>newArrayList();
36
        this.name = teamIn.getRegisteredName();
37
        this.action = actionIn;
38
39
        if (actionIn == 0 || actionIn == 2)
40
        {
41
            this.displayName = teamIn.getTeamName();
42
            this.prefix = teamIn.getColorPrefix();
43
            this.suffix = teamIn.getColorSuffix();
44
            this.friendlyFlags = teamIn.func_98299_i();
45
            this.nameTagVisibility = teamIn.getNameTagVisibility().internalName;
46
            this.color = teamIn.getChatFormat().getColorIndex();
47
        }
48
49
        if (actionIn == 0)
50
        {
51
            this.players.addAll(teamIn.getMembershipCollection());
52
        }
53
    }
54
55
    public S3EPacketTeams(ScorePlayerTeam teamIn, Collection<String> playersIn, int actionIn)
56
    {
57
        this.nameTagVisibility = Team.EnumVisible.ALWAYS.internalName;
58
        this.color = -1;
59
        this.players = Lists.<String>newArrayList();
60
61
        if (actionIn != 3 && actionIn != 4)
62
        {
63
            throw new IllegalArgumentException("Method must be join or leave for player constructor");
64
        }
65
        else if (playersIn != null && !playersIn.isEmpty())
66
        {
67
            this.action = actionIn;
68
            this.name = teamIn.getRegisteredName();
69
            this.players.addAll(playersIn);
70
        }
71
        else
72
        {
73
            throw new IllegalArgumentException("Players cannot be null/empty");
74
        }
75
    }
76
77
    /**
78
     * Reads the raw packet data from the data stream.
79
     */
80
    public void readPacketData(PacketBuffer buf) throws IOException
81
    {
82
        this.name = buf.readStringFromBuffer(16);
83
        this.action = buf.readByte();
84
85
        if (this.action == 0 || this.action == 2)
86
        {
87
            this.displayName = buf.readStringFromBuffer(32);
88
            this.prefix = buf.readStringFromBuffer(16);
89
            this.suffix = buf.readStringFromBuffer(16);
90
            this.friendlyFlags = buf.readByte();
91
            this.nameTagVisibility = buf.readStringFromBuffer(32);
92
            this.color = buf.readByte();
93
        }
94
95
        if (this.action == 0 || this.action == 3 || this.action == 4)
96
        {
97
            int i = buf.readVarIntFromBuffer();
98
99
            for (int j = 0; j < i; ++j)
100
            {
101
                this.players.add(buf.readStringFromBuffer(40));
102
            }
103
        }
104
    }
105
106
    /**
107
     * Writes the raw packet data to the data stream.
108
     */
109
    public void writePacketData(PacketBuffer buf) throws IOException
110
    {
111
        buf.writeString(this.name);
112
        buf.writeByte(this.action);
113
114
        if (this.action == 0 || this.action == 2)
115
        {
116
            buf.writeString(this.displayName);
117
            buf.writeString(this.prefix);
118
            buf.writeString(this.suffix);
119
            buf.writeByte(this.friendlyFlags);
120
            buf.writeString(this.nameTagVisibility);
121
            buf.writeByte(this.color);
122
        }
123
124
        if (this.action == 0 || this.action == 3 || this.action == 4)
125
        {
126
            buf.writeVarIntToBuffer(this.players.size());
127
128
            for (String s : this.players)
129
            {
130
                buf.writeString(s);
131
            }
132
        }
133
    }
134
135
    /**
136
     * Passes this Packet on to the NetHandler for processing.
137
     */
138
    public void processPacket(INetHandlerPlayClient handler)
139
    {
140
        handler.handleTeams(this);
141
    }
142
143
    public String getName()
144
    {
145
        return this.name;
146
    }
147
148
    public String getDisplayName()
149
    {
150
        return this.displayName;
151
    }
152
153
    public String getPrefix()
154
    {
155
        return this.prefix;
156
    }
157
158
    public String getSuffix()
159
    {
160
        return this.suffix;
161
    }
162
163
    public Collection<String> getPlayers()
164
    {
165
        return this.players;
166
    }
167
168
    public int getAction()
169
    {
170
        return this.action;
171
    }
172
173
    public int getFriendlyFlags()
174
    {
175
        return this.friendlyFlags;
176
    }
177
178
    public int getColor()
179
    {
180
        return this.color;
181
    }
182
183
    public String getNameTagVisibility()
184
    {
185
        return this.nameTagVisibility;
186
    }
187
}
188

Deobfuscated MCP 1.8.9 source of S3EPacketTeams from Marcelektro/MavenMCP-1.8.9 (net/minecraft/network/play/server/S3EPacketTeams.java), stored verbatim.