Add scoreboard packets + API classes. Still unimplemented.
This commit is contained in:
parent
34f4bae923
commit
156ea30c32
@ -0,0 +1,20 @@
|
||||
package net.md_5.bungee.api.scoreboard;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Represents an objective entry.
|
||||
*/
|
||||
@Data
|
||||
public class Objective
|
||||
{
|
||||
|
||||
/**
|
||||
* Name of the objective.
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* Value of the objective.
|
||||
*/
|
||||
private final String value;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package net.md_5.bungee.api.scoreboard;
|
||||
|
||||
/**
|
||||
* Represents locations for a scoreboard to be displayed.
|
||||
*/
|
||||
public enum Position
|
||||
{
|
||||
|
||||
LIST, SIDEBAR, BELOW;
|
||||
}
|
24
api/src/main/java/net/md_5/bungee/api/scoreboard/Score.java
Normal file
24
api/src/main/java/net/md_5/bungee/api/scoreboard/Score.java
Normal file
@ -0,0 +1,24 @@
|
||||
package net.md_5.bungee.api.scoreboard;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Represents a scoreboard score entry.
|
||||
*/
|
||||
@Data
|
||||
public class Score
|
||||
{
|
||||
|
||||
/**
|
||||
* Name to be displayed in the list.
|
||||
*/
|
||||
private final String itemName;
|
||||
/**
|
||||
* Unique name of the score.
|
||||
*/
|
||||
private final String scoreName;
|
||||
/**
|
||||
* Value of the score.
|
||||
*/
|
||||
private final int value;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.api.scoreboard;
|
||||
|
||||
import java.util.Collection;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -11,7 +12,15 @@ public class Scoreboard
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* Text to be displayed with this scoreboard.
|
||||
* Position of this scoreboard.
|
||||
*/
|
||||
private final String text;
|
||||
private final Position position;
|
||||
/**
|
||||
* Objectives for this scoreboard.
|
||||
*/
|
||||
private final Collection<Objective> objectives;
|
||||
/**
|
||||
* Scores for this scoreboard.
|
||||
*/
|
||||
private final Collection<Score> scores;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class PacketDefinitions
|
||||
public enum OpCode
|
||||
{
|
||||
|
||||
BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, TEAM, USHORT_BYTE
|
||||
BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SCORE, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, TEAM, USHORT_BYTE
|
||||
}
|
||||
|
||||
static
|
||||
@ -307,7 +307,7 @@ public class PacketDefinitions
|
||||
};
|
||||
opCodes[0xCF] = new OpCode[]
|
||||
{
|
||||
STRING, BYTE, STRING, INT
|
||||
SCORE
|
||||
};
|
||||
opCodes[0xD0] = new OpCode[]
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ import net.md_5.bungee.packet.DefinedPacket;
|
||||
import net.md_5.bungee.packet.Packet1Login;
|
||||
import net.md_5.bungee.packet.Packet9Respawn;
|
||||
import net.md_5.bungee.packet.PacketCDClientStatus;
|
||||
import net.md_5.bungee.packet.PacketCESetScoreboard;
|
||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
||||
import net.md_5.bungee.packet.PacketFDEncryptionRequest;
|
||||
import net.md_5.bungee.packet.PacketFFKick;
|
||||
import net.md_5.bungee.packet.PacketHandler;
|
||||
@ -91,10 +91,6 @@ public class ServerConnector extends PacketHandler
|
||||
{
|
||||
bungee.getTabListHandler().onServerChange( user );
|
||||
|
||||
if ( user.serverSentScoreboard != null )
|
||||
{
|
||||
user.sendPacket( new PacketCESetScoreboard( user.serverSentScoreboard.getName(), user.serverSentScoreboard.getText(), (byte) 1 ) );
|
||||
}
|
||||
user.sendPacket( Packet9Respawn.DIM1_SWITCH );
|
||||
user.sendPacket( Packet9Respawn.DIM2_SWITCH );
|
||||
|
||||
|
@ -18,7 +18,7 @@ import net.md_5.bungee.api.scoreboard.Scoreboard;
|
||||
import net.md_5.bungee.packet.Packet0KeepAlive;
|
||||
import net.md_5.bungee.packet.Packet3Chat;
|
||||
import net.md_5.bungee.packet.PacketC9PlayerListItem;
|
||||
import net.md_5.bungee.packet.PacketCESetScoreboard;
|
||||
import net.md_5.bungee.packet.PacketCEScoreboardObjective;
|
||||
import net.md_5.bungee.packet.PacketFAPluginMessage;
|
||||
import net.md_5.bungee.packet.PacketFFKick;
|
||||
import net.md_5.bungee.packet.PacketHandler;
|
||||
@ -75,12 +75,6 @@ public class DownstreamBridge extends PacketHandler
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketCESetScoreboard scoreboard) throws Exception
|
||||
{
|
||||
con.serverSentScoreboard = new Scoreboard( scoreboard.name, scoreboard.text );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketC9PlayerListItem playerList) throws Exception
|
||||
{
|
||||
|
@ -226,7 +226,9 @@ public abstract class DefinedPacket implements DataOutput
|
||||
classes[0x09] = Packet9Respawn.class;
|
||||
classes[0xC9] = PacketC9PlayerListItem.class;
|
||||
classes[0xCD] = PacketCDClientStatus.class;
|
||||
classes[0xCE] = PacketCESetScoreboard.class;
|
||||
classes[0xCE] = PacketCEScoreboardObjective.class;
|
||||
classes[0xCF] = PacketCFScoreboardScore.class;
|
||||
classes[0xD0] = PacketD0DisplayScoreboard.class;
|
||||
classes[0xFA] = PacketFAPluginMessage.class;
|
||||
classes[0xFC] = PacketFCEncryptionResponse.class;
|
||||
classes[0xFD] = PacketFDEncryptionRequest.class;
|
||||
|
@ -5,7 +5,7 @@ import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PacketCESetScoreboard extends DefinedPacket
|
||||
public class PacketCEScoreboardObjective extends DefinedPacket
|
||||
{
|
||||
|
||||
public String name;
|
||||
@ -15,7 +15,7 @@ public class PacketCESetScoreboard extends DefinedPacket
|
||||
*/
|
||||
public byte status;
|
||||
|
||||
public PacketCESetScoreboard(String name, String text, byte status)
|
||||
public PacketCEScoreboardObjective(String name, String text, byte status)
|
||||
{
|
||||
super( 0xCE );
|
||||
writeUTF( name );
|
||||
@ -26,7 +26,7 @@ public class PacketCESetScoreboard extends DefinedPacket
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
PacketCESetScoreboard(byte[] buf)
|
||||
PacketCEScoreboardObjective(byte[] buf)
|
||||
{
|
||||
super( 0xCE, buf );
|
||||
this.name = readUTF();
|
@ -0,0 +1,36 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PacketCFScoreboardScore extends DefinedPacket
|
||||
{
|
||||
|
||||
public String itemName;
|
||||
/**
|
||||
* 0 = create / update, 1 = remove.
|
||||
*/
|
||||
public byte action;
|
||||
public String scoreName;
|
||||
public int value;
|
||||
|
||||
public PacketCFScoreboardScore(byte[] buf)
|
||||
{
|
||||
super( 0xCF, buf );
|
||||
itemName = readUTF();
|
||||
action = readByte();
|
||||
if ( action == 0 )
|
||||
{
|
||||
scoreName = readUTF();
|
||||
value = readInt();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package net.md_5.bungee.packet;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class PacketD0DisplayScoreboard extends DefinedPacket
|
||||
{
|
||||
|
||||
/**
|
||||
* 0 = list, 1 = side, 2 = below.
|
||||
*/
|
||||
public byte position;
|
||||
public String name;
|
||||
|
||||
public PacketD0DisplayScoreboard(byte[] buf)
|
||||
{
|
||||
super( 0xCF, buf );
|
||||
position = readByte();
|
||||
name = readUTF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(PacketHandler handler) throws Exception
|
||||
{
|
||||
handler.handle( this );
|
||||
}
|
||||
}
|
@ -56,7 +56,15 @@ public abstract class PacketHandler
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCESetScoreboard scoreboard) throws Exception
|
||||
public void handle(PacketCEScoreboardObjective objective) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketCFScoreboardScore score) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user