forked from SpigotMC/BungeeCord
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/SpigotMC/BungeeCord
- Loading branch information
Showing
7 changed files
with
174 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
protocol/src/main/java/net/md_5/bungee/protocol/packet/DisconnectReportDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package net.md_5.bungee.protocol.packet; | ||
|
||
import com.google.common.base.Preconditions; | ||
import io.netty.buffer.ByteBuf; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import net.md_5.bungee.protocol.AbstractPacketHandler; | ||
import net.md_5.bungee.protocol.DefinedPacket; | ||
import net.md_5.bungee.protocol.ProtocolConstants; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class DisconnectReportDetails extends DefinedPacket | ||
{ | ||
|
||
private Map<String, String> details; | ||
|
||
@Override | ||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) | ||
{ | ||
int len = readVarInt( buf ); | ||
Preconditions.checkArgument( len <= 32, "Too many details" ); | ||
|
||
details = new HashMap<>(); | ||
for ( int i = 0; i < len; i++ ) | ||
{ | ||
details.put( readString( buf, 128 ), readString( buf, 4096 ) ); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) | ||
{ | ||
Preconditions.checkArgument( details.size() <= 32, "Too many details" ); | ||
writeVarInt( details.size(), buf ); | ||
|
||
for ( Map.Entry<String, String> detail : details.entrySet() ) | ||
{ | ||
writeString( detail.getKey(), buf, 128 ); | ||
writeString( detail.getValue(), buf, 4096 ); | ||
} | ||
} | ||
|
||
@Override | ||
public void handle(AbstractPacketHandler handler) throws Exception | ||
{ | ||
handler.handle( this ); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
protocol/src/main/java/net/md_5/bungee/protocol/packet/ServerLinks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package net.md_5.bungee.protocol.packet; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
import net.md_5.bungee.api.chat.BaseComponent; | ||
import net.md_5.bungee.protocol.AbstractPacketHandler; | ||
import net.md_5.bungee.protocol.DefinedPacket; | ||
import net.md_5.bungee.protocol.Either; | ||
import net.md_5.bungee.protocol.ProtocolConstants; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class ServerLinks extends DefinedPacket | ||
{ | ||
|
||
private Link[] links; | ||
|
||
@Override | ||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) | ||
{ | ||
int len = readVarInt( buf ); | ||
links = new Link[ len ]; | ||
for ( int i = 0; i < len; i++ ) | ||
{ | ||
Either<LinkType, BaseComponent> type; | ||
if ( buf.readBoolean() ) | ||
{ | ||
type = Either.left( LinkType.values()[readVarInt( buf )] ); | ||
} else | ||
{ | ||
type = Either.right( readBaseComponent( buf, protocolVersion ) ); | ||
} | ||
String url = readString( buf ); | ||
|
||
links[i] = new Link( type, url ); | ||
} | ||
} | ||
|
||
@Override | ||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion) | ||
{ | ||
writeVarInt( links.length, buf ); | ||
for ( Link link : links ) | ||
{ | ||
Either<LinkType, BaseComponent> type = link.getType(); | ||
if ( type.isLeft() ) | ||
{ | ||
buf.writeBoolean( true ); | ||
writeVarInt( type.getLeft().ordinal(), buf ); | ||
} else | ||
{ | ||
buf.writeBoolean( false ); | ||
writeBaseComponent( type.getRight(), buf, protocolVersion ); | ||
} | ||
writeString( link.getUrl(), buf ); | ||
} | ||
} | ||
|
||
@Override | ||
public void handle(AbstractPacketHandler handler) throws Exception | ||
{ | ||
handler.handle( this ); | ||
} | ||
|
||
public enum LinkType | ||
{ | ||
REPORT_BUG; | ||
} | ||
|
||
@Data | ||
public static class Link | ||
{ | ||
|
||
private final Either<LinkType, BaseComponent> type; | ||
private final String url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters