Compare commits

..

6 Commits

Author SHA1 Message Date
6019f9de6f new event TabCompleteRequestEvent and deprecate TabCompleteEvent 2024-05-31 21:55:19 +02:00
0220b4512f Add CommandsDeclareEvent to declare commands with brigadier API 2024-05-31 21:55:19 +02:00
151b22c95b Server branding now includes the backend server name 2024-05-31 21:55:19 +02:00
77be5eee80 Multi-session with same Minecraft account with specific permission
Players with permission bungeecord.multiple_connect can have multiple connections with the same Minecraft account.
The UUID and player name is altered to avoid collision with other player:
UUID : xxxxxxxx-xxxx-VIxx-xxxx-xxxxxxxxxxxx
- The UUID version (V above) is now the provided version + 8 (for online player, it is 4, so it becomes C).
- The I digit will follow the index of the duplicated player : first duplicated player is 1, second one is 2.
- The name of the player will be the real player name, followed by the character "." (dot) followed by the duplication index.

Bedrock accounts connected using the Floodgate plugin will not be able to connect multiple times due to the risk of xUID collision.
2024-05-31 21:55:19 +02:00
b90791d41f Change projet configuration and POM for Pandacube 2024-05-31 21:55:17 +02:00
a842899898 Remove modules and startup delay
We don’t need them for Pandacube
2024-05-31 21:50:47 +02:00
31 changed files with 67 additions and 354 deletions

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-API</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-bootstrap</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Bootstrap</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-chat</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Chat</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-config</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Config</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-event</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Event</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-log</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Log</name>

View File

@ -8,20 +8,7 @@ echo "Compiling mbedtls"
echo "Compiling zlib"
(cd zlib && CFLAGS=-fPIC ./configure --static && make)
CC="gcc"
CFLAGS="-c -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
LDFLAGS="-shared"
CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
echo "Compiling bungee"
$CC $CFLAGS -o shared.o src/main/c/shared.c
$CC $CFLAGS -Imbedtls/include -o NativeCipherImpl.o src/main/c/NativeCipherImpl.c
$CC $CFLAGS -Izlib -o NativeCompressImpl.o src/main/c/NativeCompressImpl.c
echo "Linking native-cipher.so"
$CC $LDFLAGS -o src/main/resources/native-cipher.so shared.o NativeCipherImpl.o mbedtls/library/libmbedcrypto.a
echo "Linking native-compress.so"
$CC $LDFLAGS -o src/main/resources/native-compress.so shared.o NativeCompressImpl.o zlib/libz.a
echo "Cleaning up"
rm shared.o NativeCipherImpl.o NativeCompressImpl.o
$CXX -Imbedtls/include src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so mbedtls/library/libmbedcrypto.a
$CXX -Izlib src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so zlib/libz.a

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-native</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Native</name>

View File

@ -2,33 +2,31 @@
#include <string.h>
#include <mbedtls/aes.h>
#include "shared.h"
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
typedef unsigned char byte;
typedef struct crypto_context {
struct crypto_context {
int mode;
mbedtls_aes_context cipher;
byte key[];
} crypto_context;
byte *key;
};
jlong JNICALL Java_net_md_15_bungee_jni_cipher_NativeCipherImpl_init(JNIEnv* env, jobject obj, jboolean forEncryption, jbyteArray key) {
jsize keyLen = (*env)->GetArrayLength(env, key);
crypto_context *crypto = (crypto_context*) malloc(sizeof (crypto_context) + (size_t) keyLen);
if (!crypto) {
throwOutOfMemoryError(env, "Failed to malloc new crypto_context");
return 0;
}
(*env)->GetByteArrayRegion(env, key, 0, keyLen, (jbyte*) &crypto->key);
jsize keyLen = env->GetArrayLength(key);
jbyte *keyBytes = env->GetByteArrayElements(key, NULL);
crypto_context *crypto = (crypto_context*) malloc(sizeof (crypto_context));
mbedtls_aes_init(&crypto->cipher);
mbedtls_aes_setkey_enc(&crypto->cipher, (byte*) &crypto->key, keyLen * 8);
mbedtls_aes_setkey_enc(&crypto->cipher, (byte*) keyBytes, keyLen * 8);
crypto->key = (byte*) malloc(keyLen);
memcpy(crypto->key, keyBytes, keyLen);
crypto->mode = (forEncryption) ? MBEDTLS_AES_ENCRYPT : MBEDTLS_AES_DECRYPT;
env->ReleaseByteArrayElements(key, keyBytes, JNI_ABORT);
return (jlong) crypto;
}
@ -36,6 +34,7 @@ void Java_net_md_15_bungee_jni_cipher_NativeCipherImpl_free(JNIEnv* env, jobject
crypto_context *crypto = (crypto_context*) ctx;
mbedtls_aes_free(&crypto->cipher);
free(crypto->key);
free(crypto);
}

View File

@ -2,28 +2,28 @@
#include <string.h>
#include <zlib.h>
#include "shared.h"
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
typedef unsigned char byte;
static jclass classID;
static jfieldID consumedID;
static jfieldID finishedID;
static jmethodID makeExceptionID;
void JNICALL Java_net_md_15_bungee_jni_zlib_NativeCompressImpl_initFields(JNIEnv* env, jclass clazz) {
classID = clazz;
// We trust that these will be there
consumedID = (*env)->GetFieldID(env, clazz, "consumed", "I");
finishedID = (*env)->GetFieldID(env, clazz, "finished", "Z");
makeExceptionID = (*env)->GetMethodID(env, clazz, "makeException", "(Ljava/lang/String;I)Lnet/md_5/bungee/jni/NativeCodeException;");
// We trust that these fields will be there
consumedID = env->GetFieldID(clazz, "consumed", "I");
finishedID = env->GetFieldID(clazz, "finished", "Z");
}
jint throwException(JNIEnv *env, const char* message, int err) {
jstring jMessage = (*env)->NewStringUTF(env, message);
jthrowable throwable = (jthrowable) (*env)->CallStaticObjectMethod(env, classID, makeExceptionID, jMessage, err);
return (*env)->Throw(env, throwable);
// These can't be static for some unknown reason
jclass exceptionClass = env->FindClass("net/md_5/bungee/jni/NativeCodeException");
jmethodID exceptionInitID = env->GetMethodID(exceptionClass, "<init>", "(Ljava/lang/String;I)V");
jstring jMessage = env->NewStringUTF(message);
jthrowable throwable = (jthrowable) env->NewObject(exceptionClass, exceptionInitID, jMessage, err);
return env->Throw(throwable);
}
void JNICALL Java_net_md_15_bungee_jni_zlib_NativeCompressImpl_reset(JNIEnv* env, jobject obj, jlong ctx, jboolean compress) {
@ -48,17 +48,10 @@ void JNICALL Java_net_md_15_bungee_jni_zlib_NativeCompressImpl_end(JNIEnv* env,
jlong JNICALL Java_net_md_15_bungee_jni_zlib_NativeCompressImpl_init(JNIEnv* env, jobject obj, jboolean compress, jint level) {
z_stream* stream = (z_stream*) calloc(1, sizeof (z_stream));
if (!stream) {
throwOutOfMemoryError(env, "Failed to calloc new z_stream");
return 0;
}
int ret = (compress) ? deflateInit(stream, level) : inflateInit(stream);
if (ret != Z_OK) {
free(stream);
throwException(env, "Could not init z_stream", ret);
return 0;
}
return (jlong) stream;
@ -77,16 +70,15 @@ jint JNICALL Java_net_md_15_bungee_jni_zlib_NativeCompressImpl_process(JNIEnv* e
switch (ret) {
case Z_STREAM_END:
(*env)->SetBooleanField(env, obj, finishedID, JNI_TRUE);
env->SetBooleanField(obj, finishedID, true);
break;
case Z_OK:
break;
default:
throwException(env, "Unknown z_stream return code", ret);
return -1;
}
(*env)->SetIntField(env, obj, consumedID, inLength - stream->avail_in);
env->SetIntField(obj, consumedID, inLength - stream->avail_in);
return outLength - stream->avail_out;
}

View File

@ -1,15 +0,0 @@
#include "shared.h"
#include <stdlib.h>
#include <stdio.h>
void throwOutOfMemoryError(JNIEnv* env, const char* msg) {
jclass exceptionClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
if (!exceptionClass) {
// If the proxy ran out of memory, loading this class may fail
fprintf(stderr, "OUT OF MEMORY: %s\n", msg);
fprintf(stderr, "Could not load class java.lang.OutOfMemoryError!\n");
exit(-1);
return;
}
(*env)->ThrowNew(env, exceptionClass, msg);
}

View File

@ -1,10 +0,0 @@
// This header contains functions to be shared between both native libraries
#include <jni.h>
#ifndef _INCLUDE_SHARED_H
#define _INCLUDE_SHARED_H
void throwOutOfMemoryError(JNIEnv* env, const char* msg);
#endif

View File

@ -1,6 +1,6 @@
package net.md_5.bungee.jni;
public class NativeCodeException extends RuntimeException
public class NativeCodeException extends Exception
{
public NativeCodeException(String message, int reason)

View File

@ -1,7 +1,5 @@
package net.md_5.bungee.jni.zlib;
import net.md_5.bungee.jni.NativeCodeException;
public class NativeCompressImpl
{
@ -22,9 +20,4 @@ public class NativeCompressImpl
native long init(boolean compress, int compressionLevel);
native int process(long ctx, long in, int inLength, long out, int outLength, boolean compress);
NativeCodeException makeException(String message, int err)
{
return new NativeCodeException( message, err );
}
}

View File

@ -4,7 +4,6 @@ import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.zip.DataFormatException;
import lombok.Getter;
import net.md_5.bungee.jni.NativeCodeException;
public class NativeZlib implements BungeeZlib
{
@ -49,14 +48,7 @@ public class NativeZlib implements BungeeZlib
{
out.ensureWritable( 8192 );
int processed;
try
{
processed = nativeCompress.process( ctx, in.memoryAddress() + in.readerIndex(), in.readableBytes(), out.memoryAddress() + out.writerIndex(), out.writableBytes(), compress );
} catch ( NativeCodeException exception )
{
throw (DataFormatException) new DataFormatException( "Failed to decompress via Zlib!" ).initCause( exception );
}
int processed = nativeCompress.process( ctx, in.memoryAddress() + in.readerIndex(), in.readableBytes(), out.memoryAddress() + out.writerIndex(), out.writableBytes(), compress );
in.readerIndex( in.readerIndex() + nativeCompress.consumed );
out.writerIndex( out.writerIndex() + processed );

View File

@ -28,17 +28,6 @@ public class NativeZlibTest
test( new JavaZlib() );
}
@Test
public void testException() throws DataFormatException
{
if ( NativeCode.isSupported() )
{
assertTrue( factory.load(), "Native code failed to load!" );
testExceptionImpl( factory.newInstance() );
}
testExceptionImpl( new JavaZlib() );
}
private void test(BungeeZlib zlib) throws DataFormatException
{
System.out.println( "Testing: " + zlib );
@ -77,22 +66,4 @@ public class NativeZlibTest
assertTrue( Arrays.equals( dataBuf, check ), "Results do not match" );
}
private void testExceptionImpl(BungeeZlib zlib) throws DataFormatException
{
System.out.println( "Testing Exception: " + zlib );
long start = System.currentTimeMillis();
byte[] dataBuf = new byte[ 1 << 12 ]; // 4096 random bytes
new Random().nextBytes( dataBuf );
zlib.init( false, 0 );
ByteBuf originalBuf = Unpooled.directBuffer();
originalBuf.writeBytes( dataBuf );
ByteBuf decompressed = Unpooled.directBuffer();
assertThrows( DataFormatException.class, () -> zlib.process( originalBuf, decompressed ), "Decompressing random bytes did not result in a DataFormatException!" );
}
}

View File

@ -5,7 +5,7 @@
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>BungeeCord-Parent</name>
@ -82,7 +82,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<version>4.1.110.Final</version>
<version>4.1.109.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-protocol</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Protocol</name>

View File

@ -10,7 +10,6 @@ import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.CookieRequest;
import net.md_5.bungee.protocol.packet.CookieResponse;
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus;
@ -39,7 +38,6 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
import net.md_5.bungee.protocol.packet.ServerData;
import net.md_5.bungee.protocol.packet.ServerLinks;
import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StartConfiguration;
import net.md_5.bungee.protocol.packet.StatusRequest;
@ -270,12 +268,4 @@ public abstract class AbstractPacketHandler
public void handle(CookieResponse cookieResponse) throws Exception
{
}
public void handle(DisconnectReportDetails disconnectReportDetails) throws Exception
{
}
public void handle(ServerLinks serverLinks) throws Exception
{
}
}

View File

@ -18,7 +18,6 @@ import net.md_5.bungee.protocol.packet.ClientSettings;
import net.md_5.bungee.protocol.packet.Commands;
import net.md_5.bungee.protocol.packet.CookieRequest;
import net.md_5.bungee.protocol.packet.CookieResponse;
import net.md_5.bungee.protocol.packet.DisconnectReportDetails;
import net.md_5.bungee.protocol.packet.EncryptionRequest;
import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EntityStatus;
@ -45,7 +44,6 @@ import net.md_5.bungee.protocol.packet.ScoreboardObjective;
import net.md_5.bungee.protocol.packet.ScoreboardScore;
import net.md_5.bungee.protocol.packet.ScoreboardScoreReset;
import net.md_5.bungee.protocol.packet.ServerData;
import net.md_5.bungee.protocol.packet.ServerLinks;
import net.md_5.bungee.protocol.packet.SetCompression;
import net.md_5.bungee.protocol.packet.StartConfiguration;
import net.md_5.bungee.protocol.packet.StatusRequest;
@ -498,16 +496,6 @@ public enum Protocol
Transfer::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x73 )
);
TO_CLIENT.registerPacket(
DisconnectReportDetails.class,
DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7A )
);
TO_CLIENT.registerPacket(
ServerLinks.class,
ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x7B )
);
TO_SERVER.registerPacket(
KeepAlive.class,
@ -754,16 +742,6 @@ public enum Protocol
Transfer::new,
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B )
);
TO_CLIENT.registerPacket(
DisconnectReportDetails.class,
DisconnectReportDetails::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x0F )
);
TO_CLIENT.registerPacket(
ServerLinks.class,
ServerLinks::new,
map( ProtocolConstants.MINECRAFT_1_21, 0x10 )
);
TO_SERVER.registerPacket(
ClientSettings.class,

View File

@ -46,7 +46,6 @@ public class ProtocolConstants
public static final int MINECRAFT_1_20_2 = 764;
public static final int MINECRAFT_1_20_3 = 765;
public static final int MINECRAFT_1_20_5 = 766;
public static final int MINECRAFT_1_21 = 767;
public static final List<String> SUPPORTED_VERSIONS;
public static final List<Integer> SUPPORTED_VERSION_IDS;
@ -65,8 +64,7 @@ public class ProtocolConstants
"1.17.x",
"1.18.x",
"1.19.x",
"1.20.x",
"1.21.x"
"1.20.x"
);
ImmutableList.Builder<Integer> supportedVersionIds = ImmutableList.<Integer>builder().add(
ProtocolConstants.MINECRAFT_1_8,
@ -107,14 +105,13 @@ public class ProtocolConstants
ProtocolConstants.MINECRAFT_1_20,
ProtocolConstants.MINECRAFT_1_20_2,
ProtocolConstants.MINECRAFT_1_20_3,
ProtocolConstants.MINECRAFT_1_20_5,
ProtocolConstants.MINECRAFT_1_21
ProtocolConstants.MINECRAFT_1_20_5
);
if ( SNAPSHOT_SUPPORT )
{
// supportedVersions.add( "1.21.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_21 );
// supportedVersions.add( "1.20.x" );
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 );
}
SUPPORTED_VERSIONS = supportedVersions.build();

View File

@ -1,55 +0,0 @@
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 );
}
}

View File

@ -1,92 +0,0 @@
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,
COMMUNITY_GUIDELINES,
SUPPORT,
STATUS,
FEEDBACK,
COMMUNITY,
WEBSITE,
FORUMS,
NEWS,
ANNOUNCEMENTS;
}
@Data
public static class Link
{
private final Either<LinkType, BaseComponent> type;
private final String url;
}
}

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-proxy</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Proxy</name>
@ -107,7 +107,7 @@
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.4.0</version>
<version>8.3.0</version>
<scope>runtime</scope>
</dependency>
<!-- add these back in as they are not exposed by the API -->

View File

@ -108,7 +108,7 @@ public class DownstreamBridge extends PacketHandler
{
server.setObsolete( true );
con.connectNow( def, ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT );
con.sendMessage( bungee.getTranslation( "server_went_down", def.getName() ) );
con.sendMessage( bungee.getTranslation( "server_went_down" ) );
} else
{
con.disconnect( Util.exception( t ) );
@ -125,25 +125,13 @@ public class DownstreamBridge extends PacketHandler
bungee.getReconnectHandler().setServer( con );
}
ServerDisconnectEvent serverDisconnectEvent = new ServerDisconnectEvent( con, server.getInfo() );
bungee.getPluginManager().callEvent( serverDisconnectEvent );
if ( server.isObsolete() )
{
// do not perform any actions if the user has already moved
return;
}
ServerInfo def = con.updateAndGetNextServer( server.getInfo() );
if ( def != null )
{
server.setObsolete( true );
con.connectNow( def, ServerConnectEvent.Reason.SERVER_DOWN_REDIRECT );
con.sendMessage( bungee.getTranslation( "server_went_down", def.getName() ) );
} else
if ( !server.isObsolete() )
{
con.disconnect( bungee.getTranslation( "lost_connection" ) );
}
ServerDisconnectEvent serverDisconnectEvent = new ServerDisconnectEvent( con, server.getInfo() );
bungee.getPluginManager().callEvent( serverDisconnectEvent );
}
@Override

View File

@ -87,7 +87,6 @@ public abstract class EntityMap
case ProtocolConstants.MINECRAFT_1_20_3:
return EntityMap_1_16_2.INSTANCE_1_20_3;
case ProtocolConstants.MINECRAFT_1_20_5:
case ProtocolConstants.MINECRAFT_1_21:
return EntityMap_1_16_2.INSTANCE_1_20_5;
}
throw new RuntimeException( "Version " + version + " has no entity map" );

View File

@ -30,7 +30,6 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
private ChannelWrapper channel;
private PacketHandler handler;
private boolean healthCheck;
public void setHandler(PacketHandler handler)
{
@ -97,7 +96,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
channel.setRemoteAddress( newAddress );
} else
{
healthCheck = true;
channel.close();
}
} finally
{
@ -147,7 +146,7 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
{
if ( ctx.channel().isActive() )
{
boolean logExceptions = !( handler instanceof PingHandler ) && !healthCheck;
boolean logExceptions = !( handler instanceof PingHandler );
if ( logExceptions )
{

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-query</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Query</name>

View File

@ -6,12 +6,12 @@
<parent>
<groupId>fr.pandacube.bungeecord</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>bungeecord-slf4j</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.20-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-SLF4J</name>