Compare commits
6 Commits
53b54d300f
...
a56ff2d4d2
Author | SHA1 | Date | |
---|---|---|---|
a56ff2d4d2 | |||
037cf6d97b | |||
dc520b9bdf | |||
b4095c4540 | |||
c30c57482e | |||
b13dcb3aa5 |
@ -23,4 +23,4 @@ Binaries
|
|||||||
--------
|
--------
|
||||||
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).
|
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).
|
||||||
|
|
||||||
(c) 2012-2024 SpigotMC Pty. Ltd.
|
(c) 2012-2023 SpigotMC Pty. Ltd.
|
||||||
|
@ -3,9 +3,8 @@ package net.md_5.bungee.api.event;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import net.md_5.bungee.api.Callback;
|
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.plugin.Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event called as soon as a connection has a {@link ProxiedPlayer} and is ready
|
* Event called as soon as a connection has a {@link ProxiedPlayer} and is ready
|
||||||
@ -14,22 +13,11 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|||||||
@Data
|
@Data
|
||||||
@ToString(callSuper = false)
|
@ToString(callSuper = false)
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class PostLoginEvent extends AsyncEvent<PostLoginEvent>
|
public class PostLoginEvent extends Event
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player involved with this event.
|
* The player involved with this event.
|
||||||
*/
|
*/
|
||||||
private final ProxiedPlayer player;
|
private final ProxiedPlayer player;
|
||||||
/**
|
|
||||||
* The server to which the player will initially be connected.
|
|
||||||
*/
|
|
||||||
private ServerInfo target;
|
|
||||||
|
|
||||||
public PostLoginEvent(ProxiedPlayer player, ServerInfo target, Callback<PostLoginEvent> done)
|
|
||||||
{
|
|
||||||
super( done );
|
|
||||||
this.player = player;
|
|
||||||
this.target = target;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -61,11 +61,6 @@ class LibraryLoader
|
|||||||
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
|
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
|
||||||
// SPIGOT-7638: Add system properties,
|
|
||||||
// since JdkVersionProfileActivator needs 'java.version' when a profile has the 'jdk' element
|
|
||||||
// otherwise it will silently fail and not resolves the dependencies in the affected pom.
|
|
||||||
session.setSystemProperties( System.getProperties() );
|
|
||||||
session.setReadOnly();
|
session.setReadOnly();
|
||||||
|
|
||||||
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
|
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
<version>3.4.1</version>
|
<version>3.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifestEntries>
|
<manifestEntries>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.5.3</version>
|
<version>3.5.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -244,7 +244,7 @@ public final class ChatColor
|
|||||||
public static ChatColor of(String string)
|
public static ChatColor of(String string)
|
||||||
{
|
{
|
||||||
Preconditions.checkArgument( string != null, "string cannot be null" );
|
Preconditions.checkArgument( string != null, "string cannot be null" );
|
||||||
if ( string.length() == 7 && string.charAt( 0 ) == '#' )
|
if ( string.startsWith( "#" ) && string.length() == 7 )
|
||||||
{
|
{
|
||||||
int rgb;
|
int rgb;
|
||||||
try
|
try
|
||||||
|
@ -253,9 +253,6 @@ public abstract class BaseComponent
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set this component's color.
|
* Set this component's color.
|
||||||
* <p>
|
|
||||||
* <b>Warning: This should be a color, not formatting code (ie,
|
|
||||||
* {@link ChatColor#color} should not be null).</b>
|
|
||||||
*
|
*
|
||||||
* @param color the component color, or null to use the default
|
* @param color the component color, or null to use the default
|
||||||
*/
|
*/
|
||||||
|
@ -18,9 +18,6 @@ public final class ComponentStyle implements Cloneable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The color of this style.
|
* The color of this style.
|
||||||
* <p>
|
|
||||||
* <b>Warning: This should be a color, not formatting code (ie,
|
|
||||||
* {@link ChatColor#color} should not be null).</b>
|
|
||||||
*/
|
*/
|
||||||
private ChatColor color;
|
private ChatColor color;
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ import net.md_5.bungee.chat.TranslationRegistry;
|
|||||||
public final class TranslatableComponent extends BaseComponent
|
public final class TranslatableComponent extends BaseComponent
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Pattern FORMAT = Pattern.compile( "%(?:(\\d+)\\$)?([A-Za-z%]|$)" );
|
private final Pattern format = Pattern.compile( "%(?:(\\d+)\\$)?([A-Za-z%]|$)" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The key into the Minecraft locale files to use for the translation. The
|
* The key into the Minecraft locale files to use for the translation. The
|
||||||
@ -44,11 +44,10 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
{
|
{
|
||||||
super( original );
|
super( original );
|
||||||
setTranslate( original.getTranslate() );
|
setTranslate( original.getTranslate() );
|
||||||
setFallback( original.getFallback() );
|
|
||||||
|
|
||||||
if ( original.getWith() != null )
|
if ( original.getWith() != null )
|
||||||
{
|
{
|
||||||
List<BaseComponent> temp = new ArrayList<>();
|
List<BaseComponent> temp = new ArrayList<BaseComponent>();
|
||||||
for ( BaseComponent baseComponent : original.getWith() )
|
for ( BaseComponent baseComponent : original.getWith() )
|
||||||
{
|
{
|
||||||
temp.add( baseComponent.duplicate() );
|
temp.add( baseComponent.duplicate() );
|
||||||
@ -178,7 +177,7 @@ public final class TranslatableComponent extends BaseComponent
|
|||||||
trans = fallback;
|
trans = fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher matcher = FORMAT.matcher( trans );
|
Matcher matcher = format.matcher( trans );
|
||||||
int position = 0;
|
int position = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ( matcher.find( position ) )
|
while ( matcher.find( position ) )
|
||||||
|
@ -23,62 +23,59 @@ public class BaseComponentSerializer
|
|||||||
{
|
{
|
||||||
component.applyStyle( context.deserialize( object, ComponentStyle.class ) );
|
component.applyStyle( context.deserialize( object, ComponentStyle.class ) );
|
||||||
|
|
||||||
JsonElement insertion = object.get( "insertion" );
|
if ( object.has( "insertion" ) )
|
||||||
if ( insertion != null )
|
|
||||||
{
|
{
|
||||||
component.setInsertion( insertion.getAsString() );
|
component.setInsertion( object.get( "insertion" ).getAsString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Events
|
//Events
|
||||||
JsonObject clickEvent = object.getAsJsonObject( "clickEvent" );
|
if ( object.has( "clickEvent" ) )
|
||||||
if ( clickEvent != null )
|
|
||||||
{
|
{
|
||||||
|
JsonObject event = object.getAsJsonObject( "clickEvent" );
|
||||||
component.setClickEvent( new ClickEvent(
|
component.setClickEvent( new ClickEvent(
|
||||||
ClickEvent.Action.valueOf( clickEvent.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) ),
|
ClickEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) ),
|
||||||
( clickEvent.has( "value" ) ) ? clickEvent.get( "value" ).getAsString() : "" ) );
|
( event.has( "value" ) ) ? event.get( "value" ).getAsString() : "" ) );
|
||||||
}
|
}
|
||||||
JsonObject hoverEventJson = object.getAsJsonObject( "hoverEvent" );
|
if ( object.has( "hoverEvent" ) )
|
||||||
if ( hoverEventJson != null )
|
|
||||||
{
|
{
|
||||||
|
JsonObject event = object.getAsJsonObject( "hoverEvent" );
|
||||||
HoverEvent hoverEvent = null;
|
HoverEvent hoverEvent = null;
|
||||||
HoverEvent.Action action = HoverEvent.Action.valueOf( hoverEventJson.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
|
HoverEvent.Action action = HoverEvent.Action.valueOf( event.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
|
||||||
|
|
||||||
JsonElement value = hoverEventJson.get( "value" );
|
if ( event.has( "value" ) )
|
||||||
if ( value != null )
|
|
||||||
{
|
{
|
||||||
|
JsonElement contents = event.get( "value" );
|
||||||
|
|
||||||
// Plugins previously had support to pass BaseComponent[] into any action.
|
// Plugins previously had support to pass BaseComponent[] into any action.
|
||||||
// If the GSON is possible to be parsed as BaseComponent, attempt to parse as so.
|
// If the GSON is possible to be parsed as BaseComponent, attempt to parse as so.
|
||||||
BaseComponent[] components;
|
BaseComponent[] components;
|
||||||
if ( value.isJsonArray() )
|
if ( contents.isJsonArray() )
|
||||||
{
|
{
|
||||||
components = context.deserialize( value, BaseComponent[].class );
|
components = context.deserialize( contents, BaseComponent[].class );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
components = new BaseComponent[]
|
components = new BaseComponent[]
|
||||||
{
|
{
|
||||||
context.deserialize( value, BaseComponent.class )
|
context.deserialize( contents, BaseComponent.class )
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
hoverEvent = new HoverEvent( action, components );
|
hoverEvent = new HoverEvent( action, components );
|
||||||
} else
|
} else if ( event.has( "contents" ) )
|
||||||
{
|
{
|
||||||
JsonElement contents = hoverEventJson.get( "contents" );
|
JsonElement contents = event.get( "contents" );
|
||||||
if ( contents != null )
|
|
||||||
|
Content[] list;
|
||||||
|
if ( contents.isJsonArray() )
|
||||||
{
|
{
|
||||||
Content[] list;
|
list = context.deserialize( contents, HoverEvent.getClass( action, true ) );
|
||||||
if ( contents.isJsonArray() )
|
} else
|
||||||
|
{
|
||||||
|
list = new Content[]
|
||||||
{
|
{
|
||||||
list = context.deserialize( contents, HoverEvent.getClass( action, true ) );
|
context.deserialize( contents, HoverEvent.getClass( action, false ) )
|
||||||
} else
|
};
|
||||||
{
|
|
||||||
list = new Content[]
|
|
||||||
{
|
|
||||||
context.deserialize( contents, HoverEvent.getClass( action, false ) )
|
|
||||||
};
|
|
||||||
}
|
|
||||||
hoverEvent = new HoverEvent( action, new ArrayList<>( Arrays.asList( list ) ) );
|
|
||||||
}
|
}
|
||||||
|
hoverEvent = new HoverEvent( action, new ArrayList<>( Arrays.asList( list ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hoverEvent != null )
|
if ( hoverEvent != null )
|
||||||
@ -87,10 +84,9 @@ public class BaseComponentSerializer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonElement extra = object.get( "extra" );
|
if ( object.has( "extra" ) )
|
||||||
if ( extra != null )
|
|
||||||
{
|
{
|
||||||
component.setExtra( Arrays.asList( context.deserialize( extra, BaseComponent[].class ) ) );
|
component.setExtra( Arrays.asList( context.<BaseComponent[]>deserialize( object.get( "extra" ), BaseComponent[].class ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,6 @@ import com.google.gson.JsonPrimitive;
|
|||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.Map;
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyle;
|
import net.md_5.bungee.api.chat.ComponentStyle;
|
||||||
import net.md_5.bungee.api.chat.ComponentStyleBuilder;
|
import net.md_5.bungee.api.chat.ComponentStyleBuilder;
|
||||||
@ -63,7 +62,7 @@ public class ComponentStyleSerializer implements JsonSerializer<ComponentStyle>,
|
|||||||
{
|
{
|
||||||
object.addProperty( "obfuscated", style.isObfuscatedRaw() );
|
object.addProperty( "obfuscated", style.isObfuscatedRaw() );
|
||||||
}
|
}
|
||||||
if ( style.hasColor() && style.getColor().getColor() != null )
|
if ( style.hasColor() )
|
||||||
{
|
{
|
||||||
object.addProperty( "color", style.getColor().getName() );
|
object.addProperty( "color", style.getColor().getName() );
|
||||||
}
|
}
|
||||||
@ -78,34 +77,33 @@ public class ComponentStyleSerializer implements JsonSerializer<ComponentStyle>,
|
|||||||
{
|
{
|
||||||
ComponentStyleBuilder builder = ComponentStyle.builder();
|
ComponentStyleBuilder builder = ComponentStyle.builder();
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
for ( Map.Entry<String, JsonElement> entry : object.entrySet() )
|
if ( object.has( "bold" ) )
|
||||||
{
|
{
|
||||||
String name = entry.getKey();
|
builder.bold( getAsBoolean( object.get( "bold" ) ) );
|
||||||
JsonElement value = entry.getValue();
|
}
|
||||||
switch ( name )
|
if ( object.has( "italic" ) )
|
||||||
{
|
{
|
||||||
case "bold":
|
builder.italic( getAsBoolean( object.get( "italic" ) ) );
|
||||||
builder.bold( getAsBoolean( value ) );
|
}
|
||||||
break;
|
if ( object.has( "underlined" ) )
|
||||||
case "italic":
|
{
|
||||||
builder.italic( getAsBoolean( value ) );
|
builder.underlined( getAsBoolean( object.get( "underlined" ) ) );
|
||||||
break;
|
}
|
||||||
case "underlined":
|
if ( object.has( "strikethrough" ) )
|
||||||
builder.underlined( getAsBoolean( value ) );
|
{
|
||||||
break;
|
builder.strikethrough( getAsBoolean( object.get( "strikethrough" ) ) );
|
||||||
case "strikethrough":
|
}
|
||||||
builder.strikethrough( getAsBoolean( value ) );
|
if ( object.has( "obfuscated" ) )
|
||||||
break;
|
{
|
||||||
case "obfuscated":
|
builder.obfuscated( getAsBoolean( object.get( "obfuscated" ) ) );
|
||||||
builder.obfuscated( getAsBoolean( value ) );
|
}
|
||||||
break;
|
if ( object.has( "color" ) )
|
||||||
case "color":
|
{
|
||||||
builder.color( ChatColor.of( value.getAsString() ) );
|
builder.color( ChatColor.of( object.get( "color" ).getAsString() ) );
|
||||||
break;
|
}
|
||||||
case "font":
|
if ( object.has( "font" ) )
|
||||||
builder.font( value.getAsString() );
|
{
|
||||||
break;
|
builder.font( object.get( "font" ).getAsString() );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,13 @@ public class KeybindComponentSerializer extends BaseComponentSerializer implemen
|
|||||||
public KeybindComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
public KeybindComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
JsonElement keybind = object.get( "keybind" );
|
if ( !object.has( "keybind" ) )
|
||||||
if ( keybind == null )
|
|
||||||
{
|
{
|
||||||
throw new JsonParseException( "Could not parse JSON: missing 'keybind' property" );
|
throw new JsonParseException( "Could not parse JSON: missing 'keybind' property" );
|
||||||
}
|
}
|
||||||
KeybindComponent component = new KeybindComponent();
|
KeybindComponent component = new KeybindComponent();
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
component.setKeybind( keybind.getAsString() );
|
component.setKeybind( object.get( "keybind" ).getAsString() );
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,29 +17,22 @@ public class ScoreComponentSerializer extends BaseComponentSerializer implements
|
|||||||
public ScoreComponent deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException
|
public ScoreComponent deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
JsonObject json = element.getAsJsonObject();
|
JsonObject json = element.getAsJsonObject();
|
||||||
JsonObject score = json.getAsJsonObject( "score" );
|
if ( !json.has( "score" ) )
|
||||||
if ( score == null )
|
|
||||||
{
|
{
|
||||||
throw new JsonParseException( "Could not parse JSON: missing 'score' property" );
|
throw new JsonParseException( "Could not parse JSON: missing 'score' property" );
|
||||||
}
|
}
|
||||||
JsonElement nameJson = score.get( "name" );
|
JsonObject score = json.get( "score" ).getAsJsonObject();
|
||||||
if ( nameJson == null )
|
if ( !score.has( "name" ) || !score.has( "objective" ) )
|
||||||
{
|
|
||||||
throw new JsonParseException( "A score component needs at least a name (and an objective)" );
|
|
||||||
}
|
|
||||||
JsonElement objectiveJson = score.get( "objective" );
|
|
||||||
if ( objectiveJson == null )
|
|
||||||
{
|
{
|
||||||
throw new JsonParseException( "A score component needs at least a name and an objective" );
|
throw new JsonParseException( "A score component needs at least a name and an objective" );
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = nameJson.getAsString();
|
String name = score.get( "name" ).getAsString();
|
||||||
String objective = objectiveJson.getAsString();
|
String objective = score.get( "objective" ).getAsString();
|
||||||
ScoreComponent component = new ScoreComponent( name, objective );
|
ScoreComponent component = new ScoreComponent( name, objective );
|
||||||
JsonElement value = score.get( "value" );
|
if ( score.has( "value" ) && !score.get( "value" ).getAsString().isEmpty() )
|
||||||
if ( value != null && !value.getAsString().isEmpty() )
|
|
||||||
{
|
{
|
||||||
component.setValue( value.getAsString() );
|
component.setValue( score.get( "value" ).getAsString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialize( json, component, context );
|
deserialize( json, component, context );
|
||||||
|
@ -17,17 +17,15 @@ public class SelectorComponentSerializer extends BaseComponentSerializer impleme
|
|||||||
public SelectorComponent deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException
|
public SelectorComponent deserialize(JsonElement element, Type type, JsonDeserializationContext context) throws JsonParseException
|
||||||
{
|
{
|
||||||
JsonObject object = element.getAsJsonObject();
|
JsonObject object = element.getAsJsonObject();
|
||||||
JsonElement selector = object.get( "selector" );
|
if ( !object.has( "selector" ) )
|
||||||
if ( selector == null )
|
|
||||||
{
|
{
|
||||||
throw new JsonParseException( "Could not parse JSON: missing 'selector' property" );
|
throw new JsonParseException( "Could not parse JSON: missing 'selector' property" );
|
||||||
}
|
}
|
||||||
SelectorComponent component = new SelectorComponent( selector.getAsString() );
|
SelectorComponent component = new SelectorComponent( object.get( "selector" ).getAsString() );
|
||||||
|
|
||||||
JsonElement separator = object.get( "separator" );
|
if ( object.has( "separator" ) )
|
||||||
if ( separator != null )
|
|
||||||
{
|
{
|
||||||
component.setSeparator( ComponentSerializer.deserialize( separator.getAsString() ) );
|
component.setSeparator( ComponentSerializer.deserialize( object.get( "separator" ).getAsString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
|
@ -18,10 +18,9 @@ public class TextComponentSerializer extends BaseComponentSerializer implements
|
|||||||
{
|
{
|
||||||
TextComponent component = new TextComponent();
|
TextComponent component = new TextComponent();
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
JsonElement text = object.get( "text" );
|
if ( object.has( "text" ) )
|
||||||
if ( text != null )
|
|
||||||
{
|
{
|
||||||
component.setText( text.getAsString() );
|
component.setText( object.get( "text" ).getAsString() );
|
||||||
}
|
}
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
return component;
|
return component;
|
||||||
|
@ -21,21 +21,18 @@ public class TranslatableComponentSerializer extends BaseComponentSerializer imp
|
|||||||
TranslatableComponent component = new TranslatableComponent();
|
TranslatableComponent component = new TranslatableComponent();
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
deserialize( object, component, context );
|
deserialize( object, component, context );
|
||||||
JsonElement translate = object.get( "translate" );
|
if ( !object.has( "translate" ) )
|
||||||
if ( translate == null )
|
|
||||||
{
|
{
|
||||||
throw new JsonParseException( "Could not parse JSON: missing 'translate' property" );
|
throw new JsonParseException( "Could not parse JSON: missing 'translate' property" );
|
||||||
}
|
}
|
||||||
component.setTranslate( translate.getAsString() );
|
component.setTranslate( object.get( "translate" ).getAsString() );
|
||||||
JsonElement with = object.get( "with" );
|
if ( object.has( "with" ) )
|
||||||
if ( with != null )
|
|
||||||
{
|
{
|
||||||
component.setWith( Arrays.asList( context.deserialize( with, BaseComponent[].class ) ) );
|
component.setWith( Arrays.asList( context.deserialize( object.get( "with" ), BaseComponent[].class ) ) );
|
||||||
}
|
}
|
||||||
JsonElement fallback = object.get( "fallback" );
|
if ( object.has( "fallback" ) )
|
||||||
if ( fallback != null )
|
|
||||||
{
|
{
|
||||||
component.setFallback( fallback.getAsString() );
|
component.setFallback( object.get( "fallback" ).getAsString() );
|
||||||
}
|
}
|
||||||
return component;
|
return component;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
package net.md_5.bungee.api.chat;
|
||||||
|
|
||||||
import static net.md_5.bungee.api.ChatColor.*;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -8,6 +7,7 @@ import java.util.function.Consumer;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.ObjIntConsumer;
|
import java.util.function.ObjIntConsumer;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Entity;
|
import net.md_5.bungee.api.chat.hover.content.Entity;
|
||||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
@ -20,14 +20,14 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
String json = ComponentSerializer.toString( components );
|
String json = ComponentSerializer.toString( components );
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
||||||
assertEquals( BaseComponent.toLegacyText( parsed ), BaseComponent.toLegacyText( components ) );
|
assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( components ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testDissembleReassemble(BaseComponent component)
|
public static void testDissembleReassemble(BaseComponent component)
|
||||||
{
|
{
|
||||||
String json = ComponentSerializer.toString( component );
|
String json = ComponentSerializer.toString( component );
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
||||||
assertEquals( BaseComponent.toLegacyText( parsed ), BaseComponent.toLegacyText( component ) );
|
assertEquals( TextComponent.toLegacyText( parsed ), TextComponent.toLegacyText( component ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void testAssembleDissemble(String json, boolean modern)
|
public static void testAssembleDissemble(String json, boolean modern)
|
||||||
@ -100,7 +100,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testEmptyComponentBuilderCreate()
|
public void testEmptyComponentBuilderCreate()
|
||||||
{
|
{
|
||||||
testEmptyComponentBuilder(
|
this.testEmptyComponentBuilder(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
(components) -> assertEquals( components.length, 0 ),
|
(components) -> assertEquals( components.length, 0 ),
|
||||||
(components, size) -> assertEquals( size, components.length )
|
(components, size) -> assertEquals( size, components.length )
|
||||||
@ -110,14 +110,14 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testEmptyComponentBuilderBuild()
|
public void testEmptyComponentBuilderBuild()
|
||||||
{
|
{
|
||||||
testEmptyComponentBuilder(
|
this.testEmptyComponentBuilder(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component) -> assertNull( component.getExtra() ),
|
(component) -> assertNull( component.getExtra() ),
|
||||||
(component, size) -> assertEquals( component.getExtra().size(), size )
|
(component, size) -> assertEquals( component.getExtra().size(), size )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testEmptyComponentBuilder(Function<ComponentBuilder, T> componentBuilder, Consumer<T> emptyAssertion, ObjIntConsumer<T> sizedAssertion)
|
private <T> void testEmptyComponentBuilder(Function<ComponentBuilder, T> componentBuilder, Consumer<T> emptyAssertion, ObjIntConsumer<T> sizedAssertion)
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
|
|
||||||
@ -137,9 +137,9 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
assertNotNull( builder.getCurrentComponent() );
|
assertNotNull( builder.getCurrentComponent() );
|
||||||
builder.color( GREEN );
|
builder.color( ChatColor.GREEN );
|
||||||
builder.append( "test ", ComponentBuilder.FormatRetention.ALL );
|
builder.append( "test ", ComponentBuilder.FormatRetention.ALL );
|
||||||
assertEquals( builder.getCurrentComponent().getColor(), GREEN );
|
assertEquals( builder.getCurrentComponent().getColor(), ChatColor.GREEN );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -155,17 +155,6 @@ public class ComponentsTest
|
|||||||
assertThrows( IndexOutOfBoundsException.class, () -> builder.getComponent( 1 ) );
|
assertThrows( IndexOutOfBoundsException.class, () -> builder.getComponent( 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testFormatNotColor()
|
|
||||||
{
|
|
||||||
BaseComponent[] component = new ComponentBuilder().color( BOLD ).append( "Test" ).create();
|
|
||||||
|
|
||||||
String json = ComponentSerializer.toString( component );
|
|
||||||
BaseComponent[] parsed = ComponentSerializer.parse( json );
|
|
||||||
|
|
||||||
assertNull( parsed[0].getColorRaw(), "Format should not be preserved as color" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComponentParting()
|
public void testComponentParting()
|
||||||
{
|
{
|
||||||
@ -187,8 +176,8 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testToLegacyFromLegacy()
|
public void testToLegacyFromLegacy()
|
||||||
{
|
{
|
||||||
String text = "" + GREEN + BOLD + "Hello " + WHITE + MAGIC + "world" + GRAY + "!";
|
String text = "§a§lHello §f§kworld§7!";
|
||||||
assertEquals( text, BaseComponent.toLegacyText( TextComponent.fromLegacyText( text ) ) );
|
assertEquals( text, TextComponent.toLegacyText( TextComponent.fromLegacyText( text ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -229,7 +218,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLegacyComponentBuilderAppend()
|
public void testLegacyComponentBuilderAppend()
|
||||||
{
|
{
|
||||||
String text = "" + GREEN + BOLD + "Hello " + RESET + MAGIC + "world" + GRAY + "!";
|
String text = "§a§lHello §r§kworld§7!";
|
||||||
BaseComponent[] components = TextComponent.fromLegacyText( text );
|
BaseComponent[] components = TextComponent.fromLegacyText( text );
|
||||||
BaseComponent[] builderComponents = new ComponentBuilder().append( components ).create();
|
BaseComponent[] builderComponents = new ComponentBuilder().append( components ).create();
|
||||||
assertArrayEquals( components, builderComponents );
|
assertArrayEquals( components, builderComponents );
|
||||||
@ -348,20 +337,20 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testFormatRetentionCopyFormattingCreate()
|
public void testFormatRetentionCopyFormattingCreate()
|
||||||
{
|
{
|
||||||
testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Test" ).create() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFormatRetentionCopyFormattingBuild()
|
public void testFormatRetentionCopyFormattingBuild()
|
||||||
{
|
{
|
||||||
testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Test" ).build() ) ) );
|
this.testFormatRetentionCopyFormatting( () -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Test" ).build() ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testFormatRetentionCopyFormatting(Supplier<HoverEvent> hoverEventSupplier)
|
private void testFormatRetentionCopyFormatting(Supplier<HoverEvent> hoverEventSupplier)
|
||||||
{
|
{
|
||||||
TextComponent first = new TextComponent( "Hello" );
|
TextComponent first = new TextComponent( "Hello" );
|
||||||
first.setBold( true );
|
first.setBold( true );
|
||||||
first.setColor( RED );
|
first.setColor( ChatColor.RED );
|
||||||
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
first.setClickEvent( new ClickEvent( ClickEvent.Action.RUN_COMMAND, "test" ) );
|
||||||
first.setHoverEvent( hoverEventSupplier.get() );
|
first.setHoverEvent( hoverEventSupplier.get() );
|
||||||
|
|
||||||
@ -376,18 +365,18 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderCloneCreate()
|
public void testBuilderCloneCreate()
|
||||||
{
|
{
|
||||||
testBuilderClone( (builder) -> BaseComponent.toLegacyText( builder.create() ) );
|
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.create() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCloneBuild()
|
public void testBuilderCloneBuild()
|
||||||
{
|
{
|
||||||
testBuilderClone( (builder) -> BaseComponent.toLegacyText( builder.build() ) );
|
this.testBuilderClone( (builder) -> TextComponent.toLegacyText( builder.build() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testBuilderClone(Function<ComponentBuilder, String> legacyTextFunction)
|
private void testBuilderClone(Function<ComponentBuilder, String> legacyTextFunction)
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( RED ).append( "world" ).color( DARK_RED );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.RED ).append( "world" ).color( ChatColor.DARK_RED );
|
||||||
ComponentBuilder cloned = new ComponentBuilder( builder );
|
ComponentBuilder cloned = new ComponentBuilder( builder );
|
||||||
|
|
||||||
assertEquals( legacyTextFunction.apply( builder ), legacyTextFunction.apply( cloned ) );
|
assertEquals( legacyTextFunction.apply( builder ), legacyTextFunction.apply( cloned ) );
|
||||||
@ -396,7 +385,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreateMixedComponents()
|
public void testBuilderAppendCreateMixedComponents()
|
||||||
{
|
{
|
||||||
testBuilderAppendMixedComponents(
|
this.testBuilderAppendMixedComponents(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
(components, index) -> components[index]
|
(components, index) -> components[index]
|
||||||
);
|
);
|
||||||
@ -405,13 +394,13 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendBuildMixedComponents()
|
public void testBuilderAppendBuildMixedComponents()
|
||||||
{
|
{
|
||||||
testBuilderAppendMixedComponents(
|
this.testBuilderAppendMixedComponents(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component, index) -> component.getExtra().get( index )
|
(component, index) -> component.getExtra().get( index )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilderAppendMixedComponents(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
private <T> void testBuilderAppendMixedComponents(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " );
|
||||||
TextComponent textComponent = new TextComponent( "world " );
|
TextComponent textComponent = new TextComponent( "world " );
|
||||||
@ -454,12 +443,12 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendCreate()
|
public void testBuilderAppendCreate()
|
||||||
{
|
{
|
||||||
testBuilderAppend(
|
this.testBuilderAppend(
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() ),
|
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder( "Hello world" ).create() ),
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
(components, index) -> components[index],
|
(components, index) -> components[index],
|
||||||
BaseComponent::toPlainText,
|
BaseComponent::toPlainText,
|
||||||
YELLOW + "Hello " + GREEN + "world!",
|
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
||||||
BaseComponent::toLegacyText
|
BaseComponent::toLegacyText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -467,24 +456,24 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendBuild()
|
public void testBuilderAppendBuild()
|
||||||
{
|
{
|
||||||
testBuilderAppend(
|
this.testBuilderAppend(
|
||||||
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Hello world" ).build() ) ),
|
() -> new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "Hello world" ).build() ) ),
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component, index) -> component.getExtra().get( index ),
|
(component, index) -> component.getExtra().get( index ),
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
(component) -> BaseComponent.toPlainText( component ),
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
||||||
WHITE.toString() + YELLOW + "Hello " + GREEN + "world!",
|
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
(component) -> BaseComponent.toLegacyText( component )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilderAppend(Supplier<HoverEvent> hoverEventSupplier, Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter, Function<T, String> toPlainTextFunction, String expectedLegacyText, Function<T, String> toLegacyTextFunction)
|
private <T> void testBuilderAppend(Supplier<HoverEvent> hoverEventSupplier, Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter, Function<T, String> toPlainTextFunction, String expectedLegacyText, Function<T, String> toLegacyTextFunction)
|
||||||
{
|
{
|
||||||
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
ClickEvent clickEvent = new ClickEvent( ClickEvent.Action.RUN_COMMAND, "/help " );
|
||||||
HoverEvent hoverEvent = hoverEventSupplier.get();
|
HoverEvent hoverEvent = hoverEventSupplier.get();
|
||||||
|
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.append( new ComponentBuilder( "world!" ).color( GREEN ).event( hoverEvent ).event( clickEvent ).create() ); // Intentionally using create() to append multiple individual components
|
builder.append( new ComponentBuilder( "world!" ).color( ChatColor.GREEN ).event( hoverEvent ).event( clickEvent ).create() ); // Intentionally using create() to append multiple individual components
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
T component = componentBuilder.apply( builder );
|
||||||
|
|
||||||
@ -497,10 +486,10 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendLegacyCreate()
|
public void testBuilderAppendLegacyCreate()
|
||||||
{
|
{
|
||||||
testBuilderAppendLegacy(
|
this.testBuilderAppendLegacy(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
BaseComponent::toPlainText,
|
BaseComponent::toPlainText,
|
||||||
YELLOW + "Hello " + GREEN + "world!",
|
ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
||||||
BaseComponent::toLegacyText
|
BaseComponent::toLegacyText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -508,19 +497,19 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderAppendLegacyBuild()
|
public void testBuilderAppendLegacyBuild()
|
||||||
{
|
{
|
||||||
testBuilderAppendLegacy(
|
this.testBuilderAppendLegacy(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
(component) -> BaseComponent.toPlainText( component ),
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
||||||
WHITE.toString() + YELLOW + "Hello " + GREEN + "world!",
|
ChatColor.WHITE.toString() + ChatColor.YELLOW + "Hello " + ChatColor.GREEN + "world!",
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
(component) -> BaseComponent.toLegacyText( component )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilderAppendLegacy(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
private <T> void testBuilderAppendLegacy(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( YELLOW );
|
ComponentBuilder builder = new ComponentBuilder( "Hello " ).color( ChatColor.YELLOW );
|
||||||
builder.appendLegacy( GREEN + "world!" );
|
builder.appendLegacy( "§aworld!" );
|
||||||
|
|
||||||
T component = componentBuilder.apply( builder );
|
T component = componentBuilder.apply( builder );
|
||||||
|
|
||||||
@ -532,26 +521,26 @@ public class ComponentsTest
|
|||||||
public void testBasicComponent()
|
public void testBasicComponent()
|
||||||
{
|
{
|
||||||
TextComponent textComponent = new TextComponent( "Hello world" );
|
TextComponent textComponent = new TextComponent( "Hello world" );
|
||||||
textComponent.setColor( RED );
|
textComponent.setColor( ChatColor.RED );
|
||||||
|
|
||||||
assertEquals( "Hello world", textComponent.toPlainText() );
|
assertEquals( "Hello world", textComponent.toPlainText() );
|
||||||
assertEquals( RED + "Hello world", textComponent.toLegacyText() );
|
assertEquals( ChatColor.RED + "Hello world", textComponent.toLegacyText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLegacyConverter()
|
public void testLegacyConverter()
|
||||||
{
|
{
|
||||||
BaseComponent[] test1 = TextComponent.fromLegacyText( AQUA + "Aqua " + RED + BOLD + "RedBold" );
|
BaseComponent[] test1 = TextComponent.fromLegacyText( ChatColor.AQUA + "Aqua " + ChatColor.RED + ChatColor.BOLD + "RedBold" );
|
||||||
|
|
||||||
assertEquals( "Aqua RedBold", BaseComponent.toPlainText( test1 ) );
|
assertEquals( "Aqua RedBold", BaseComponent.toPlainText( test1 ) );
|
||||||
assertEquals( AQUA + "Aqua " + RED + BOLD + "RedBold", BaseComponent.toLegacyText( test1 ) );
|
assertEquals( ChatColor.AQUA + "Aqua " + ChatColor.RED + ChatColor.BOLD + "RedBold", BaseComponent.toLegacyText( test1 ) );
|
||||||
|
|
||||||
BaseComponent[] test2 = TextComponent.fromLegacyText( "Text http://spigotmc.org " + GREEN + "google.com/test" );
|
BaseComponent[] test2 = TextComponent.fromLegacyText( "Text http://spigotmc.org " + ChatColor.GREEN + "google.com/test" );
|
||||||
|
|
||||||
assertEquals( "Text http://spigotmc.org google.com/test", BaseComponent.toPlainText( test2 ) );
|
assertEquals( "Text http://spigotmc.org google.com/test", BaseComponent.toPlainText( test2 ) );
|
||||||
//The extra ChatColor instances are sometimes inserted when not needed but it doesn't change the result
|
//The extra ChatColor instances are sometimes inserted when not needed but it doesn't change the result
|
||||||
assertEquals( WHITE + "Text " + WHITE + "http://spigotmc.org" + WHITE
|
assertEquals( ChatColor.WHITE + "Text " + ChatColor.WHITE + "http://spigotmc.org" + ChatColor.WHITE
|
||||||
+ " " + GREEN + "google.com/test" + GREEN, BaseComponent.toLegacyText( test2 ) );
|
+ " " + ChatColor.GREEN + "google.com/test" + ChatColor.GREEN, BaseComponent.toLegacyText( test2 ) );
|
||||||
|
|
||||||
ClickEvent url1 = test2[1].getClickEvent();
|
ClickEvent url1 = test2[1].getClickEvent();
|
||||||
assertNotNull( url1 );
|
assertNotNull( url1 );
|
||||||
@ -564,13 +553,36 @@ public class ComponentsTest
|
|||||||
assertEquals( "http://google.com/test", url2.getValue() );
|
assertEquals( "http://google.com/test", url2.getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTranslateComponent()
|
||||||
|
{
|
||||||
|
TranslatableComponent item = new TranslatableComponent( "item.swordGold.name" );
|
||||||
|
item.setColor( ChatColor.AQUA );
|
||||||
|
TranslatableComponent translatableComponent = new TranslatableComponent( "commands.give.success",
|
||||||
|
item, "5",
|
||||||
|
"thinkofdeath" );
|
||||||
|
|
||||||
|
assertEquals( "Given Golden Sword * 5 to thinkofdeath", translatableComponent.toPlainText() );
|
||||||
|
assertEquals( ChatColor.WHITE + "Given " + ChatColor.AQUA + "Golden Sword" + ChatColor.WHITE
|
||||||
|
+ " * " + ChatColor.WHITE + "5" + ChatColor.WHITE + " to " + ChatColor.WHITE + "thinkofdeath",
|
||||||
|
translatableComponent.toLegacyText() );
|
||||||
|
|
||||||
|
TranslatableComponent positional = new TranslatableComponent( "book.pageIndicator", "5", "50" );
|
||||||
|
|
||||||
|
assertEquals( "Page 5 of 50", positional.toPlainText() );
|
||||||
|
assertEquals( ChatColor.WHITE + "Page " + ChatColor.WHITE + "5" + ChatColor.WHITE + " of " + ChatColor.WHITE + "50", positional.toLegacyText() );
|
||||||
|
|
||||||
|
TranslatableComponent one_four_two = new TranslatableComponent( "filled_map.buried_treasure" );
|
||||||
|
assertEquals( "Buried Treasure Map", one_four_two.toPlainText() );
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreate()
|
public void testBuilderCreate()
|
||||||
{
|
{
|
||||||
testBuilder(
|
this.testBuilder(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
BaseComponent::toPlainText,
|
BaseComponent::toPlainText,
|
||||||
RED + "Hello " + BLUE + BOLD + "World" + YELLOW + BOLD + "!",
|
ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD + "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
||||||
BaseComponent::toLegacyText
|
BaseComponent::toLegacyText
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -578,20 +590,20 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderBuild()
|
public void testBuilderBuild()
|
||||||
{
|
{
|
||||||
testBuilder(
|
this.testBuilder(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component) -> BaseComponent.toPlainText( component ),
|
(component) -> BaseComponent.toPlainText( component ),
|
||||||
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
// An extra format code is appended to the beginning because there is an empty TextComponent at the start of every component
|
||||||
WHITE.toString() + RED + "Hello " + BLUE + BOLD + "World" + YELLOW + BOLD + "!",
|
ChatColor.WHITE.toString() + ChatColor.RED + "Hello " + ChatColor.BLUE + ChatColor.BOLD + "World" + ChatColor.YELLOW + ChatColor.BOLD + "!",
|
||||||
(component) -> BaseComponent.toLegacyText( component )
|
(component) -> BaseComponent.toLegacyText( component )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
private <T> void testBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> toPlainTextFunction, String expectedLegacyString, Function<T, String> toLegacyTextFunction)
|
||||||
{
|
{
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( RED ).
|
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED ).
|
||||||
append( "World" ).bold( true ).color( BLUE ).
|
append( "World" ).bold( true ).color( ChatColor.BLUE ).
|
||||||
append( "!" ).color( YELLOW ) );
|
append( "!" ).color( ChatColor.YELLOW ) );
|
||||||
|
|
||||||
assertEquals( "Hello World!", toPlainTextFunction.apply( component ) );
|
assertEquals( "Hello World!", toPlainTextFunction.apply( component ) );
|
||||||
assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
assertEquals( expectedLegacyString, toLegacyTextFunction.apply( component ) );
|
||||||
@ -600,7 +612,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderCreateReset()
|
public void testBuilderCreateReset()
|
||||||
{
|
{
|
||||||
testBuilderReset(
|
this.testBuilderReset(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
(components, index) -> components[index]
|
(components, index) -> components[index]
|
||||||
);
|
);
|
||||||
@ -609,25 +621,25 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderBuildReset()
|
public void testBuilderBuildReset()
|
||||||
{
|
{
|
||||||
testBuilderReset(
|
this.testBuilderReset(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component, index) -> component.getExtra().get( index )
|
(component, index) -> component.getExtra().get( index )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilderReset(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
private <T> void testBuilderReset(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
||||||
{
|
{
|
||||||
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( RED )
|
T component = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.append( "World" ).reset() );
|
.append( "World" ).reset() );
|
||||||
|
|
||||||
assertEquals( RED, extraGetter.apply( component, 0 ).getColor() );
|
assertEquals( ChatColor.RED, extraGetter.apply( component, 0 ).getColor() );
|
||||||
assertEquals( WHITE, extraGetter.apply( component, 1 ).getColor() );
|
assertEquals( ChatColor.WHITE, extraGetter.apply( component, 1 ).getColor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBuilderCreateFormatRetention()
|
public void testBuilderCreateFormatRetention()
|
||||||
{
|
{
|
||||||
testBuilderFormatRetention(
|
this.testBuilderFormatRetention(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
(components, index) -> components[index]
|
(components, index) -> components[index]
|
||||||
);
|
);
|
||||||
@ -636,39 +648,39 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testBuilderBuildFormatRetention()
|
public void testBuilderBuildFormatRetention()
|
||||||
{
|
{
|
||||||
testBuilderFormatRetention(
|
this.testBuilderFormatRetention(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
(component, index) -> component.getExtra().get( index )
|
(component, index) -> component.getExtra().get( index )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void testBuilderFormatRetention(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
private <T> void testBuilderFormatRetention(Function<ComponentBuilder, T> componentBuilder, BiFunction<T, Integer, BaseComponent> extraGetter)
|
||||||
{
|
{
|
||||||
T noneRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( RED )
|
T noneRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.append( "World", ComponentBuilder.FormatRetention.NONE ) );
|
.append( "World", ComponentBuilder.FormatRetention.NONE ) );
|
||||||
|
|
||||||
assertEquals( RED, extraGetter.apply( noneRetention, 0 ).getColor() );
|
assertEquals( ChatColor.RED, extraGetter.apply( noneRetention, 0 ).getColor() );
|
||||||
assertEquals( WHITE, extraGetter.apply( noneRetention, 1 ).getColor() );
|
assertEquals( ChatColor.WHITE, extraGetter.apply( noneRetention, 1 ).getColor() );
|
||||||
|
|
||||||
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "test" ).build() ) );
|
HoverEvent testEvent = new HoverEvent( HoverEvent.Action.SHOW_TEXT, new Text( new ComponentBuilder( "test" ).build() ) );
|
||||||
|
|
||||||
T formattingRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( RED )
|
T formattingRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ) );
|
.event( testEvent ).append( "World", ComponentBuilder.FormatRetention.FORMATTING ) );
|
||||||
|
|
||||||
assertEquals( RED, extraGetter.apply( formattingRetention, 0 ).getColor() );
|
assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 0 ).getColor() );
|
||||||
assertEquals( testEvent, extraGetter.apply( formattingRetention, 0 ).getHoverEvent() );
|
assertEquals( testEvent, extraGetter.apply( formattingRetention, 0 ).getHoverEvent() );
|
||||||
assertEquals( RED, extraGetter.apply( formattingRetention, 1 ).getColor() );
|
assertEquals( ChatColor.RED, extraGetter.apply( formattingRetention, 1 ).getColor() );
|
||||||
assertNull( extraGetter.apply( formattingRetention, 1 ).getHoverEvent() );
|
assertNull( extraGetter.apply( formattingRetention, 1 ).getHoverEvent() );
|
||||||
|
|
||||||
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
ClickEvent testClickEvent = new ClickEvent( ClickEvent.Action.OPEN_URL, "http://www.example.com" );
|
||||||
|
|
||||||
T eventRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( RED )
|
T eventRetention = componentBuilder.apply( new ComponentBuilder( "Hello " ).color( ChatColor.RED )
|
||||||
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ) );
|
.event( testEvent ).event( testClickEvent ).append( "World", ComponentBuilder.FormatRetention.EVENTS ) );
|
||||||
|
|
||||||
assertEquals( RED, extraGetter.apply( eventRetention, 0 ).getColor() );
|
assertEquals( ChatColor.RED, extraGetter.apply( eventRetention, 0 ).getColor() );
|
||||||
assertEquals( testEvent, extraGetter.apply( eventRetention, 0 ).getHoverEvent() );
|
assertEquals( testEvent, extraGetter.apply( eventRetention, 0 ).getHoverEvent() );
|
||||||
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 0 ).getClickEvent() );
|
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 0 ).getClickEvent() );
|
||||||
assertEquals( WHITE, extraGetter.apply( eventRetention, 1 ).getColor() );
|
assertEquals( ChatColor.WHITE, extraGetter.apply( eventRetention, 1 ).getColor() );
|
||||||
assertEquals( testEvent, extraGetter.apply( eventRetention, 1 ).getHoverEvent() );
|
assertEquals( testEvent, extraGetter.apply( eventRetention, 1 ).getHoverEvent() );
|
||||||
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
|
assertEquals( testClickEvent, extraGetter.apply( eventRetention, 1 ).getClickEvent() );
|
||||||
}
|
}
|
||||||
@ -686,9 +698,9 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
TextComponent a = new TextComponent( "A" );
|
TextComponent a = new TextComponent( "A" );
|
||||||
TextComponent b = new TextComponent( "B" );
|
TextComponent b = new TextComponent( "B" );
|
||||||
b.setColor( AQUA );
|
b.setColor( ChatColor.AQUA );
|
||||||
TextComponent c = new TextComponent( "C" );
|
TextComponent c = new TextComponent( "C" );
|
||||||
c.setColor( RED );
|
c.setColor( ChatColor.RED );
|
||||||
a.addExtra( b );
|
a.addExtra( b );
|
||||||
b.addExtra( c );
|
b.addExtra( c );
|
||||||
c.addExtra( a );
|
c.addExtra( a );
|
||||||
@ -700,7 +712,7 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
TextComponent a = new TextComponent( "A" );
|
TextComponent a = new TextComponent( "A" );
|
||||||
TextComponent b = new TextComponent( "B" );
|
TextComponent b = new TextComponent( "B" );
|
||||||
b.setColor( AQUA );
|
b.setColor( ChatColor.AQUA );
|
||||||
a.addExtra( b );
|
a.addExtra( b );
|
||||||
a.addExtra( b );
|
a.addExtra( b );
|
||||||
ComponentSerializer.toString( a );
|
ComponentSerializer.toString( a );
|
||||||
@ -711,9 +723,9 @@ public class ComponentsTest
|
|||||||
{
|
{
|
||||||
TextComponent a = new TextComponent( "A" );
|
TextComponent a = new TextComponent( "A" );
|
||||||
TextComponent b = new TextComponent( "B" );
|
TextComponent b = new TextComponent( "B" );
|
||||||
b.setColor( AQUA );
|
b.setColor( ChatColor.AQUA );
|
||||||
TextComponent c = new TextComponent( "C" );
|
TextComponent c = new TextComponent( "C" );
|
||||||
c.setColor( RED );
|
c.setColor( ChatColor.RED );
|
||||||
a.addExtra( b );
|
a.addExtra( b );
|
||||||
a.addExtra( c );
|
a.addExtra( c );
|
||||||
c.addExtra( a );
|
c.addExtra( a );
|
||||||
@ -729,15 +741,15 @@ public class ComponentsTest
|
|||||||
// collect all invalid color codes (e.g. §z, §g, ...)
|
// collect all invalid color codes (e.g. §z, §g, ...)
|
||||||
for ( char alphChar : "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray() )
|
for ( char alphChar : "0123456789abcdefghijklmnopqrstuvwxyz".toCharArray() )
|
||||||
{
|
{
|
||||||
if ( ALL_CODES.indexOf( alphChar ) == -1 )
|
if ( ChatColor.ALL_CODES.indexOf( alphChar ) == -1 )
|
||||||
{
|
{
|
||||||
allInvalidColorCodes.append( COLOR_CHAR );
|
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
||||||
allInvalidColorCodes.append( alphChar );
|
allInvalidColorCodes.append( alphChar );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// last char is a single '§'
|
// last char is a single '§'
|
||||||
allInvalidColorCodes.append( COLOR_CHAR );
|
allInvalidColorCodes.append( ChatColor.COLOR_CHAR );
|
||||||
|
|
||||||
String invalidColorCodesLegacyText = fromAndToLegacyText( allInvalidColorCodes.toString() );
|
String invalidColorCodesLegacyText = fromAndToLegacyText( allInvalidColorCodes.toString() );
|
||||||
String emptyLegacyText = fromAndToLegacyText( "" );
|
String emptyLegacyText = fromAndToLegacyText( "" );
|
||||||
@ -749,10 +761,10 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testFormattingOnlyTextConversion()
|
public void testFormattingOnlyTextConversion()
|
||||||
{
|
{
|
||||||
String text = "" + GREEN;
|
String text = "§a";
|
||||||
|
|
||||||
BaseComponent[] converted = TextComponent.fromLegacyText( text );
|
BaseComponent[] converted = TextComponent.fromLegacyText( text );
|
||||||
assertEquals( GREEN, converted[0].getColor() );
|
assertEquals( ChatColor.GREEN, converted[0].getColor() );
|
||||||
|
|
||||||
String roundtripLegacyText = BaseComponent.toLegacyText( converted );
|
String roundtripLegacyText = BaseComponent.toLegacyText( converted );
|
||||||
|
|
||||||
@ -787,8 +799,8 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLegacyHack()
|
public void testLegacyHack()
|
||||||
{
|
{
|
||||||
BaseComponent[] hexColored = new ComponentBuilder().color( of( Color.GRAY ) ).append( "Test" ).create();
|
BaseComponent[] hexColored = new ComponentBuilder().color( ChatColor.of( Color.GRAY ) ).append( "Test" ).create();
|
||||||
String legacy = BaseComponent.toLegacyText( hexColored );
|
String legacy = TextComponent.toLegacyText( hexColored );
|
||||||
|
|
||||||
BaseComponent[] reColored = TextComponent.fromLegacyText( legacy );
|
BaseComponent[] reColored = TextComponent.fromLegacyText( legacy );
|
||||||
|
|
||||||
@ -798,7 +810,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLegacyResetInBuilderCreate()
|
public void testLegacyResetInBuilderCreate()
|
||||||
{
|
{
|
||||||
testLegacyResetInBuilder(
|
this.testLegacyResetInBuilder(
|
||||||
ComponentBuilder::create,
|
ComponentBuilder::create,
|
||||||
ComponentSerializer::toString
|
ComponentSerializer::toString
|
||||||
);
|
);
|
||||||
@ -807,7 +819,7 @@ public class ComponentsTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLegacyResetInBuilderBuild()
|
public void testLegacyResetInBuilderBuild()
|
||||||
{
|
{
|
||||||
testLegacyResetInBuilder(
|
this.testLegacyResetInBuilder(
|
||||||
ComponentBuilder::build,
|
ComponentBuilder::build,
|
||||||
ComponentSerializer::toString
|
ComponentSerializer::toString
|
||||||
);
|
);
|
||||||
@ -830,8 +842,8 @@ public class ComponentsTest
|
|||||||
assertTrue( style.isEmpty() );
|
assertTrue( style.isEmpty() );
|
||||||
|
|
||||||
style = ComponentStyle.builder()
|
style = ComponentStyle.builder()
|
||||||
.bold( true )
|
.bold( true )
|
||||||
.build();
|
.build();
|
||||||
assertFalse( style.isEmpty() );
|
assertFalse( style.isEmpty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -839,10 +851,10 @@ public class ComponentsTest
|
|||||||
* In legacy chat, colors and reset both reset all formatting.
|
* In legacy chat, colors and reset both reset all formatting.
|
||||||
* Make sure it works in combination with ComponentBuilder.
|
* Make sure it works in combination with ComponentBuilder.
|
||||||
*/
|
*/
|
||||||
private static <T> void testLegacyResetInBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> componentSerializer)
|
private <T> void testLegacyResetInBuilder(Function<ComponentBuilder, T> componentBuilder, Function<T, String> componentSerializer)
|
||||||
{
|
{
|
||||||
ComponentBuilder builder = new ComponentBuilder();
|
ComponentBuilder builder = new ComponentBuilder();
|
||||||
BaseComponent[] a = TextComponent.fromLegacyText( "" + DARK_RED + UNDERLINE + "44444" + RESET + "dd" + GOLD + BOLD + "6666" );
|
BaseComponent[] a = TextComponent.fromLegacyText( "§4§n44444§rdd§6§l6666" );
|
||||||
|
|
||||||
String expected = "{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},{\"color\":"
|
String expected = "{\"extra\":[{\"underlined\":true,\"color\":\"dark_red\",\"text\":\"44444\"},{\"color\":"
|
||||||
+ "\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"}],\"text\":\"\"}";
|
+ "\"white\",\"text\":\"dd\"},{\"bold\":true,\"color\":\"gold\",\"text\":\"6666\"}],\"text\":\"\"}";
|
||||||
@ -853,7 +865,7 @@ public class ComponentsTest
|
|||||||
String test1 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
String test1 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
||||||
assertEquals( expected, test1 );
|
assertEquals( expected, test1 );
|
||||||
|
|
||||||
BaseComponent[] b = TextComponent.fromLegacyText( RESET + "rrrr" );
|
BaseComponent[] b = TextComponent.fromLegacyText( "§rrrrr" );
|
||||||
builder.append( b );
|
builder.append( b );
|
||||||
|
|
||||||
String test2 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
String test2 = componentSerializer.apply( componentBuilder.apply( builder ) );
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package net.md_5.bungee.api.chat;
|
package net.md_5.bungee.api.chat;
|
||||||
|
|
||||||
import static net.md_5.bungee.api.ChatColor.*;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import net.md_5.bungee.chat.ComponentSerializer;
|
import net.md_5.bungee.chat.ComponentSerializer;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -13,7 +12,7 @@ public class TranslatableComponentTest
|
|||||||
{
|
{
|
||||||
TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", 2, "aoeu" );
|
TranslatableComponent testComponent = new TranslatableComponent( "Test string with %s placeholders: %s", 2, "aoeu" );
|
||||||
assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() );
|
assertEquals( "Test string with 2 placeholders: aoeu", testComponent.toPlainText() );
|
||||||
assertEquals( WHITE + "Test string with " + WHITE + "2" + WHITE + " placeholders: " + WHITE + "aoeu", testComponent.toLegacyText() );
|
assertEquals( "§fTest string with §f2§f placeholders: §faoeu", testComponent.toLegacyText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -23,29 +22,7 @@ public class TranslatableComponentTest
|
|||||||
String jsonString = ComponentSerializer.toString( testComponent );
|
String jsonString = ComponentSerializer.toString( testComponent );
|
||||||
BaseComponent[] baseComponents = ComponentSerializer.parse( jsonString );
|
BaseComponent[] baseComponents = ComponentSerializer.parse( jsonString );
|
||||||
|
|
||||||
assertEquals( "Test string with a placeholder", BaseComponent.toPlainText( baseComponents ) );
|
assertEquals( "Test string with a placeholder", TextComponent.toPlainText( baseComponents ) );
|
||||||
assertEquals( WHITE + "Test string with " + WHITE + "a" + WHITE + " placeholder", BaseComponent.toLegacyText( baseComponents ) );
|
assertEquals( "§fTest string with §fa§f placeholder", TextComponent.toLegacyText( baseComponents ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTranslateComponent()
|
|
||||||
{
|
|
||||||
TranslatableComponent item = new TranslatableComponent( "item.swordGold.name" );
|
|
||||||
item.setColor( AQUA );
|
|
||||||
TranslatableComponent translatableComponent = new TranslatableComponent( "commands.give.success",
|
|
||||||
item, "5", "thinkofdeath" );
|
|
||||||
|
|
||||||
assertEquals( "Given Golden Sword * 5 to thinkofdeath", translatableComponent.toPlainText() );
|
|
||||||
assertEquals( WHITE + "Given " + AQUA + "Golden Sword" + WHITE + " * " + WHITE + "5" + WHITE + " to " + WHITE + "thinkofdeath",
|
|
||||||
translatableComponent.toLegacyText() );
|
|
||||||
|
|
||||||
TranslatableComponent positional = new TranslatableComponent( "book.pageIndicator", "5", "50" );
|
|
||||||
|
|
||||||
assertEquals( "Page 5 of 50", positional.toPlainText() );
|
|
||||||
assertEquals( WHITE + "Page " + WHITE + "5" + WHITE + " of " + WHITE + "50", positional.toLegacyText() );
|
|
||||||
|
|
||||||
TranslatableComponent one_four_two = new TranslatableComponent( "filled_map.buried_treasure" );
|
|
||||||
assertEquals( "Buried Treasure Map", one_four_two.toPlainText() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ echo "Compiling mbedtls"
|
|||||||
echo "Compiling zlib"
|
echo "Compiling zlib"
|
||||||
(cd zlib && CFLAGS=-fPIC ./configure --static && make)
|
(cd zlib && CFLAGS=-fPIC ./configure --static && make)
|
||||||
|
|
||||||
CXX="g++ -shared -fPIC -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
|
CXX="g++ -shared -fPIC -Wl,--wrap=memcpy -O3 -Wall -Werror -I$JAVA_HOME/include/ -I$JAVA_HOME/include/linux/"
|
||||||
|
|
||||||
$CXX -Imbedtls/include src/main/c/NativeCipherImpl.cpp -o src/main/resources/native-cipher.so mbedtls/library/libmbedcrypto.a
|
$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
|
$CXX -Izlib src/main/c/NativeCompressImpl.cpp -o src/main/resources/native-compress.so zlib/libz.a
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 2ca6c285a0dd3f33982dd57299012dacab1ff206
|
Subproject commit 8c89224991adff88d53cd380f42a2baa36f91454
|
@ -4,6 +4,12 @@
|
|||||||
#include <mbedtls/aes.h>
|
#include <mbedtls/aes.h>
|
||||||
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
|
#include "net_md_5_bungee_jni_cipher_NativeCipherImpl.h"
|
||||||
|
|
||||||
|
// Support for CentOS 6
|
||||||
|
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
||||||
|
extern "C" void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
||||||
|
return memcpy(dest, src, n);
|
||||||
|
}
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
|
|
||||||
struct crypto_context {
|
struct crypto_context {
|
||||||
|
@ -4,6 +4,12 @@
|
|||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
|
#include "net_md_5_bungee_jni_zlib_NativeCompressImpl.h"
|
||||||
|
|
||||||
|
// Support for CentOS 6
|
||||||
|
__asm__(".symver memcpy,memcpy@GLIBC_2.2.5");
|
||||||
|
extern "C" void *__wrap_memcpy(void *dest, const void *src, size_t n) {
|
||||||
|
return memcpy(dest, src, n);
|
||||||
|
}
|
||||||
|
|
||||||
typedef unsigned char byte;
|
typedef unsigned char byte;
|
||||||
|
|
||||||
static jfieldID consumedID;
|
static jfieldID consumedID;
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
|||||||
Subproject commit 92530568d2c128b4432467b76a3b54d93d6350bd
|
Subproject commit 4e4e4c4fbdad9dd034d8f05e2312bf845f0d4d15
|
10
pom.xml
10
pom.xml
@ -71,7 +71,7 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<build.number>unknown</build.number>
|
<build.number>unknown</build.number>
|
||||||
<lombok.version>1.18.32</lombok.version>
|
<lombok.version>1.18.30</lombok.version>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.netty</groupId>
|
<groupId>io.netty</groupId>
|
||||||
<artifactId>netty-bom</artifactId>
|
<artifactId>netty-bom</artifactId>
|
||||||
<version>4.1.109.Final</version>
|
<version>4.1.107.Final</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -151,7 +151,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.13.0</version>
|
<version>3.12.1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
@ -281,7 +281,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>3.3.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
@ -356,7 +356,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-gpg-plugin</artifactId>
|
<artifactId>maven-gpg-plugin</artifactId>
|
||||||
<version>3.2.4</version>
|
<version>3.1.0</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>verify</phase>
|
<phase>verify</phase>
|
||||||
|
@ -51,7 +51,6 @@ import net.md_5.bungee.protocol.packet.Team;
|
|||||||
import net.md_5.bungee.protocol.packet.Title;
|
import net.md_5.bungee.protocol.packet.Title;
|
||||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
import net.md_5.bungee.protocol.packet.TitleTimes;
|
||||||
import net.md_5.bungee.protocol.packet.Transfer;
|
import net.md_5.bungee.protocol.packet.Transfer;
|
||||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public abstract class AbstractPacketHandler
|
public abstract class AbstractPacketHandler
|
||||||
@ -105,10 +104,6 @@ public abstract class AbstractPacketHandler
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handle(UnsignedClientCommand command) throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handle(Respawn respawn) throws Exception
|
public void handle(Respawn respawn) throws Exception
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ import net.md_5.bungee.protocol.packet.Team;
|
|||||||
import net.md_5.bungee.protocol.packet.Title;
|
import net.md_5.bungee.protocol.packet.Title;
|
||||||
import net.md_5.bungee.protocol.packet.TitleTimes;
|
import net.md_5.bungee.protocol.packet.TitleTimes;
|
||||||
import net.md_5.bungee.protocol.packet.Transfer;
|
import net.md_5.bungee.protocol.packet.Transfer;
|
||||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
|
||||||
import net.md_5.bungee.protocol.packet.ViewDistance;
|
import net.md_5.bungee.protocol.packet.ViewDistance;
|
||||||
|
|
||||||
public enum Protocol
|
public enum Protocol
|
||||||
@ -445,7 +444,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x4F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x51 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x53 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x55 )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x62 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
ServerData.class,
|
ServerData.class,
|
||||||
@ -514,7 +513,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x12 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x14 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x15 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x18 )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x17 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket( Chat.class,
|
TO_SERVER.registerPacket( Chat.class,
|
||||||
Chat::new,
|
Chat::new,
|
||||||
@ -529,20 +528,13 @@ public enum Protocol
|
|||||||
ClientCommand.class,
|
ClientCommand.class,
|
||||||
ClientCommand::new,
|
ClientCommand::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x03 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x04 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x05 )
|
|
||||||
);
|
|
||||||
TO_SERVER.registerPacket(
|
|
||||||
UnsignedClientCommand.class,
|
|
||||||
UnsignedClientCommand::new,
|
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x04 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
ClientChat.class,
|
ClientChat.class,
|
||||||
ClientChat::new,
|
ClientChat::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
|
map( ProtocolConstants.MINECRAFT_1_19, 0x04 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x05 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x06 )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
TabCompleteRequest.class,
|
TabCompleteRequest.class,
|
||||||
@ -557,8 +549,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x09 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x09 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0A )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
ClientSettings.class,
|
ClientSettings.class,
|
||||||
@ -572,8 +563,7 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_1, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
|
map( ProtocolConstants.MINECRAFT_1_19_3, 0x07 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x08 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x09 )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
PluginMessage.class,
|
PluginMessage.class,
|
||||||
@ -591,18 +581,17 @@ public enum Protocol
|
|||||||
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
|
map( ProtocolConstants.MINECRAFT_1_19_4, 0x0D ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0F ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
|
map( ProtocolConstants.MINECRAFT_1_20_3, 0x10 ),
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x12 )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 )
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
StartConfiguration.class,
|
StartConfiguration.class,
|
||||||
StartConfiguration::new,
|
StartConfiguration::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B ),
|
map( ProtocolConstants.MINECRAFT_1_20_2, 0x0B )
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0C )
|
|
||||||
);
|
);
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
CookieResponse.class,
|
CookieResponse.class,
|
||||||
CookieResponse::new,
|
CookieResponse::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x11 )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x10 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -735,12 +724,12 @@ public enum Protocol
|
|||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
StoreCookie.class,
|
StoreCookie.class,
|
||||||
StoreCookie::new,
|
StoreCookie::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x09 )
|
||||||
);
|
);
|
||||||
TO_CLIENT.registerPacket(
|
TO_CLIENT.registerPacket(
|
||||||
Transfer.class,
|
Transfer.class,
|
||||||
Transfer::new,
|
Transfer::new,
|
||||||
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0B )
|
map( ProtocolConstants.MINECRAFT_1_20_5, 0x0A )
|
||||||
);
|
);
|
||||||
|
|
||||||
TO_SERVER.registerPacket(
|
TO_SERVER.registerPacket(
|
||||||
|
@ -45,7 +45,7 @@ public class ProtocolConstants
|
|||||||
public static final int MINECRAFT_1_20 = 763;
|
public static final int MINECRAFT_1_20 = 763;
|
||||||
public static final int MINECRAFT_1_20_2 = 764;
|
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_3 = 765;
|
||||||
public static final int MINECRAFT_1_20_5 = 766;
|
public static final int MINECRAFT_1_20_5 = 1073742003;
|
||||||
public static final List<String> SUPPORTED_VERSIONS;
|
public static final List<String> SUPPORTED_VERSIONS;
|
||||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||||
|
|
||||||
@ -104,14 +104,13 @@ public class ProtocolConstants
|
|||||||
ProtocolConstants.MINECRAFT_1_19_4,
|
ProtocolConstants.MINECRAFT_1_19_4,
|
||||||
ProtocolConstants.MINECRAFT_1_20,
|
ProtocolConstants.MINECRAFT_1_20,
|
||||||
ProtocolConstants.MINECRAFT_1_20_2,
|
ProtocolConstants.MINECRAFT_1_20_2,
|
||||||
ProtocolConstants.MINECRAFT_1_20_3,
|
ProtocolConstants.MINECRAFT_1_20_3
|
||||||
ProtocolConstants.MINECRAFT_1_20_5
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( SNAPSHOT_SUPPORT )
|
if ( SNAPSHOT_SUPPORT )
|
||||||
{
|
{
|
||||||
// supportedVersions.add( "1.20.x" );
|
// supportedVersions.add( "1.20.x" );
|
||||||
// supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 );
|
supportedVersionIds.add( ProtocolConstants.MINECRAFT_1_20_5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
SUPPORTED_VERSIONS = supportedVersions.build();
|
SUPPORTED_VERSIONS = supportedVersions.build();
|
||||||
|
@ -922,10 +922,7 @@ public class Commands extends DefinedPacket
|
|||||||
get( "minecraft:template_mirror", VOID ),
|
get( "minecraft:template_mirror", VOID ),
|
||||||
get( "minecraft:template_rotation", VOID ),
|
get( "minecraft:template_rotation", VOID ),
|
||||||
get( "minecraft:uuid", VOID ),
|
get( "minecraft:uuid", VOID ),
|
||||||
get( "minecraft:heightmap", VOID ),
|
get( "minecraft:heightmap", VOID )
|
||||||
get( "minecraft:loot_table", VOID ),
|
|
||||||
get( "minecraft:loot_predicate", VOID ),
|
|
||||||
get( "minecraft:loot_modifier", VOID )
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,11 +37,6 @@ public class LoginSuccess extends DefinedPacket
|
|||||||
{
|
{
|
||||||
properties = readProperties( buf );
|
properties = readProperties( buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
// Whether the client should disconnect on its own if it receives invalid data from the server
|
|
||||||
buf.readBoolean();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,12 +54,6 @@ public class LoginSuccess extends DefinedPacket
|
|||||||
{
|
{
|
||||||
writeProperties( properties, buf );
|
writeProperties( properties, buf );
|
||||||
}
|
}
|
||||||
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_5 )
|
|
||||||
{
|
|
||||||
// Whether the client should disconnect on its own if it receives invalid data from the server
|
|
||||||
// Vanilla sends true so we also send true
|
|
||||||
buf.writeBoolean( true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,38 +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.protocol.AbstractPacketHandler;
|
|
||||||
import net.md_5.bungee.protocol.DefinedPacket;
|
|
||||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public class UnsignedClientCommand extends DefinedPacket
|
|
||||||
{
|
|
||||||
|
|
||||||
private String command;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
command = readString( buf, 256 );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
|
|
||||||
{
|
|
||||||
writeString( command, buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(AbstractPacketHandler handler) throws Exception
|
|
||||||
{
|
|
||||||
handler.handle( this );
|
|
||||||
}
|
|
||||||
}
|
|
@ -50,18 +50,6 @@
|
|||||||
<classifier>linux-aarch_64</classifier>
|
<classifier>linux-aarch_64</classifier>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.netty.incubator</groupId>
|
|
||||||
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
|
|
||||||
<version>0.0.25.Final</version>
|
|
||||||
<classifier>linux-x86_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.netty.incubator</groupId>
|
|
||||||
<artifactId>netty-incubator-transport-native-io_uring</artifactId>
|
|
||||||
<version>0.0.25.Final</version>
|
|
||||||
<classifier>linux-aarch_64</classifier>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.pandacube.bungeecord</groupId>
|
<groupId>fr.pandacube.bungeecord</groupId>
|
||||||
<artifactId>bungeecord-api</artifactId>
|
<artifactId>bungeecord-api</artifactId>
|
||||||
@ -107,7 +95,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
<version>8.3.0</version>
|
<version>8.2.0</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- add these back in as they are not exposed by the API -->
|
<!-- add these back in as they are not exposed by the API -->
|
||||||
|
@ -130,7 +130,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
channel.write( copiedHandshake );
|
channel.write( copiedHandshake );
|
||||||
|
|
||||||
channel.setProtocol( Protocol.LOGIN );
|
channel.setProtocol( Protocol.LOGIN );
|
||||||
channel.write( new LoginRequest( user.getName(), null, user.getRewriteId() ) );
|
channel.write( new LoginRequest( user.getName(), null, user.getUniqueId() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -365,7 +365,7 @@ public class ServerConnector extends PacketHandler
|
|||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
|
LoginResult loginProfile = user.getPendingConnection().getLoginProfile();
|
||||||
user.unsafe().sendPacket( new LoginSuccess( user.getRewriteId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
user.unsafe().sendPacket( new LoginSuccess( user.getUniqueId(), user.getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
||||||
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
|
user.getCh().setEncodeProtocol( Protocol.CONFIGURATION );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -642,11 +642,6 @@ public final class UserConnection implements ProxiedPlayer
|
|||||||
return getPendingConnection().getUniqueId();
|
return getPendingConnection().getUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getRewriteId()
|
|
||||||
{
|
|
||||||
return getPendingConnection().getRewriteId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSettings(ClientSettings settings)
|
public void setSettings(ClientSettings settings)
|
||||||
{
|
{
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
@ -126,8 +126,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Getter
|
@Getter
|
||||||
private UUID offlineId;
|
private UUID offlineId;
|
||||||
@Getter
|
@Getter
|
||||||
private UUID rewriteId;
|
|
||||||
@Getter
|
|
||||||
private LoginResult loginProfile;
|
private LoginResult loginProfile;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean legacy;
|
private boolean legacy;
|
||||||
@ -229,7 +227,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
@Override
|
@Override
|
||||||
public void done(ProxyPingEvent result, Throwable error)
|
public void done(ProxyPingEvent result, Throwable error)
|
||||||
{
|
{
|
||||||
if ( ch.isClosing() )
|
if ( ch.isClosed() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -372,12 +370,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
bungee.getPluginManager().callEvent( new PlayerHandshakeEvent( InitialHandler.this, handshake ) );
|
||||||
|
|
||||||
// return if the connection was closed during the event
|
|
||||||
if ( ch.isClosing() )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ( handshake.getRequestedProtocol() )
|
switch ( handshake.getRequestedProtocol() )
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@ -478,7 +470,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) );
|
disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ch.isClosing() )
|
if ( ch.isClosed() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -585,7 +577,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
duplication = true;
|
duplication = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rewriteId = ( bungee.config.isIpForward() ) ? uniqueId : offlineId;
|
|
||||||
|
|
||||||
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
|
if ( BungeeCord.getInstance().config.isEnforceSecureProfile() )
|
||||||
{
|
{
|
||||||
@ -648,7 +639,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) );
|
disconnect( ( reason != null ) ? reason : TextComponent.fromLegacy( bungee.getTranslation( "kick_message" ) ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( ch.isClosing() )
|
if ( ch.isClosed() )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -665,7 +656,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
|
|
||||||
if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
|
if ( getVersion() < ProtocolConstants.MINECRAFT_1_20_2 )
|
||||||
{
|
{
|
||||||
unsafe.sendPacket( new LoginSuccess( getRewriteId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
unsafe.sendPacket( new LoginSuccess( getUniqueId(), getName(), ( loginProfile == null ) ? null : loginProfile.getProperties() ) );
|
||||||
ch.setProtocol( Protocol.GAME );
|
ch.setProtocol( Protocol.GAME );
|
||||||
}
|
}
|
||||||
finish2();
|
finish2();
|
||||||
@ -688,37 +679,28 @@ public class InitialHandler extends PacketHandler implements PendingConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
ch.getHandle().pipeline().get( HandlerBoss.class ).setHandler( new UpstreamBridge( bungee, userCon ) );
|
||||||
|
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
|
||||||
|
|
||||||
ServerInfo initialServer;
|
// #3612: Don't progress further if disconnected during event
|
||||||
|
if ( ch.isClosed() )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerInfo server;
|
||||||
if ( bungee.getReconnectHandler() != null )
|
if ( bungee.getReconnectHandler() != null )
|
||||||
{
|
{
|
||||||
initialServer = bungee.getReconnectHandler().getServer( userCon );
|
server = bungee.getReconnectHandler().getServer( userCon );
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
initialServer = AbstractReconnectHandler.getForcedHost( InitialHandler.this );
|
server = AbstractReconnectHandler.getForcedHost( InitialHandler.this );
|
||||||
}
|
}
|
||||||
if ( initialServer == null )
|
if ( server == null )
|
||||||
{
|
{
|
||||||
initialServer = bungee.getServerInfo( listener.getDefaultServer() );
|
server = bungee.getServerInfo( listener.getDefaultServer() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Callback<PostLoginEvent> complete = new Callback<PostLoginEvent>()
|
userCon.connect( server, null, true, ServerConnectEvent.Reason.JOIN_PROXY );
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void done(PostLoginEvent result, Throwable error)
|
|
||||||
{
|
|
||||||
// #3612: Don't progress further if disconnected during event
|
|
||||||
if ( ch.isClosing() )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
userCon.connect( result.getTarget(), null, true, ServerConnectEvent.Reason.JOIN_PROXY );
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// fire post-login event
|
|
||||||
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon, initialServer, complete ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,7 +42,6 @@ import net.md_5.bungee.protocol.packet.PluginMessage;
|
|||||||
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
import net.md_5.bungee.protocol.packet.StartConfiguration;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
import net.md_5.bungee.protocol.packet.TabCompleteRequest;
|
||||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||||
import net.md_5.bungee.protocol.packet.UnsignedClientCommand;
|
|
||||||
import net.md_5.bungee.util.AllowedCharacters;
|
import net.md_5.bungee.util.AllowedCharacters;
|
||||||
|
|
||||||
public class UpstreamBridge extends PacketHandler
|
public class UpstreamBridge extends PacketHandler
|
||||||
@ -85,7 +84,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
PlayerListItem oldPacket = new PlayerListItem();
|
PlayerListItem oldPacket = new PlayerListItem();
|
||||||
oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER );
|
oldPacket.setAction( PlayerListItem.Action.REMOVE_PLAYER );
|
||||||
PlayerListItem.Item item = new PlayerListItem.Item();
|
PlayerListItem.Item item = new PlayerListItem.Item();
|
||||||
item.setUuid( con.getRewriteId() );
|
item.setUuid( con.getUniqueId() );
|
||||||
oldPacket.setItems( new PlayerListItem.Item[]
|
oldPacket.setItems( new PlayerListItem.Item[]
|
||||||
{
|
{
|
||||||
item
|
item
|
||||||
@ -94,7 +93,7 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
PlayerListItemRemove newPacket = new PlayerListItemRemove();
|
PlayerListItemRemove newPacket = new PlayerListItemRemove();
|
||||||
newPacket.setUuids( new UUID[]
|
newPacket.setUuids( new UUID[]
|
||||||
{
|
{
|
||||||
con.getRewriteId()
|
con.getUniqueId()
|
||||||
} );
|
} );
|
||||||
|
|
||||||
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
|
for ( ProxiedPlayer player : con.getServer().getInfo().getPlayers() )
|
||||||
@ -197,12 +196,6 @@ public class UpstreamBridge extends PacketHandler
|
|||||||
handleChat( "/" + command.getCommand() );
|
handleChat( "/" + command.getCommand() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void handle(UnsignedClientCommand command) throws Exception
|
|
||||||
{
|
|
||||||
handleChat( "/" + command.getCommand() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private String handleChat(String message)
|
private String handleChat(String message)
|
||||||
{
|
{
|
||||||
for ( int index = 0, length = message.length(); index < length; index++ )
|
for ( int index = 0, length = message.length(); index < length; index++ )
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_10 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -164,7 +164,7 @@ class EntityMap_1_10 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -173,7 +173,7 @@ class EntityMap_1_10 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_11 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -165,7 +165,7 @@ class EntityMap_1_11 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -174,7 +174,7 @@ class EntityMap_1_11 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_12 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -165,7 +165,7 @@ class EntityMap_1_12 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -174,7 +174,7 @@ class EntityMap_1_12 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_12_1 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -165,7 +165,7 @@ class EntityMap_1_12_1 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1E /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -174,7 +174,7 @@ class EntityMap_1_12_1 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_13 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -165,7 +165,7 @@ class EntityMap_1_13 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x28 /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -174,7 +174,7 @@ class EntityMap_1_13 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,13 +120,13 @@ class EntityMap_1_14 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -169,7 +169,7 @@ class EntityMap_1_14 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -178,7 +178,7 @@ class EntityMap_1_14 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,13 +120,13 @@ class EntityMap_1_15 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -169,7 +169,7 @@ class EntityMap_1_15 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x2B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -178,7 +178,7 @@ class EntityMap_1_15 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,13 +120,13 @@ class EntityMap_1_16 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -169,7 +169,7 @@ class EntityMap_1_16 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x2C /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -178,7 +178,7 @@ class EntityMap_1_16 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
static final EntityMap_1_16_2 INSTANCE_1_19_4 = new EntityMap_1_16_2( 0x03, 0x30 );
|
static final EntityMap_1_16_2 INSTANCE_1_19_4 = new EntityMap_1_16_2( 0x03, 0x30 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 );
|
static final EntityMap_1_16_2 INSTANCE_1_20_2 = new EntityMap_1_16_2( -1, 0x33 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 );
|
static final EntityMap_1_16_2 INSTANCE_1_20_3 = new EntityMap_1_16_2( -1, 0x34 );
|
||||||
static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 0x37 );
|
static final EntityMap_1_16_2 INSTANCE_1_20_5 = new EntityMap_1_16_2( -1, 0x36 );
|
||||||
//
|
//
|
||||||
private final int spawnPlayerId;
|
private final int spawnPlayerId;
|
||||||
private final int spectateId;
|
private final int spectateId;
|
||||||
@ -41,13 +41,13 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == spectateId )
|
if ( packetId == spectateId && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -71,7 +71,7 @@ class EntityMap_1_16_2 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_8 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
} else if ( packetId == 0x42 /* Combat Event */ )
|
} else if ( packetId == 0x42 /* Combat Event */ )
|
||||||
@ -158,7 +158,7 @@ class EntityMap_1_8 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x18 /* Spectate */ )
|
if ( packetId == 0x18 /* Spectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -167,7 +167,7 @@ class EntityMap_1_8 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_9 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -164,7 +164,7 @@ class EntityMap_1_9 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -173,7 +173,7 @@ class EntityMap_1_9 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,13 +121,13 @@ class EntityMap_1_9_4 extends EntityMap
|
|||||||
DefinedPacket.readVarInt( packet ); // Entity ID
|
DefinedPacket.readVarInt( packet ); // Entity ID
|
||||||
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
int idLength = packet.readerIndex() - readerIndex - packetIdLength;
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
UserConnection player;
|
ProxiedPlayer player;
|
||||||
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
if ( ( player = BungeeCord.getInstance().getPlayerByOfflineUUID( uuid ) ) != null )
|
||||||
{
|
{
|
||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
packet.writerIndex( readerIndex + packetIdLength + idLength );
|
||||||
DefinedPacket.writeUUID( player.getRewriteId(), packet );
|
DefinedPacket.writeUUID( player.getUniqueId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -164,7 +164,7 @@ class EntityMap_1_9_4 extends EntityMap
|
|||||||
int packetId = DefinedPacket.readVarInt( packet );
|
int packetId = DefinedPacket.readVarInt( packet );
|
||||||
int packetIdLength = packet.readerIndex() - readerIndex;
|
int packetIdLength = packet.readerIndex() - readerIndex;
|
||||||
|
|
||||||
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ )
|
if ( packetId == 0x1B /* Spectate : PacketPlayInSpectate */ && !BungeeCord.getInstance().getConfig().isIpForward() )
|
||||||
{
|
{
|
||||||
UUID uuid = DefinedPacket.readUUID( packet );
|
UUID uuid = DefinedPacket.readUUID( packet );
|
||||||
ProxiedPlayer player;
|
ProxiedPlayer player;
|
||||||
@ -173,7 +173,7 @@ class EntityMap_1_9_4 extends EntityMap
|
|||||||
int previous = packet.writerIndex();
|
int previous = packet.writerIndex();
|
||||||
packet.readerIndex( readerIndex );
|
packet.readerIndex( readerIndex );
|
||||||
packet.writerIndex( readerIndex + packetIdLength );
|
packet.writerIndex( readerIndex + packetIdLength );
|
||||||
DefinedPacket.writeUUID( ( (UserConnection) player ).getRewriteId(), packet );
|
DefinedPacket.writeUUID( ( (UserConnection) player ).getPendingConnection().getOfflineId(), packet );
|
||||||
packet.writerIndex( previous );
|
packet.writerIndex( previous );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,9 +94,6 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
channel.setRemoteAddress( newAddress );
|
channel.setRemoteAddress( newAddress );
|
||||||
} else
|
|
||||||
{
|
|
||||||
channel.close();
|
|
||||||
}
|
}
|
||||||
} finally
|
} finally
|
||||||
{
|
{
|
||||||
|
@ -24,11 +24,6 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import io.netty.channel.unix.DomainSocketAddress;
|
import io.netty.channel.unix.DomainSocketAddress;
|
||||||
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
|
import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
|
||||||
import io.netty.handler.timeout.ReadTimeoutHandler;
|
import io.netty.handler.timeout.ReadTimeoutHandler;
|
||||||
import io.netty.incubator.channel.uring.IOUring;
|
|
||||||
import io.netty.incubator.channel.uring.IOUringDatagramChannel;
|
|
||||||
import io.netty.incubator.channel.uring.IOUringEventLoopGroup;
|
|
||||||
import io.netty.incubator.channel.uring.IOUringServerSocketChannel;
|
|
||||||
import io.netty.incubator.channel.uring.IOUringSocketChannel;
|
|
||||||
import io.netty.util.AttributeKey;
|
import io.netty.util.AttributeKey;
|
||||||
import io.netty.util.internal.PlatformDependent;
|
import io.netty.util.internal.PlatformDependent;
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
@ -107,42 +102,26 @@ public class PipelineUtils
|
|||||||
public static final String LEGACY_KICKER = "legacy-kick";
|
public static final String LEGACY_KICKER = "legacy-kick";
|
||||||
|
|
||||||
private static boolean epoll;
|
private static boolean epoll;
|
||||||
private static boolean io_uring;
|
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
if ( !PlatformDependent.isWindows() )
|
if ( !PlatformDependent.isWindows() && Boolean.parseBoolean( System.getProperty( "bungee.epoll", "true" ) ) )
|
||||||
{
|
{
|
||||||
// disable by default (experimental)
|
ProxyServer.getInstance().getLogger().info( "Not on Windows, attempting to use enhanced EpollEventLoop" );
|
||||||
if ( Boolean.parseBoolean( System.getProperty( "bungee.io_uring", "false" ) ) )
|
|
||||||
{
|
|
||||||
ProxyServer.getInstance().getLogger().info( "Not on Windows, attempting to use enhanced IOUringEventLoopGroup" );
|
|
||||||
if ( io_uring = IOUring.isAvailable() )
|
|
||||||
{
|
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "io_uring is enabled and working, utilising it! (experimental feature)" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "io_uring is not working: {0}", Util.exception( IOUring.unavailabilityCause() ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !io_uring && Boolean.parseBoolean( System.getProperty( "bungee.epoll", "true" ) ) )
|
if ( epoll = Epoll.isAvailable() )
|
||||||
{
|
{
|
||||||
ProxyServer.getInstance().getLogger().info( "Not on Windows, attempting to use enhanced EpollEventLoop" );
|
ProxyServer.getInstance().getLogger().info( "Epoll is working, utilising it!" );
|
||||||
if ( epoll = Epoll.isAvailable() )
|
} else
|
||||||
{
|
{
|
||||||
ProxyServer.getInstance().getLogger().info( "Epoll is working, utilising it!" );
|
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Epoll is not working, falling back to NIO: {0}", Util.exception( Epoll.unavailabilityCause() ) );
|
||||||
} else
|
|
||||||
{
|
|
||||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Epoll is not working, falling back to NIO: {0}", Util.exception( Epoll.unavailabilityCause() ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EventLoopGroup newEventLoopGroup(int threads, ThreadFactory factory)
|
public static EventLoopGroup newEventLoopGroup(int threads, ThreadFactory factory)
|
||||||
{
|
{
|
||||||
return io_uring ? new IOUringEventLoopGroup( threads, factory ) : epoll ? new EpollEventLoopGroup( threads, factory ) : new NioEventLoopGroup( threads, factory );
|
return epoll ? new EpollEventLoopGroup( threads, factory ) : new NioEventLoopGroup( threads, factory );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends ServerChannel> getServerChannel(SocketAddress address)
|
public static Class<? extends ServerChannel> getServerChannel(SocketAddress address)
|
||||||
@ -154,7 +133,7 @@ public class PipelineUtils
|
|||||||
return EpollServerDomainSocketChannel.class;
|
return EpollServerDomainSocketChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return io_uring ? IOUringServerSocketChannel.class : epoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
|
return epoll ? EpollServerSocketChannel.class : NioServerSocketChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends Channel> getChannel(SocketAddress address)
|
public static Class<? extends Channel> getChannel(SocketAddress address)
|
||||||
@ -166,12 +145,12 @@ public class PipelineUtils
|
|||||||
return EpollDomainSocketChannel.class;
|
return EpollDomainSocketChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
return io_uring ? IOUringSocketChannel.class : epoll ? EpollSocketChannel.class : NioSocketChannel.class;
|
return epoll ? EpollSocketChannel.class : NioSocketChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends DatagramChannel> getDatagramChannel()
|
public static Class<? extends DatagramChannel> getDatagramChannel()
|
||||||
{
|
{
|
||||||
return io_uring ? IOUringDatagramChannel.class : epoll ? EpollDatagramChannel.class : NioDatagramChannel.class;
|
return epoll ? EpollDatagramChannel.class : NioDatagramChannel.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int LOW_MARK = Integer.getInteger( "net.md_5.bungee.low_mark", 2 << 18 ); // 0.5 mb
|
private static final int LOW_MARK = Integer.getInteger( "net.md_5.bungee.low_mark", 2 << 18 ); // 0.5 mb
|
||||||
|
@ -46,7 +46,7 @@ public abstract class TabList
|
|||||||
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( playerListItem.getUuids()[i] );
|
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( playerListItem.getUuids()[i] );
|
||||||
if ( player != null )
|
if ( player != null )
|
||||||
{
|
{
|
||||||
playerListItem.getUuids()[i] = player.getRewriteId();
|
playerListItem.getUuids()[i] = player.getUniqueId();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ public abstract class TabList
|
|||||||
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
|
UserConnection player = BungeeCord.getInstance().getPlayerByOfflineUUID( item.getUuid() );
|
||||||
if ( player != null )
|
if ( player != null )
|
||||||
{
|
{
|
||||||
item.setUuid( player.getRewriteId() );
|
item.setUuid( player.getUniqueId() );
|
||||||
|
|
||||||
if ( item.getProperties() != null )
|
if ( item.getProperties() != null )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user