Compare commits
36 Commits
3aab2fa1e1
...
16646efb3c
Author | SHA1 | Date | |
---|---|---|---|
16646efb3c | |||
ec1e8483b9 | |||
d39b527c3e | |||
af9e6d9118 | |||
da736d8ad9 | |||
57da3ee6ca | |||
![]() |
296b31bd56 | ||
![]() |
8f6768ae00 | ||
![]() |
70603d5413 | ||
![]() |
2e12caad03 | ||
![]() |
f9ce9fad28 | ||
![]() |
69b476fcbc | ||
![]() |
d37a430f5a | ||
![]() |
4c02676b7a | ||
![]() |
a2558484f5 | ||
![]() |
97c6167272 | ||
![]() |
c2162eeddb | ||
![]() |
0124b66918 | ||
![]() |
7be06f141d | ||
![]() |
01048b4fca | ||
![]() |
d2a317eee2 | ||
![]() |
0be632a4d6 | ||
![]() |
f27f4fbca9 | ||
![]() |
e62fc6c291 | ||
![]() |
8e99a4c5bf | ||
![]() |
df53053677 | ||
![]() |
4cd9a17a40 | ||
![]() |
e9558ab370 | ||
![]() |
3a5c731826 | ||
![]() |
c13e6df67e | ||
![]() |
704e866413 | ||
![]() |
aea5870ac8 | ||
![]() |
f1a4a42d51 | ||
![]() |
a485d9f314 | ||
![]() |
131125c7d2 | ||
![]() |
7fcc62067b |
2
.github/workflows/maven.yml
vendored
2
.github/workflows/maven.yml
vendored
@@ -9,7 +9,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
java: [8, 11, 17, 21, 25-ea]
|
||||
java: [8, 11, 17, 21, 25]
|
||||
|
||||
name: Java ${{ matrix.java }}
|
||||
|
||||
|
10
api/pom.xml
10
api/pom.xml
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-API</name>
|
||||
@@ -74,6 +74,12 @@
|
||||
<!-- not part of the API proper -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<version>9.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
|
77
api/src/main/java/net/md_5/bungee/api/ServerLink.java
Normal file
77
api/src/main/java/net/md_5/bungee/api/ServerLink.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
* Represents a server link which may be sent to the client.
|
||||
*/
|
||||
@Data
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class ServerLink
|
||||
{
|
||||
|
||||
/**
|
||||
* The links type.
|
||||
*
|
||||
* Note: This value is nullable, if null, label is non-null.
|
||||
*/
|
||||
private final LinkType type;
|
||||
|
||||
/**
|
||||
* The label for the link.
|
||||
*
|
||||
* Note: This value is nullable, if null, type is non-null.
|
||||
*/
|
||||
private final BaseComponent label;
|
||||
|
||||
/**
|
||||
* The URL that is displayed.
|
||||
*/
|
||||
@NonNull
|
||||
private final String url;
|
||||
|
||||
/**
|
||||
* Creates a link with a specified type and URL.
|
||||
*
|
||||
* @param type the type of the link
|
||||
* @param url the URL to be displayed
|
||||
*/
|
||||
public ServerLink(@NonNull LinkType type, @NonNull String url)
|
||||
{
|
||||
this.type = type;
|
||||
this.label = null;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a link with a label and URL.
|
||||
*
|
||||
* @param label the label to be displayed
|
||||
* @param url the URL to be displayed
|
||||
*/
|
||||
public ServerLink(@NonNull BaseComponent label, @NonNull String url)
|
||||
{
|
||||
this.type = null;
|
||||
this.label = label;
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public enum LinkType
|
||||
{
|
||||
|
||||
REPORT_BUG,
|
||||
COMMUNITY_GUIDELINES,
|
||||
SUPPORT,
|
||||
STATUS,
|
||||
FEEDBACK,
|
||||
COMMUNITY,
|
||||
WEBSITE,
|
||||
FORUMS,
|
||||
NEWS,
|
||||
ANNOUNCEMENTS;
|
||||
}
|
||||
}
|
@@ -87,8 +87,10 @@ public interface Connection
|
||||
|
||||
/**
|
||||
* Queue a packet to this connection.
|
||||
* If the packet is not registered for the connections current encoder protocol, it will be queued until it is,
|
||||
* otherwise it will be sent immediately.
|
||||
*
|
||||
* If the packet is not registered for the connections current encoder
|
||||
* protocol, it will be queued until it is, otherwise it will be sent
|
||||
* immediately.
|
||||
*
|
||||
* @param packet the packet to be queued
|
||||
* @throws UnsupportedOperationException if used for a PendingConnection
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@@ -8,6 +9,7 @@ import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ServerConnectRequest;
|
||||
import net.md_5.bungee.api.ServerLink;
|
||||
import net.md_5.bungee.api.SkinConfiguration;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -386,6 +388,7 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
|
||||
/**
|
||||
* Gets the client brand of this player.
|
||||
*
|
||||
* If the player has not sent a brand packet yet, it will return null.
|
||||
*
|
||||
* @return the brand of the client, or null if not received yet
|
||||
@@ -410,4 +413,16 @@ public interface ProxiedPlayer extends Connection, CommandSender
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
void showDialog(Dialog dialog);
|
||||
|
||||
/**
|
||||
* Sends server links to the player.
|
||||
*
|
||||
* Note: The links already sent to the player will be overwritten. Also, the
|
||||
* backend server is able to override links sent by the proxy.
|
||||
*
|
||||
* @param serverLinks the server links to send
|
||||
* @throws IllegalStateException if the player's version is not at least
|
||||
* 1.21
|
||||
*/
|
||||
void sendServerLinks(List<ServerLink> serverLinks);
|
||||
}
|
||||
|
@@ -11,6 +11,7 @@ import lombok.Getter;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
import net.md_5.bungee.api.scheduler.GroupedThreadFactory;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* Represents any Plugin that may be loaded at runtime to enhance existing
|
||||
@@ -108,7 +109,14 @@ public class Plugin
|
||||
//
|
||||
private ExecutorService service;
|
||||
|
||||
/**
|
||||
* Returns the executor service associated with this plugin.
|
||||
*
|
||||
* @return the executor service for this plugin
|
||||
* @deprecated internal API. Use {@link ProxyServer#getScheduler()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.Internal
|
||||
public ExecutorService getExecutorService()
|
||||
{
|
||||
if ( service == null )
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -9,13 +10,20 @@ import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.security.CodeSigner;
|
||||
import java.security.CodeSource;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.commons.ClassRemapper;
|
||||
import org.objectweb.asm.commons.SimpleRemapper;
|
||||
|
||||
@ToString(of = "desc")
|
||||
final class PluginClassloader extends URLClassLoader
|
||||
@@ -121,6 +129,15 @@ final class PluginClassloader extends URLClassLoader
|
||||
throw new ClassNotFoundException( name, ex );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
classBytes = remap( classBytes );
|
||||
} catch ( Exception ex )
|
||||
{
|
||||
Logger logger = ( plugin != null ) ? plugin.getLogger() : proxy.getLogger();
|
||||
logger.log( Level.SEVERE, "Error trying to remap class " + path, ex );
|
||||
}
|
||||
|
||||
int dot = name.lastIndexOf( '.' );
|
||||
if ( dot != -1 )
|
||||
{
|
||||
@@ -155,6 +172,27 @@ final class PluginClassloader extends URLClassLoader
|
||||
return super.findClass( name );
|
||||
}
|
||||
|
||||
private static final Map<String, String> MAPPINGS = ImmutableMap.of(
|
||||
"net/md_5/bungee/protocol/ChatChain", "net/md_5/bungee/protocol/data/ChatChain",
|
||||
"net/md_5/bungee/protocol/Location", "net/md_5/bungee/protocol/data/Location",
|
||||
"net/md_5/bungee/protocol/NumberFormat", "net/md_5/bungee/protocol/data/NumberFormat",
|
||||
"net/md_5/bungee/protocol/PlayerPublicKey", "net/md_5/bungee/protocol/data/PlayerPublicKey",
|
||||
"net/md_5/bungee/protocol/Property", "net/md_5/bungee/protocol/data/Property",
|
||||
"net/md_5/bungee/protocol/SeenMessages", "net/md_5/bungee/protocol/data/SeenMessages",
|
||||
"net/md_5/bungee/protocol/Either", "net/md_5/bungee/protocol/util/Either",
|
||||
"net/md_5/bungee/protocol/TagUtil", "net/md_5/bungee/protocol/util/TagUtil"
|
||||
);
|
||||
|
||||
private static byte[] remap(byte[] b)
|
||||
{
|
||||
ClassReader cr = new ClassReader( b );
|
||||
ClassWriter cw = new ClassWriter( cr, 0 );
|
||||
|
||||
cr.accept( new ClassRemapper( cw, new SimpleRemapper( MAPPINGS ) ), 0 );
|
||||
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException
|
||||
{
|
||||
|
@@ -30,6 +30,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import lombok.Locked;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@@ -98,10 +99,8 @@ public final class PluginManager
|
||||
* @param plugin the plugin owning this command
|
||||
* @param command the command to register
|
||||
*/
|
||||
@Locked.Write("commandsLock")
|
||||
public void registerCommand(Plugin plugin, Command command)
|
||||
{
|
||||
commandsLock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
commandMap.put( command.getName().toLowerCase( Locale.ROOT ), command );
|
||||
for ( String alias : command.getAliases() )
|
||||
@@ -109,10 +108,6 @@ public final class PluginManager
|
||||
commandMap.put( alias.toLowerCase( Locale.ROOT ), command );
|
||||
}
|
||||
commandsByPlugin.put( plugin, command );
|
||||
} finally
|
||||
{
|
||||
commandsLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,17 +115,11 @@ public final class PluginManager
|
||||
*
|
||||
* @param command the command to unregister
|
||||
*/
|
||||
@Locked.Write("commandsLock")
|
||||
public void unregisterCommand(Command command)
|
||||
{
|
||||
commandsLock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
while ( commandMap.values().remove( command ) );
|
||||
commandsByPlugin.values().remove( command );
|
||||
} finally
|
||||
{
|
||||
commandsLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,10 +127,8 @@ public final class PluginManager
|
||||
*
|
||||
* @param plugin the plugin to register the commands of
|
||||
*/
|
||||
@Locked.Write("commandsLock")
|
||||
public void unregisterCommands(Plugin plugin)
|
||||
{
|
||||
commandsLock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
for ( Iterator<Command> it = commandsByPlugin.get( plugin ).iterator(); it.hasNext(); )
|
||||
{
|
||||
@@ -149,10 +136,6 @@ public final class PluginManager
|
||||
while ( commandMap.values().remove( command ) );
|
||||
it.remove();
|
||||
}
|
||||
} finally
|
||||
{
|
||||
commandsLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private Command getCommandIfEnabled(String commandName, CommandSender sender)
|
||||
@@ -467,22 +450,15 @@ public final class PluginManager
|
||||
* @param plugin the owning plugin
|
||||
* @param listener the listener to register events for
|
||||
*/
|
||||
@Locked("listenersLock")
|
||||
public void registerListener(Plugin plugin, Listener listener)
|
||||
{
|
||||
listenersLock.lock();
|
||||
try
|
||||
{
|
||||
for ( Method method : listener.getClass().getDeclaredMethods() )
|
||||
{
|
||||
Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ),
|
||||
"Listener %s has registered using deprecated subscribe annotation! Please update to @EventHandler.", listener );
|
||||
Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ), "Listener %s has registered using deprecated subscribe annotation! Please update to @EventHandler.", listener );
|
||||
}
|
||||
eventBus.register( listener );
|
||||
listenersByPlugin.put( plugin, listener );
|
||||
} finally
|
||||
{
|
||||
listenersLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,17 +466,11 @@ public final class PluginManager
|
||||
*
|
||||
* @param listener the listener to unregister
|
||||
*/
|
||||
@Locked("listenersLock")
|
||||
public void unregisterListener(Listener listener)
|
||||
{
|
||||
listenersLock.lock();
|
||||
try
|
||||
{
|
||||
eventBus.unregister( listener );
|
||||
listenersByPlugin.values().remove( listener );
|
||||
} finally
|
||||
{
|
||||
listenersLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,20 +478,14 @@ public final class PluginManager
|
||||
*
|
||||
* @param plugin target plugin
|
||||
*/
|
||||
@Locked("listenersLock")
|
||||
public void unregisterListeners(Plugin plugin)
|
||||
{
|
||||
listenersLock.lock();
|
||||
try
|
||||
{
|
||||
for ( Iterator<Listener> it = listenersByPlugin.get( plugin ).iterator(); it.hasNext(); )
|
||||
{
|
||||
eventBus.unregister( it.next() );
|
||||
it.remove();
|
||||
}
|
||||
} finally
|
||||
{
|
||||
listenersLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,16 +493,10 @@ public final class PluginManager
|
||||
*
|
||||
* @return commands
|
||||
*/
|
||||
@Locked.Read("commandsLock")
|
||||
public Collection<Map.Entry<String, Command>> getCommands()
|
||||
{
|
||||
commandsLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
return Collections.unmodifiableCollection( commandMap.entrySet() );
|
||||
} finally
|
||||
{
|
||||
commandsLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
boolean isTransitiveDepend(PluginDescription plugin, PluginDescription depend)
|
||||
|
@@ -6,18 +6,19 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-bootstrap</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Bootstrap</name>
|
||||
<description>Java 1.6 loader for BungeeCord</description>
|
||||
|
||||
<properties>
|
||||
<skipPublishing>true</skipPublishing>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
<maven.build.timestamp.format>yyyyMMdd</maven.build.timestamp.format>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Chat</name>
|
||||
|
@@ -313,8 +313,9 @@ public abstract class BaseComponent
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shadow color of this component. This uses the parent's shadow color if this
|
||||
* component doesn't have one. null is returned if no shadow color is found.
|
||||
* Returns the shadow color of this component. This uses the parent's shadow
|
||||
* color if this component doesn't have one. null is returned if no shadow
|
||||
* color is found.
|
||||
*
|
||||
* @return the shadow color of this component
|
||||
*/
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api.chat;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
@@ -351,6 +352,19 @@ public final class ComponentBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the shadow color of the current part.
|
||||
*
|
||||
* @param color the new shadow color
|
||||
* @return this ComponentBuilder for chaining
|
||||
* @since Minecraft 1.21.4-pre1
|
||||
*/
|
||||
public ComponentBuilder shadowColor(Color color)
|
||||
{
|
||||
getCurrentComponent().setShadowColor( color );
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the font of the current part.
|
||||
*
|
||||
|
@@ -0,0 +1,73 @@
|
||||
package net.md_5.bungee.api.chat;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.chat.objects.ChatObject;
|
||||
|
||||
/**
|
||||
* An object component that can be used to display objects.
|
||||
* <p>
|
||||
* It can either display a player's head or an object by a specific sprite and
|
||||
* an atlas.
|
||||
* <p>
|
||||
* Note: this was added in Minecraft 1.21.9.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public final class ObjectComponent extends BaseComponent
|
||||
{
|
||||
|
||||
private ChatObject object;
|
||||
|
||||
/**
|
||||
* Creates a ObjectComponent from a given ChatObject.
|
||||
*
|
||||
* See {@link net.md_5.bungee.api.chat.objects.PlayerObject} and
|
||||
* {@link net.md_5.bungee.api.chat.objects.SpriteObject}.
|
||||
*
|
||||
* @param object the ChatObject
|
||||
*/
|
||||
public ObjectComponent(@NonNull ChatObject object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object component from the original to clone it.
|
||||
*
|
||||
* @param original the original for the new score component
|
||||
*/
|
||||
public ObjectComponent(ObjectComponent original)
|
||||
{
|
||||
super( original );
|
||||
setObject( original.object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectComponent duplicate()
|
||||
{
|
||||
return new ObjectComponent( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toPlainText(StringVisitor builder)
|
||||
{
|
||||
// I guess we cannot convert this to plain text
|
||||
// builder.append( this.value );
|
||||
super.toPlainText( builder );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void toLegacyText(StringVisitor builder)
|
||||
{
|
||||
addFormat( builder );
|
||||
// Same here...
|
||||
// builder.append( this.value );
|
||||
super.toLegacyText( builder );
|
||||
}
|
||||
}
|
@@ -170,7 +170,7 @@ public final class TextComponent extends BaseComponent
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int pos = message.indexOf( ' ', i );
|
||||
int pos = indexOfSpecial( message, i );
|
||||
if ( pos == -1 )
|
||||
{
|
||||
pos = message.length();
|
||||
@@ -205,6 +205,20 @@ public final class TextComponent extends BaseComponent
|
||||
appender.accept( component );
|
||||
}
|
||||
|
||||
private static int indexOfSpecial(String message, int pos)
|
||||
{
|
||||
for ( int i = pos; i < message.length(); i++ )
|
||||
{
|
||||
char c = message.charAt( i );
|
||||
|
||||
if ( c == ' ' || Character.isISOControl( c ) )
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal compatibility method to transform an array of components to a
|
||||
* single component.
|
||||
|
@@ -0,0 +1,5 @@
|
||||
package net.md_5.bungee.api.chat.objects;
|
||||
|
||||
public interface ChatObject
|
||||
{
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package net.md_5.bungee.api.chat.objects;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import net.md_5.bungee.api.chat.player.Profile;
|
||||
import net.md_5.bungee.api.chat.player.Property;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public final class PlayerObject implements ChatObject
|
||||
{
|
||||
|
||||
/**
|
||||
* The profile of the player.
|
||||
*/
|
||||
@NonNull
|
||||
private Profile profile;
|
||||
/**
|
||||
* If true, a hat layer will be rendered on the head. (default: true)
|
||||
*/
|
||||
private Boolean hat;
|
||||
|
||||
public PlayerObject(@NonNull String name)
|
||||
{
|
||||
this.profile = new Profile( name );
|
||||
}
|
||||
|
||||
public PlayerObject(@NonNull UUID uuid)
|
||||
{
|
||||
this.profile = new Profile( uuid );
|
||||
}
|
||||
|
||||
public PlayerObject(@NonNull Property[] properties)
|
||||
{
|
||||
this.profile = new Profile( properties );
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
package net.md_5.bungee.api.chat.objects;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public final class SpriteObject implements ChatObject
|
||||
{
|
||||
|
||||
/**
|
||||
* The namespaced ID of a sprite atlas, default value: minecraft:blocks.
|
||||
*/
|
||||
private String atlas;
|
||||
/**
|
||||
* The namespaced ID of a sprite in atlas, for example item/porkchop.
|
||||
*/
|
||||
@NonNull
|
||||
private String sprite;
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
package net.md_5.bungee.api.chat.player;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Profile
|
||||
{
|
||||
|
||||
/**
|
||||
* The name of the profile. Can be null.
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* The UUID of the profile. Can be null.
|
||||
*/
|
||||
private UUID uuid;
|
||||
/**
|
||||
* The properties of the profile. Can be null.
|
||||
*/
|
||||
private Property[] properties;
|
||||
|
||||
public Profile(@NonNull String name)
|
||||
{
|
||||
this( name, null, null );
|
||||
}
|
||||
|
||||
public Profile(@NonNull UUID uuid)
|
||||
{
|
||||
this( null, uuid, null );
|
||||
}
|
||||
|
||||
public Profile(@NonNull Property[] properties)
|
||||
{
|
||||
this( null, null, properties );
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package net.md_5.bungee.api.chat.player;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Property
|
||||
{
|
||||
|
||||
@NonNull
|
||||
private String name;
|
||||
@NonNull
|
||||
private String value;
|
||||
private String signature;
|
||||
|
||||
public Property(@NonNull String name, @NonNull String value)
|
||||
{
|
||||
this( name, value, null );
|
||||
}
|
||||
}
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-config</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Config</name>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-dialog</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Dialog</name>
|
||||
|
@@ -38,7 +38,8 @@ public final class DialogListDialog implements Dialog
|
||||
*/
|
||||
private Integer columns;
|
||||
/**
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum:
|
||||
* 1024).
|
||||
*/
|
||||
@SerializedName("button_width")
|
||||
private Integer buttonWidth;
|
||||
|
@@ -37,7 +37,8 @@ public final class ServerLinksDialog implements Dialog
|
||||
*/
|
||||
private Integer columns;
|
||||
/**
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum:
|
||||
* 1024).
|
||||
*/
|
||||
@SerializedName("button_width")
|
||||
private Integer buttonWidth;
|
||||
|
@@ -6,8 +6,8 @@ import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* Executes a command. If the command requires a permission
|
||||
* higher than 0, a confirmation dialog will be shown by the client.
|
||||
* Executes a command. If the command requires a permission higher than 0, a
|
||||
* confirmation dialog will be shown by the client.
|
||||
*/
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-event</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Event</name>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-log</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Log</name>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-native</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Native</name>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-nbt</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-NBT</name>
|
||||
|
@@ -81,9 +81,8 @@ public interface Tag
|
||||
void write(DataOutput output) throws IOException;
|
||||
|
||||
/**
|
||||
* Reads a {@link Tag} from the given {@link DataInput},
|
||||
* based on the specified tag type, with limitations of the
|
||||
* {@link NBTLimiter}.
|
||||
* Reads a {@link Tag} from the given {@link DataInput}, based on the
|
||||
* specified tag type, with limitations of the {@link NBTLimiter}.
|
||||
*
|
||||
* @param id the nbt type
|
||||
* @param input the input to read from
|
||||
@@ -104,8 +103,8 @@ public interface Tag
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a {@link NamedTag} from the given {@link DataInput},
|
||||
* with limitations of the {@link NBTLimiter}.
|
||||
* Reads a {@link NamedTag} from the given {@link DataInput}, with
|
||||
* limitations of the {@link NBTLimiter}.
|
||||
*
|
||||
* @param input the data input to read from
|
||||
* @param limiter the limiter for this read operation
|
||||
@@ -120,8 +119,8 @@ public interface Tag
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the given {@link TypedTag} into a byte array.
|
||||
* This is the inverse operation of {@link #fromByteArray(byte[])}.
|
||||
* Serializes the given {@link TypedTag} into a byte array. This is the
|
||||
* inverse operation of {@link #fromByteArray(byte[])}.
|
||||
*
|
||||
* @param tag the tag to convert
|
||||
* @return the serialized byte array
|
||||
@@ -137,8 +136,8 @@ public interface Tag
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the given byte array into a {@link TypedTag}.
|
||||
* This is the inverse operation of {@link #toByteArray(TypedTag)}.
|
||||
* Deserializes the given byte array into a {@link TypedTag}. This is the
|
||||
* inverse operation of {@link #toByteArray(TypedTag)}.
|
||||
*
|
||||
* @param data the byte array to read from
|
||||
* @return the deserialized {@link TypedTag}
|
||||
@@ -150,8 +149,8 @@ public interface Tag
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the given byte array into a {@link TypedTag},
|
||||
* with limitations of the {@link NBTLimiter}.
|
||||
* Deserializes the given byte array into a {@link TypedTag}, with
|
||||
* limitations of the {@link NBTLimiter}.
|
||||
*
|
||||
* @param data the byte array to read from
|
||||
* @param limiter the limiter for this read operation
|
||||
|
18
pom.xml
18
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>BungeeCord-Parent</name>
|
||||
@@ -63,12 +63,12 @@
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
<id>central-portal-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-staging</id>
|
||||
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
<id>ossrh-staging-api</id>
|
||||
<url>https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-bom</artifactId>
|
||||
<version>4.2.1.Final</version>
|
||||
<version>4.2.3.Final</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
@@ -372,6 +372,12 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.central</groupId>
|
||||
<artifactId>central-publishing-maven-plugin</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<extensions>true</extensions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-protocol</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Protocol</name>
|
||||
|
@@ -26,17 +26,22 @@ import net.md_5.bungee.nbt.Tag;
|
||||
import net.md_5.bungee.nbt.TypedTag;
|
||||
import net.md_5.bungee.nbt.limit.NBTLimiter;
|
||||
import net.md_5.bungee.nbt.type.EndTag;
|
||||
import net.md_5.bungee.protocol.data.NumberFormat;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.data.Property;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
import net.md_5.bungee.protocol.util.TagUtil;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public abstract class DefinedPacket
|
||||
{
|
||||
|
||||
public <T> T readNullable(Function<ByteBuf, T> reader, ByteBuf buf)
|
||||
public static <T> T readNullable(Function<ByteBuf, T> reader, ByteBuf buf)
|
||||
{
|
||||
return buf.readBoolean() ? reader.apply( buf ) : null;
|
||||
}
|
||||
|
||||
public <T> void writeNullable(T t0, BiConsumer<T, ByteBuf> writer, ByteBuf buf)
|
||||
public static <T> void writeNullable(T t0, BiConsumer<T, ByteBuf> writer, ByteBuf buf)
|
||||
{
|
||||
if ( t0 != null )
|
||||
{
|
||||
@@ -48,7 +53,7 @@ public abstract class DefinedPacket
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T readLengthPrefixed(Function<ByteBuf, T> reader, ByteBuf buf, int maxSize)
|
||||
public static <T> T readLengthPrefixed(Function<ByteBuf, T> reader, ByteBuf buf, int maxSize)
|
||||
{
|
||||
int size = readVarInt( buf );
|
||||
|
||||
@@ -60,7 +65,7 @@ public abstract class DefinedPacket
|
||||
return reader.apply( buf.readSlice( size ) );
|
||||
}
|
||||
|
||||
public <T> void writeLengthPrefixed(T value, BiConsumer<T, ByteBuf> writer, ByteBuf buf, int maxSize)
|
||||
public static <T> void writeLengthPrefixed(T value, BiConsumer<T, ByteBuf> writer, ByteBuf buf, int maxSize)
|
||||
{
|
||||
ByteBuf tempBuffer = buf.alloc().buffer();
|
||||
try
|
||||
@@ -124,8 +129,7 @@ public abstract class DefinedPacket
|
||||
throw new OverflowPacketException( "Cannot receive string longer than " + maxLen * 3 + " (got " + len + " bytes)" );
|
||||
}
|
||||
|
||||
String s = buf.toString( buf.readerIndex(), len, StandardCharsets.UTF_8 );
|
||||
buf.readerIndex( buf.readerIndex() + len );
|
||||
String s = buf.readString( len, StandardCharsets.UTF_8 );
|
||||
|
||||
if ( s.length() > maxLen )
|
||||
{
|
||||
|
@@ -110,7 +110,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x24 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x26 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x27 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x26 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x26 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x2B )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Login.class,
|
||||
@@ -129,11 +130,13 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x29 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x2B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x2C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x2B )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x2B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x30 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Chat.class,
|
||||
Chat::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_8, 0x02 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_9, 0x0F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_13, 0x0E ),
|
||||
@@ -163,7 +166,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x45 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x47 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x4C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x4B )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x4B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x50 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
BossBar.class,
|
||||
@@ -227,7 +231,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x5E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x64 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x63 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x63 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x68 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardScore.class,
|
||||
@@ -247,7 +252,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x61 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x68 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x67 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x67 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x6C )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardScoreReset.class,
|
||||
@@ -255,7 +261,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x42 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x44 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x49 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x48 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x48 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x4D )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ScoreboardDisplay.class,
|
||||
@@ -275,7 +282,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x55 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x57 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x5C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x5B )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x5B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x60 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Team.class,
|
||||
@@ -295,7 +303,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x5E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x60 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x67 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x66 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x66 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x6B )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PluginMessage.class,
|
||||
@@ -333,7 +342,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x1D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x1C )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x1C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x20 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Title.class,
|
||||
@@ -355,7 +365,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x63 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x65 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6B )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x70 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ClearTitles.class,
|
||||
@@ -381,7 +392,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x61 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x63 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x69 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x69 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x6E )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
TitleTimes.class,
|
||||
@@ -396,7 +408,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x64 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x66 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x6D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6C )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x71 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
SystemChat.class,
|
||||
@@ -410,7 +423,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x69 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x73 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x72 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x72 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x77 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PlayerListHeaderFooter.class,
|
||||
@@ -435,7 +449,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x6A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x74 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x73 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x73 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x78 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
EntityStatus.class,
|
||||
@@ -455,7 +470,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x1C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x1D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x1F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x1E )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x1E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x22 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Commands.class,
|
||||
@@ -486,7 +502,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x20 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x22 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x23 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x22 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x22 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x26 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ViewDistance.class,
|
||||
@@ -504,7 +521,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x55 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x59 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x58 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x58 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x5D )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ServerData.class,
|
||||
@@ -517,7 +535,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x49 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x4B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x50 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x4F )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x4F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x54 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PlayerListItemRemove.class,
|
||||
@@ -527,7 +546,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3D ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x3F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x3E )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x3E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x43 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
PlayerListItemUpdate.class,
|
||||
@@ -537,7 +557,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x3C ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x3E ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x40 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x3F )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x3F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x44 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
StartConfiguration.class,
|
||||
@@ -546,7 +567,8 @@ public enum Protocol
|
||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x67 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x69 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x70 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6F )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x6F ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x74 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
CookieRequest.class,
|
||||
@@ -560,40 +582,46 @@ public enum Protocol
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x6B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x72 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x71 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_5, 0x71 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x76 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
Transfer.class,
|
||||
Transfer::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7A )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x7A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x7F )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
DisconnectReportDetails.class,
|
||||
DisconnectReportDetails::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_21, 0x7A ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x81 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x81 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x86 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ServerLinks.class,
|
||||
ServerLinks::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_21, 0x7B ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x82 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_2, 0x82 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x87 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ClearDialog.class,
|
||||
ClearDialog::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x84 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x84 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x89 )
|
||||
);
|
||||
TO_CLIENT.registerPacket(
|
||||
ShowDialog.class,
|
||||
ShowDialog::new,
|
||||
RegisterType.ENCODE,
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x85 )
|
||||
map( ProtocolConstants.MINECRAFT_1_21_6, 0x85 ),
|
||||
map( ProtocolConstants.MINECRAFT_1_21_9, 0x8A )
|
||||
);
|
||||
|
||||
TO_SERVER.registerPacket(
|
||||
|
@@ -52,6 +52,7 @@ public class ProtocolConstants
|
||||
public static final int MINECRAFT_1_21_5 = 770;
|
||||
public static final int MINECRAFT_1_21_6 = 771;
|
||||
public static final int MINECRAFT_1_21_7 = 772;
|
||||
public static final int MINECRAFT_1_21_9 = 773;
|
||||
public static final List<String> SUPPORTED_VERSIONS;
|
||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||
|
||||
@@ -118,13 +119,14 @@ public class ProtocolConstants
|
||||
ProtocolConstants.MINECRAFT_1_21_4,
|
||||
ProtocolConstants.MINECRAFT_1_21_5,
|
||||
ProtocolConstants.MINECRAFT_1_21_6,
|
||||
ProtocolConstants.MINECRAFT_1_21_7
|
||||
ProtocolConstants.MINECRAFT_1_21_7,
|
||||
ProtocolConstants.MINECRAFT_1_21_9
|
||||
);
|
||||
|
||||
if ( SNAPSHOT_SUPPORT )
|
||||
{
|
||||
// supportedVersions.add( "1.21.x" );
|
||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21_6 );
|
||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21_9 );
|
||||
}
|
||||
|
||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
||||
|
@@ -7,8 +7,11 @@ import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* This class hold a netty channel initializer that calls the given {@link ChannelAcceptor}.
|
||||
* Use {@link BungeeChannelInitializer#create(ChannelAcceptor)} to create a new instance.
|
||||
* This class hold a netty channel initializer that calls the given
|
||||
* {@link ChannelAcceptor}.
|
||||
*
|
||||
* Use {@link BungeeChannelInitializer#create(ChannelAcceptor)} to create a new
|
||||
* instance.
|
||||
* <p>
|
||||
* Please note that this API is unsafe and doesn't provide any guarantees about
|
||||
* the stability of the channel pipeline or the API itself. Use at your own
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -9,6 +9,9 @@ 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
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.data;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.BitSet;
|
||||
@@ -6,6 +6,9 @@ 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
|
@@ -6,10 +6,10 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ChatChain;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.SeenMessages;
|
||||
import net.md_5.bungee.protocol.data.ChatChain;
|
||||
import net.md_5.bungee.protocol.data.SeenMessages;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -9,10 +9,10 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ChatChain;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.SeenMessages;
|
||||
import net.md_5.bungee.protocol.data.ChatChain;
|
||||
import net.md_5.bungee.protocol.data.SeenMessages;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -10,8 +10,8 @@ import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.nbt.Tag;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Location;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.Location;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -8,8 +8,8 @@ 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.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -8,8 +8,8 @@ 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.Property;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.Property;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -8,9 +8,9 @@ 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.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.Property;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.data.Property;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -7,8 +7,8 @@ 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.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItem.Item;
|
||||
|
||||
@Data
|
||||
|
@@ -8,8 +8,8 @@ import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.nbt.Tag;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Location;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.Location;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -9,9 +9,9 @@ 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.NumberFormat;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.NumberFormat;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -8,8 +8,8 @@ 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.NumberFormat;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.NumberFormat;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -8,8 +8,8 @@ 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;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@@ -27,10 +27,10 @@ public class ServerLinks extends DefinedPacket
|
||||
links = new Link[ len ];
|
||||
for ( int i = 0; i < len; i++ )
|
||||
{
|
||||
Either<LinkType, BaseComponent> type;
|
||||
Either<Integer, BaseComponent> type;
|
||||
if ( buf.readBoolean() )
|
||||
{
|
||||
type = Either.left( LinkType.values()[readVarInt( buf )] );
|
||||
type = Either.left( readVarInt( buf ) );
|
||||
} else
|
||||
{
|
||||
type = Either.right( readBaseComponent( buf, protocolVersion ) );
|
||||
@@ -47,11 +47,11 @@ public class ServerLinks extends DefinedPacket
|
||||
writeVarInt( links.length, buf );
|
||||
for ( Link link : links )
|
||||
{
|
||||
Either<LinkType, BaseComponent> type = link.getType();
|
||||
Either<Integer, BaseComponent> type = link.getType();
|
||||
if ( type.isLeft() )
|
||||
{
|
||||
buf.writeBoolean( true );
|
||||
writeVarInt( type.getLeft().ordinal(), buf );
|
||||
writeVarInt( type.getLeft(), buf );
|
||||
} else
|
||||
{
|
||||
buf.writeBoolean( false );
|
||||
@@ -67,26 +67,11 @@ public class ServerLinks extends DefinedPacket
|
||||
handler.handle( this );
|
||||
}
|
||||
|
||||
public enum LinkType
|
||||
{
|
||||
|
||||
REPORT_BUG,
|
||||
COMMUNITY_GUIDELINES,
|
||||
SUPPORT,
|
||||
STATUS,
|
||||
FEEDBACK,
|
||||
COMMUNITY,
|
||||
WEBSITE,
|
||||
FORUMS,
|
||||
NEWS,
|
||||
ANNOUNCEMENTS;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Link
|
||||
{
|
||||
|
||||
private final Either<LinkType, BaseComponent> type;
|
||||
private final Either<Integer, BaseComponent> type;
|
||||
private final String url;
|
||||
}
|
||||
}
|
||||
|
@@ -11,9 +11,9 @@ import net.md_5.bungee.nbt.TypedTag;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.ChatSerializer;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.TagUtil;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
import net.md_5.bungee.protocol.util.TagUtil;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -6,8 +6,8 @@ import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import net.md_5.bungee.api.dialog.Dialog;
|
||||
import net.md_5.bungee.protocol.AbstractPacketHandler;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -10,8 +10,8 @@ import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.util;
|
||||
|
||||
import java.util.function.Function;
|
||||
import lombok.AccessLevel;
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.util;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
@@ -1,4 +1,4 @@
|
||||
package net.md_5.bungee.protocol;
|
||||
package net.md_5.bungee.protocol.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import com.google.gson.Gson;
|
@@ -6,18 +6,19 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-proxy</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Proxy</name>
|
||||
<description>Proxy component of the Elastic Portal Suite</description>
|
||||
|
||||
<properties>
|
||||
<skipPublishing>true</skipPublishing>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
</properties>
|
||||
|
@@ -45,6 +45,7 @@ import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Getter;
|
||||
import lombok.Locked;
|
||||
import lombok.Setter;
|
||||
import lombok.Synchronized;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@@ -519,19 +520,13 @@ public class BungeeCord extends ProxyServer
|
||||
*
|
||||
* @param packet the packet to send
|
||||
*/
|
||||
@Locked.Read("connectionLock")
|
||||
public void broadcast(DefinedPacket packet)
|
||||
{
|
||||
connectionLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
for ( UserConnection con : connections.values() )
|
||||
{
|
||||
con.unsafe().sendPacket( packet );
|
||||
}
|
||||
} finally
|
||||
{
|
||||
connectionLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -592,17 +587,11 @@ public class BungeeCord extends ProxyServer
|
||||
}
|
||||
|
||||
@Override
|
||||
@Locked.Read("connectionLock")
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<ProxiedPlayer> getPlayers()
|
||||
{
|
||||
connectionLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
return Collections.unmodifiableCollection( new HashSet( connections.values() ) );
|
||||
} finally
|
||||
{
|
||||
connectionLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -612,16 +601,10 @@ public class BungeeCord extends ProxyServer
|
||||
}
|
||||
|
||||
@Override
|
||||
@Locked.Read("connectionLock")
|
||||
public ProxiedPlayer getPlayer(String name)
|
||||
{
|
||||
connectionLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
return connections.get( name );
|
||||
} finally
|
||||
{
|
||||
connectionLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public UserConnection getPlayerByOfflineUUID(UUID uuid)
|
||||
@@ -641,16 +624,10 @@ public class BungeeCord extends ProxyServer
|
||||
}
|
||||
|
||||
@Override
|
||||
@Locked.Read("connectionLock")
|
||||
public ProxiedPlayer getPlayer(UUID uuid)
|
||||
{
|
||||
connectionLock.readLock().lock();
|
||||
try
|
||||
{
|
||||
return connectionsByUUID.get( uuid );
|
||||
} finally
|
||||
{
|
||||
connectionLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -776,10 +753,8 @@ public class BungeeCord extends ProxyServer
|
||||
return true;
|
||||
}
|
||||
|
||||
@Locked.Write("connectionLock")
|
||||
public void removeConnection(UserConnection con)
|
||||
{
|
||||
connectionLock.writeLock().lock();
|
||||
try
|
||||
{
|
||||
// TODO See #1218
|
||||
if ( connections.get( con.getName() ) == con )
|
||||
@@ -788,10 +763,6 @@ public class BungeeCord extends ProxyServer
|
||||
connectionsByUUID.remove( con.getUniqueId() );
|
||||
connectionsByOfflineUUID.remove( con.getPendingConnection().getOfflineId() );
|
||||
}
|
||||
} finally
|
||||
{
|
||||
connectionLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,7 +27,7 @@ import net.md_5.bungee.jni.NativeCode;
|
||||
import net.md_5.bungee.jni.cipher.BungeeCipher;
|
||||
import net.md_5.bungee.jni.cipher.JavaCipher;
|
||||
import net.md_5.bungee.jni.cipher.NativeCipher;
|
||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionResponse;
|
||||
|
||||
|
@@ -35,7 +35,6 @@ import net.md_5.bungee.netty.ChannelWrapper;
|
||||
import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
@@ -60,6 +59,7 @@ import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
import net.md_5.bungee.util.AddressUtil;
|
||||
import net.md_5.bungee.util.BufUtil;
|
||||
import net.md_5.bungee.util.QuietException;
|
||||
|
@@ -14,6 +14,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -29,6 +30,7 @@ import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.ServerConnectRequest;
|
||||
import net.md_5.bungee.api.ServerLink;
|
||||
import net.md_5.bungee.api.SkinConfiguration;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@@ -50,7 +52,6 @@ import net.md_5.bungee.netty.HandlerBoss;
|
||||
import net.md_5.bungee.netty.PipelineUtils;
|
||||
import net.md_5.bungee.protocol.ChatSerializer;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.Either;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
@@ -60,12 +61,14 @@ import net.md_5.bungee.protocol.packet.ClientSettings;
|
||||
import net.md_5.bungee.protocol.packet.Kick;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListHeaderFooter;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.ServerLinks;
|
||||
import net.md_5.bungee.protocol.packet.SetCompression;
|
||||
import net.md_5.bungee.protocol.packet.ShowDialog;
|
||||
import net.md_5.bungee.protocol.packet.ShowDialogDirect;
|
||||
import net.md_5.bungee.protocol.packet.StoreCookie;
|
||||
import net.md_5.bungee.protocol.packet.SystemChat;
|
||||
import net.md_5.bungee.protocol.packet.Transfer;
|
||||
import net.md_5.bungee.protocol.util.Either;
|
||||
import net.md_5.bungee.tab.ServerUnique;
|
||||
import net.md_5.bungee.tab.TabList;
|
||||
import net.md_5.bungee.util.CaseInsensitiveSet;
|
||||
@@ -860,4 +863,16 @@ public final class UserConnection implements ProxiedPlayer
|
||||
|
||||
unsafe.sendPacket( new ShowDialog( Either.right( dialog ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendServerLinks(List<ServerLink> serverLinks)
|
||||
{
|
||||
Preconditions.checkState( getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_21, "Server links are only supported in 1.21 and above" );
|
||||
|
||||
ServerLinks.Link[] links = serverLinks.stream()
|
||||
.map( link -> new ServerLinks.Link( link.getType() != null ? Either.left( link.getType().ordinal() ) : Either.right( link.getLabel() ), link.getUrl() ) )
|
||||
.toArray( ServerLinks.Link[]::new );
|
||||
|
||||
unsafe.sendPacket( new ServerLinks( links ) );
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ public class CommandPerms extends Command
|
||||
|
||||
public CommandPerms()
|
||||
{
|
||||
super( "perms" );
|
||||
super( "perms", "bungeecord.command.perms" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -94,7 +94,7 @@ public class YamlConfig implements ConfigurationAdapter
|
||||
} ) );
|
||||
set( "permissions.admin", Arrays.asList( new String[]
|
||||
{
|
||||
"bungeecord.command.alert", "bungeecord.command.alertraw", "bungeecord.command.end", "bungeecord.command.ip", "bungeecord.command.reload", "bungeecord.command.kick", "bungeecord.command.send", "bungeecord.command.find"
|
||||
"bungeecord.command.alert", "bungeecord.command.alertraw", "bungeecord.command.end", "bungeecord.command.ip", "bungeecord.command.reload", "bungeecord.command.kick", "bungeecord.command.send", "bungeecord.command.find", "bungeecord.command.perms"
|
||||
} ) );
|
||||
}
|
||||
|
||||
|
@@ -58,9 +58,9 @@ import net.md_5.bungee.netty.cipher.CipherDecoder;
|
||||
import net.md_5.bungee.netty.cipher.CipherEncoder;
|
||||
import net.md_5.bungee.protocol.DefinedPacket;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.data.PlayerPublicKey;
|
||||
import net.md_5.bungee.protocol.packet.CookieRequest;
|
||||
import net.md_5.bungee.protocol.packet.CookieResponse;
|
||||
import net.md_5.bungee.protocol.packet.EncryptionRequest;
|
||||
|
@@ -3,7 +3,7 @@ package net.md_5.bungee.connection;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import net.md_5.bungee.protocol.Property;
|
||||
import net.md_5.bungee.protocol.data.Property;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
|
@@ -29,7 +29,6 @@ import net.md_5.bungee.netty.PacketHandler;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.Protocol;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import net.md_5.bungee.protocol.TagUtil;
|
||||
import net.md_5.bungee.protocol.packet.Chat;
|
||||
import net.md_5.bungee.protocol.packet.ClientChat;
|
||||
import net.md_5.bungee.protocol.packet.ClientCommand;
|
||||
@@ -46,6 +45,7 @@ import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
||||
import net.md_5.bungee.protocol.util.TagUtil;
|
||||
import net.md_5.bungee.util.AllowedCharacters;
|
||||
|
||||
public class UpstreamBridge extends PacketHandler
|
||||
|
@@ -13,10 +13,12 @@ import net.md_5.bungee.protocol.DefinedPacket;
|
||||
/**
|
||||
* prepends length of message and optionally compresses message beforehand
|
||||
* <br>
|
||||
* combining these operations allows to keep space infront of compressed data for length varint
|
||||
* combining these operations allows to keep space infront of compressed data
|
||||
* for length varint
|
||||
*/
|
||||
public class LengthPrependerAndCompressor extends MessageToMessageEncoder<ByteBuf>
|
||||
{
|
||||
|
||||
// reasonable to not support length varints > 4 byte (268435455 byte > 268MB)
|
||||
// if ever changed to smaller than 4, also change varintSize method to check for that
|
||||
private static final byte MAX_SUPPORTED_VARINT_LENGTH_LEN = 4;
|
||||
|
@@ -21,13 +21,18 @@ public class ServerUnique extends TabList
|
||||
|
||||
@Override
|
||||
public void onUpdate(PlayerListItem playerListItem)
|
||||
{
|
||||
PlayerListItem.Action action = playerListItem.getAction();
|
||||
|
||||
if ( action == PlayerListItem.Action.ADD_PLAYER )
|
||||
{
|
||||
for ( PlayerListItem.Item item : playerListItem.getItems() )
|
||||
{
|
||||
if ( playerListItem.getAction() == PlayerListItem.Action.ADD_PLAYER )
|
||||
{
|
||||
uuids.add( item.getUuid() );
|
||||
} else if ( playerListItem.getAction() == PlayerListItem.Action.REMOVE_PLAYER )
|
||||
}
|
||||
} else if ( action == PlayerListItem.Action.REMOVE_PLAYER )
|
||||
{
|
||||
for ( PlayerListItem.Item item : playerListItem.getItems() )
|
||||
{
|
||||
uuids.remove( item.getUuid() );
|
||||
}
|
||||
@@ -47,17 +52,14 @@ public class ServerUnique extends TabList
|
||||
|
||||
@Override
|
||||
public void onUpdate(PlayerListItemUpdate playerListItem)
|
||||
{
|
||||
if ( playerListItem.getActions().contains( PlayerListItemUpdate.Action.ADD_PLAYER ) )
|
||||
{
|
||||
for ( PlayerListItem.Item item : playerListItem.getItems() )
|
||||
{
|
||||
for ( PlayerListItemUpdate.Action action : playerListItem.getActions() )
|
||||
{
|
||||
if ( action == PlayerListItemUpdate.Action.ADD_PLAYER )
|
||||
{
|
||||
uuids.add( item.getUuid() );
|
||||
}
|
||||
}
|
||||
}
|
||||
player.unsafe().sendPacket( playerListItem );
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ public class ServerUnique extends TabList
|
||||
if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_19_3 )
|
||||
{
|
||||
PlayerListItemRemove packet = new PlayerListItemRemove();
|
||||
packet.setUuids( uuids.stream().toArray( UUID[]::new ) );
|
||||
packet.setUuids( uuids.toArray( new UUID[ 0 ] ) );
|
||||
player.unsafe().sendPacket( packet );
|
||||
} else
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.UserConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.connection.LoginResult;
|
||||
import net.md_5.bungee.protocol.Property;
|
||||
import net.md_5.bungee.protocol.data.Property;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItem;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItemRemove;
|
||||
import net.md_5.bungee.protocol.packet.PlayerListItemUpdate;
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-query</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Query</name>
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-serializer</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-Serializer</name>
|
||||
|
@@ -20,11 +20,12 @@ public class ClickEventSerializer
|
||||
public static final ClickEventSerializer NEW = new ClickEventSerializer( ClickType.NEW );
|
||||
public static final ClickEventSerializer DIALOG = new ClickEventSerializer( ClickType.DIALOG );
|
||||
//
|
||||
private final ClickType type;
|
||||
|
||||
public enum ClickType
|
||||
{
|
||||
OLD, NEW, DIALOG;
|
||||
}
|
||||
private final ClickType type;
|
||||
|
||||
public ClickEvent deserialize(JsonObject clickEvent, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
|
@@ -0,0 +1,138 @@
|
||||
package net.md_5.bungee.chat;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.UUID;
|
||||
import net.md_5.bungee.api.chat.ObjectComponent;
|
||||
import net.md_5.bungee.api.chat.objects.PlayerObject;
|
||||
import net.md_5.bungee.api.chat.objects.SpriteObject;
|
||||
import net.md_5.bungee.api.chat.player.Profile;
|
||||
import net.md_5.bungee.api.chat.player.Property;
|
||||
|
||||
public class ObjectComponentSerializer extends BaseComponentSerializer implements JsonSerializer<ObjectComponent>, JsonDeserializer<ObjectComponent>
|
||||
{
|
||||
|
||||
public ObjectComponentSerializer(VersionedComponentSerializer serializer)
|
||||
{
|
||||
super( serializer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||
{
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
|
||||
String sprite = object.has( "sprite" ) ? object.get( "sprite" ).getAsString() : null;
|
||||
String atlas = object.has( "atlas" ) ? object.get( "atlas" ).getAsString() : null;
|
||||
|
||||
if ( sprite != null )
|
||||
{
|
||||
ObjectComponent component = new ObjectComponent( new SpriteObject( atlas, sprite ) );
|
||||
deserialize( object, component, context );
|
||||
return component;
|
||||
}
|
||||
JsonElement player = object.get( "player" );
|
||||
if ( player != null )
|
||||
{
|
||||
String name = null;
|
||||
UUID uuid = null;
|
||||
Property[] properties = null;
|
||||
Boolean hat = object.has( "hat" ) ? object.get( "hat" ).getAsBoolean() : null;
|
||||
if ( player.isJsonObject() )
|
||||
{
|
||||
JsonObject playerObj = player.getAsJsonObject();
|
||||
validateName( name = playerObj.has( "name" ) ? playerObj.get( "name" ).getAsString() : null );
|
||||
uuid = playerObj.has( "id" ) ? parseUUID( context.deserialize( playerObj.get( "id" ), int[].class ) ) : null;
|
||||
properties = playerObj.has( "properties" ) ? context.deserialize( playerObj.get( "properties" ), Property[].class ) : null;
|
||||
} else if ( player.isJsonPrimitive() )
|
||||
{
|
||||
validateName( name = player.getAsString() );
|
||||
}
|
||||
ObjectComponent component = new ObjectComponent( new PlayerObject( new Profile( name, uuid, properties ), hat ) );
|
||||
deserialize( object, component, context );
|
||||
return component;
|
||||
}
|
||||
|
||||
throw new JsonParseException( "Could not parse JSON: missing 'player' or 'sprite' property" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(ObjectComponent src, Type typeOfSrc, JsonSerializationContext context)
|
||||
{
|
||||
JsonObject object = new JsonObject();
|
||||
serialize( object, src, context );
|
||||
|
||||
if ( src.getObject() instanceof SpriteObject )
|
||||
{
|
||||
SpriteObject sprite = (SpriteObject) src.getObject();
|
||||
object.addProperty( "sprite", sprite.getSprite() );
|
||||
if ( sprite.getAtlas() != null )
|
||||
{
|
||||
object.addProperty( "atlas", sprite.getAtlas() );
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
if ( src.getObject() instanceof PlayerObject )
|
||||
{
|
||||
PlayerObject player = (PlayerObject) src.getObject();
|
||||
|
||||
if ( player.getHat() != null )
|
||||
{
|
||||
object.addProperty( "hat", player.getHat() );
|
||||
}
|
||||
|
||||
JsonObject playerObj = new JsonObject();
|
||||
Profile profile = player.getProfile();
|
||||
|
||||
if ( profile.getName() != null )
|
||||
{
|
||||
playerObj.addProperty( "name", profile.getName() );
|
||||
}
|
||||
|
||||
if ( profile.getUuid() != null )
|
||||
{
|
||||
int[] uuidArray = new int[4];
|
||||
long most = profile.getUuid().getMostSignificantBits();
|
||||
long least = profile.getUuid().getLeastSignificantBits();
|
||||
uuidArray[0] = (int) ( most >> 32 );
|
||||
uuidArray[1] = (int) most;
|
||||
uuidArray[2] = (int) ( least >> 32 );
|
||||
uuidArray[3] = (int) least;
|
||||
playerObj.add( "id", context.serialize( uuidArray ) );
|
||||
}
|
||||
|
||||
if ( profile.getProperties() != null )
|
||||
{
|
||||
playerObj.add( "properties", context.serialize( profile.getProperties(), Property[].class ) );
|
||||
}
|
||||
object.add( "player", playerObj );
|
||||
return object;
|
||||
}
|
||||
|
||||
throw new JsonParseException( "Could not serialize ObjectComponent: unknown object type " + src.getObject().getClass() );
|
||||
}
|
||||
|
||||
private static UUID parseUUID(int[] array)
|
||||
{
|
||||
if ( array.length != 4 )
|
||||
{
|
||||
throw new JsonParseException( "UUID integer array must be exactly 4 integers long" );
|
||||
}
|
||||
return new UUID( (long) array[0] << 32 | (long) array[1] & 0XFFFFFFFFL, (long) array[2] << 32 | (long) array[3] & 0XFFFFFFFFL );
|
||||
}
|
||||
|
||||
private static void validateName(String name)
|
||||
{
|
||||
if ( name != null && ( name.length() > 16 || name.isEmpty() ) )
|
||||
{
|
||||
throw new JsonParseException( "Could not parse JSON: player name must be 16 characters or fewer and not empty" );
|
||||
}
|
||||
}
|
||||
}
|
@@ -17,6 +17,7 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
||||
import net.md_5.bungee.api.chat.ItemTag;
|
||||
import net.md_5.bungee.api.chat.KeybindComponent;
|
||||
import net.md_5.bungee.api.chat.ObjectComponent;
|
||||
import net.md_5.bungee.api.chat.ScoreComponent;
|
||||
import net.md_5.bungee.api.chat.SelectorComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -61,6 +62,7 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
|
||||
registerTypeAdapter( KeybindComponent.class, new KeybindComponentSerializer( this ) ).
|
||||
registerTypeAdapter( ScoreComponent.class, new ScoreComponentSerializer( this ) ).
|
||||
registerTypeAdapter( SelectorComponent.class, new SelectorComponentSerializer( this ) ).
|
||||
registerTypeAdapter( ObjectComponent.class, new ObjectComponentSerializer( this ) ).
|
||||
registerTypeAdapter( ComponentStyle.class, new ComponentStyleSerializer() ).
|
||||
registerTypeAdapter( Entity.class, new EntitySerializer( this ) ).
|
||||
registerTypeAdapter( Text.class, new TextSerializer() ).
|
||||
@@ -265,7 +267,7 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
|
||||
if ( json.isJsonArray() )
|
||||
{
|
||||
JsonArray arr = json.getAsJsonArray();
|
||||
BaseComponent[] components = new BaseComponent[arr.size()];
|
||||
BaseComponent[] components = new BaseComponent[ arr.size() ];
|
||||
for ( int i = 0; i < arr.size(); i++ )
|
||||
{
|
||||
components[i] = deserialize( arr.get( i ), BaseComponent.class, context );
|
||||
@@ -290,6 +292,10 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
|
||||
{
|
||||
return context.deserialize( json, SelectorComponent.class );
|
||||
}
|
||||
if ( object.has( "player" ) || object.has( "sprite" ) )
|
||||
{
|
||||
return context.deserialize( json, ObjectComponent.class );
|
||||
}
|
||||
return context.deserialize( json, TextComponent.class );
|
||||
}
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import net.md_5.bungee.chat.VersionedComponentSerializer;
|
||||
@RequiredArgsConstructor
|
||||
public class DialogSerializer implements JsonDeserializer<Dialog>, JsonSerializer<Dialog>
|
||||
{
|
||||
|
||||
private static final ThreadLocal<Set<Dialog>> serializedDialogs = new ThreadLocal<>();
|
||||
private static final BiMap<String, Class<? extends Dialog>> TYPES;
|
||||
private final VersionedComponentSerializer serializer;
|
||||
|
@@ -562,6 +562,13 @@ public class ComponentsTest
|
||||
assertNotNull( url2 );
|
||||
assertTrue( url2.getAction() == ClickEvent.Action.OPEN_URL );
|
||||
assertEquals( "http://google.com/test", url2.getValue() );
|
||||
|
||||
BaseComponent[] test3 = TextComponent.fromLegacyText( "Text\nhttp://google.com\n newline3" );
|
||||
ClickEvent url3 = test3[1].getClickEvent();
|
||||
assertNotNull( url3 );
|
||||
assertTrue( url3.getAction() == ClickEvent.Action.OPEN_URL );
|
||||
assertEquals( "http://google.com", url3.getValue() );
|
||||
assertEquals( "\n newline3", BaseComponent.toPlainText( test3[2] ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@@ -6,12 +6,12 @@
|
||||
<parent>
|
||||
<groupId>fr.pandacube.bungeecord</groupId>
|
||||
<artifactId>bungeecord-parent</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>bungeecord-slf4j</artifactId>
|
||||
<version>1.21-R0.4-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>BungeeCord-SLF4J</name>
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
<properties>
|
||||
<checkstyle.skip>true</checkstyle.skip>
|
||||
<skipPublishing>true</skipPublishing>
|
||||
<maven.deploy.skip>true</maven.deploy.skip>
|
||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||
</properties>
|
||||
|
Reference in New Issue
Block a user