Compare commits

..

No commits in common. "0e9e0b58d2f4a92e4d7a31a352d50534e5dafe2e" and "f6151dce562e12f0990801b81f7c63cb55f107a3" have entirely different histories.

174 changed files with 1505 additions and 4654 deletions

View File

@ -4,12 +4,12 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
java: [8, 11, 17, 21, 25-ea]
java: [8, 11, 17, 21]
name: Java ${{ matrix.java }}

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-API</name>
@ -31,12 +31,6 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-dialog</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-event</artifactId>

View File

@ -12,7 +12,6 @@ import net.md_5.bungee.api.SkinConfiguration;
import net.md_5.bungee.api.Title;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.dialog.Dialog;
import net.md_5.bungee.api.event.ServerConnectEvent;
import net.md_5.bungee.api.score.Scoreboard;
import org.jetbrains.annotations.ApiStatus;
@ -383,31 +382,4 @@ public interface ProxiedPlayer extends Connection, CommandSender
*/
@ApiStatus.Experimental
void transfer(String host, int port);
/**
* Gets the client brand of this player.
* If the player has not sent a brand packet yet, it will return null.
*
* @return the brand of the client, or null if not received yet
*/
String getClientBrand();
/**
* Clear the player's open dialog.
*
* @throws IllegalStateException if the players version is not at least
* 1.21.6
*/
@ApiStatus.Experimental
void clearDialog();
/**
* Show a dialog to the player.
*
* @param dialog the dialog to show
* @throws IllegalStateException if the players version is not at least
* 1.21.6
*/
@ApiStatus.Experimental
void showDialog(Dialog dialog);
}

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.api.event;
import com.google.gson.JsonElement;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Cancellable;
import net.md_5.bungee.api.plugin.Event;
import org.jetbrains.annotations.ApiStatus;
/**
* Called after a {@link ProxiedPlayer} runs a custom action from a chat event
* or form submission.
*/
@Data
@ToString(callSuper = false)
@EqualsAndHashCode(callSuper = false)
@ApiStatus.Experimental
public class CustomClickEvent extends Event implements Cancellable
{
/**
* Player who clicked.
*/
private final ProxiedPlayer player;
/**
* Custom action ID.
*/
private final String id;
/**
* The data as submitted.
*/
private final JsonElement data;
/**
* Cancelled state.
*/
private boolean cancelled;
}

View File

@ -35,7 +35,6 @@ import org.eclipse.aether.transport.http.HttpTransporterFactory;
class LibraryLoader
{
private static final String REPOSITORY_PROPERTY = "net.md_5.bungee.api.plugin.centralURL";
private final Logger logger;
private final RepositorySystem repository;
private final DefaultRepositorySystemSession session;
@ -69,7 +68,7 @@ class LibraryLoader
session.setSystemProperties( System.getProperties() );
session.setReadOnly();
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", System.getProperty( REPOSITORY_PROPERTY, "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() ) );
}
public ClassLoader createLoader(PluginDescription desc)

View File

@ -1,37 +1,22 @@
package net.md_5.bungee.util;
import it.unimi.dsi.fastutil.Hash;
import gnu.trove.strategy.HashingStrategy;
import java.util.Locale;
class CaseInsensitiveHashingStrategy implements Hash.Strategy<String>
class CaseInsensitiveHashingStrategy implements HashingStrategy
{
static final CaseInsensitiveHashingStrategy INSTANCE = new CaseInsensitiveHashingStrategy();
@Override
public int hashCode(String object)
public int computeHashCode(Object object)
{
if ( object == null )
{
return 0;
}
return object.toLowerCase( Locale.ROOT ).hashCode();
return ( (String) object ).toLowerCase( Locale.ROOT ).hashCode();
}
@Override
public boolean equals(String o1, String o2)
public boolean equals(Object o1, Object o2)
{
if ( o1 == o2 )
{
return true;
}
if ( o1 == null || o2 == null )
{
return false;
}
return o1.equals( o2 ) || o1.toLowerCase( Locale.ROOT ).equals( o2.toLowerCase( Locale.ROOT ) );
return o1.equals( o2 ) || ( o1 instanceof String && o2 instanceof String && ( (String) o1 ).toLowerCase( Locale.ROOT ).equals( ( (String) o2 ).toLowerCase( Locale.ROOT ) ) );
}
}

View File

@ -1,9 +1,9 @@
package net.md_5.bungee.util;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
import gnu.trove.map.hash.TCustomHashMap;
import java.util.Map;
public class CaseInsensitiveMap<V> extends Object2ObjectOpenCustomHashMap<String, V>
public class CaseInsensitiveMap<V> extends TCustomHashMap<String, V>
{
public CaseInsensitiveMap()
@ -13,6 +13,6 @@ public class CaseInsensitiveMap<V> extends Object2ObjectOpenCustomHashMap<String
public CaseInsensitiveMap(Map<? extends String, ? extends V> map)
{
super( map, CaseInsensitiveHashingStrategy.INSTANCE );
super( CaseInsensitiveHashingStrategy.INSTANCE, map );
}
}

View File

@ -1,9 +1,9 @@
package net.md_5.bungee.util;
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
import gnu.trove.set.hash.TCustomHashSet;
import java.util.Collection;
public class CaseInsensitiveSet extends ObjectOpenCustomHashSet<String>
public class CaseInsensitiveSet extends TCustomHashSet<String>
{
public CaseInsensitiveSet()
@ -13,6 +13,6 @@ public class CaseInsensitiveSet extends ObjectOpenCustomHashSet<String>
public CaseInsensitiveSet(Collection<? extends String> collection)
{
super( collection, CaseInsensitiveHashingStrategy.INSTANCE );
super( CaseInsensitiveHashingStrategy.INSTANCE, collection );
}
}

View File

@ -13,12 +13,12 @@ public class CaseInsensitiveTest
CaseInsensitiveMap<Object> map = new CaseInsensitiveMap<>();
map.put( "FOO", obj );
assertTrue( map.containsKey( "foo" ) ); // Assert that contains is case insensitive
assertTrue( map.contains( "foo" ) ); // Assert that contains is case insensitive
assertTrue( map.entrySet().iterator().next().getKey().equals( "FOO" ) ); // Assert that case is preserved
// Assert that remove is case insensitive
map.remove( "FoO" );
assertFalse( map.containsKey( "foo" ) );
assertFalse( map.contains( "foo" ) );
}
@Test

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-bootstrap</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Bootstrap</name>
@ -48,7 +48,6 @@
<Main-Class>net.md_5.bungee.Bootstrap</Main-Class>
<Implementation-Version>${describe}</Implementation-Version>
<Specification-Version>${maven.build.timestamp}</Specification-Version>
<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access>
</manifestEntries>
</archive>
</configuration>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Chat</name>

View File

@ -4,7 +4,6 @@ import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@ -678,11 +677,11 @@ public abstract class BaseComponent
public String toPlainText()
{
StringBuilder builder = new StringBuilder();
toPlainText( new LimitedStringVisitor( builder, Short.MAX_VALUE ) );
toPlainText( builder );
return builder.toString();
}
void toPlainText(StringVisitor builder)
void toPlainText(StringBuilder builder)
{
if ( extra != null )
{
@ -702,11 +701,11 @@ public abstract class BaseComponent
public String toLegacyText()
{
StringBuilder builder = new StringBuilder();
toLegacyText( new LimitedStringVisitor( builder, Short.MAX_VALUE ) );
toLegacyText( builder );
return builder.toString();
}
void toLegacyText(StringVisitor builder)
void toLegacyText(StringBuilder builder)
{
if ( extra != null )
{
@ -717,7 +716,7 @@ public abstract class BaseComponent
}
}
void addFormat(StringVisitor builder)
void addFormat(StringBuilder builder)
{
builder.append( getColor() );
if ( isBold() )
@ -741,35 +740,4 @@ public abstract class BaseComponent
builder.append( ChatColor.MAGIC );
}
}
@FunctionalInterface
protected static interface StringVisitor
{
void append(String s);
default void append(Object obj)
{
append( String.valueOf( obj ) );
}
}
@Data
protected static class LimitedStringVisitor implements StringVisitor
{
private final StringBuilder builder;
private final int maxLength;
@Override
public void append(String s)
{
if ( builder.length() >= maxLength )
{
throw new IllegalArgumentException( "String exceeded maximum length " + maxLength );
}
builder.append( s );
}
}
}

View File

@ -4,14 +4,12 @@ import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import org.jetbrains.annotations.ApiStatus;
@Getter
@ToString
@EqualsAndHashCode
@RequiredArgsConstructor
@ApiStatus.NonExtendable
public class ClickEvent
public final class ClickEvent
{
/**
@ -54,19 +52,11 @@ public class ClickEvent
* {@link net.md_5.bungee.api.chat.ClickEvent#value} in a book.
*/
CHANGE_PAGE,
/**
* Must use subclass ShowDialogClickEvent.
*/
SHOW_DIALOG,
/**
* Copy the string given by
* {@link net.md_5.bungee.api.chat.ClickEvent#value} into the player's
* clipboard.
*/
COPY_TO_CLIPBOARD,
/**
* Must use subclass {@link ClickEventCustom}.
*/
CUSTOM,
COPY_TO_CLIPBOARD
}
}

View File

@ -1,30 +0,0 @@
package net.md_5.bungee.api.chat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
/**
* Click event which sends a custom payload to the server.
*/
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class ClickEventCustom extends ClickEvent
{
/**
* The custom payload.
*/
private final String payload;
/**
* @param id identifier for the event (lower case, no special characters)
* @param payload custom payload
*/
public ClickEventCustom(String id, String payload)
{
super( ClickEvent.Action.CUSTOM, id );
this.payload = payload;
}
}

View File

@ -13,6 +13,7 @@ import net.md_5.bungee.api.chat.hover.content.Content;
import net.md_5.bungee.api.chat.hover.content.Entity;
import net.md_5.bungee.api.chat.hover.content.Item;
import net.md_5.bungee.api.chat.hover.content.Text;
import net.md_5.bungee.chat.VersionedComponentSerializer;
import org.jetbrains.annotations.ApiStatus;
@Getter
@ -72,6 +73,22 @@ public final class HoverEvent
this.legacy = true;
}
@Deprecated
public BaseComponent[] getValue()
{
Content content = contents.get( 0 );
if ( content instanceof Text && ( (Text) content ).getValue() instanceof BaseComponent[] )
{
return (BaseComponent[]) ( (Text) content ).getValue();
}
TextComponent component = new TextComponent( VersionedComponentSerializer.getDefault().toString( content ) );
return new BaseComponent[]
{
component
};
}
/**
* Adds a content to this hover event.
*

View File

@ -50,14 +50,14 @@ public final class KeybindComponent extends BaseComponent
}
@Override
protected void toPlainText(StringVisitor builder)
protected void toPlainText(StringBuilder builder)
{
builder.append( getKeybind() );
super.toPlainText( builder );
}
@Override
protected void toLegacyText(StringVisitor builder)
protected void toLegacyText(StringBuilder builder)
{
addFormat( builder );
builder.append( getKeybind() );

View File

@ -85,14 +85,14 @@ public final class ScoreComponent extends BaseComponent
}
@Override
protected void toPlainText(StringVisitor builder)
protected void toPlainText(StringBuilder builder)
{
builder.append( this.value );
super.toPlainText( builder );
}
@Override
protected void toLegacyText(StringVisitor builder)
protected void toLegacyText(StringBuilder builder)
{
addFormat( builder );
builder.append( this.value );

View File

@ -69,14 +69,14 @@ public final class SelectorComponent extends BaseComponent
}
@Override
protected void toPlainText(StringVisitor builder)
protected void toPlainText(StringBuilder builder)
{
builder.append( this.selector );
super.toPlainText( builder );
}
@Override
protected void toLegacyText(StringVisitor builder)
protected void toLegacyText(StringBuilder builder)
{
addFormat( builder );
builder.append( this.selector );

View File

@ -280,14 +280,14 @@ public final class TextComponent extends BaseComponent
}
@Override
protected void toPlainText(StringVisitor builder)
protected void toPlainText(StringBuilder builder)
{
builder.append( text );
super.toPlainText( builder );
}
@Override
protected void toLegacyText(StringVisitor builder)
protected void toLegacyText(StringBuilder builder)
{
addFormat( builder );
builder.append( text );

View File

@ -156,20 +156,20 @@ public final class TranslatableComponent extends BaseComponent
}
@Override
protected void toPlainText(StringVisitor builder)
protected void toPlainText(StringBuilder builder)
{
convert( builder, false );
super.toPlainText( builder );
}
@Override
protected void toLegacyText(StringVisitor builder)
protected void toLegacyText(StringBuilder builder)
{
convert( builder, true );
super.toLegacyText( builder );
}
private void convert(StringVisitor builder, boolean applyFormat)
private void convert(StringBuilder builder, boolean applyFormat)
{
String trans = TranslationRegistry.INSTANCE.translate( translate );

View File

@ -12,6 +12,7 @@ import java.util.IdentityHashMap;
import java.util.Locale;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentStyle;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.hover.content.Content;
@ -41,12 +42,30 @@ public class BaseComponentSerializer
}
if ( clickEvent != null )
{
ClickEvent.Action action = ClickEvent.Action.valueOf( clickEvent.get( "action" ).getAsString().toUpperCase( Locale.ROOT ) );
if ( newClickEvent )
{
component.setClickEvent( ClickEventSerializer.NEW.deserialize( clickEvent, context ) );
switch ( action )
{
case OPEN_URL:
component.setClickEvent( new ClickEvent( action, clickEvent.get( "url" ).getAsString() ) );
break;
case RUN_COMMAND:
case SUGGEST_COMMAND:
component.setClickEvent( new ClickEvent( action, clickEvent.get( "command" ).getAsString() ) );
break;
case CHANGE_PAGE:
int page = clickEvent.get( "page" ).getAsInt();
Preconditions.checkArgument( page >= 0, "Page number has to be positive" );
component.setClickEvent( new ClickEvent( action, Integer.toString( page ) ) );
break;
default:
component.setClickEvent( new ClickEvent( action, ( clickEvent.has( "value" ) ) ? clickEvent.get( "value" ).getAsString() : "" ) );
break;
}
} else
{
component.setClickEvent( ClickEventSerializer.OLD.deserialize( clickEvent, context ) );
component.setClickEvent( new ClickEvent( action, ( clickEvent.has( "value" ) ) ? clickEvent.get( "value" ).getAsString() : "" ) );
}
}
@ -144,17 +163,39 @@ public class BaseComponentSerializer
//Events
if ( component.getClickEvent() != null )
{
JsonObject clickEvent = new JsonObject();
String actionName = component.getClickEvent().getAction().toString().toLowerCase( Locale.ROOT );
clickEvent.addProperty( "action", actionName.toLowerCase( Locale.ROOT ) );
switch ( serializer.getVersion() )
{
case V1_21_5:
object.add( "click_event", ClickEventSerializer.NEW.serialize( component.getClickEvent(), context ) );
ClickEvent.Action action = ClickEvent.Action.valueOf( actionName.toUpperCase( Locale.ROOT ) );
switch ( action )
{
case OPEN_URL:
clickEvent.addProperty( "url", component.getClickEvent().getValue() );
break;
case RUN_COMMAND:
case SUGGEST_COMMAND:
clickEvent.addProperty( "command", component.getClickEvent().getValue() );
break;
case CHANGE_PAGE:
clickEvent.addProperty( "page", Integer.parseInt( component.getClickEvent().getValue() ) );
break;
default:
clickEvent.addProperty( "value", component.getClickEvent().getValue() );
break;
}
object.add( "click_event", clickEvent );
break;
case V1_16:
object.add( "clickEvent", ClickEventSerializer.OLD.serialize( component.getClickEvent(), context ) );
clickEvent.addProperty( "value", component.getClickEvent().getValue() );
object.add( "clickEvent", clickEvent );
break;
default:
throw new IllegalArgumentException( "Unknown version " + serializer.getVersion() );
}
}
if ( component.getHoverEvent() != null )
{

View File

@ -28,12 +28,6 @@ import net.md_5.bungee.api.chat.hover.content.Item;
import net.md_5.bungee.api.chat.hover.content.ItemSerializer;
import net.md_5.bungee.api.chat.hover.content.Text;
import net.md_5.bungee.api.chat.hover.content.TextSerializer;
import net.md_5.bungee.api.dialog.Dialog;
import net.md_5.bungee.api.dialog.action.Action;
import net.md_5.bungee.api.dialog.chat.ShowDialogClickEvent;
import net.md_5.bungee.serializer.dialog.DialogActionSerializer;
import net.md_5.bungee.serializer.dialog.DialogSerializer;
import net.md_5.bungee.serializer.dialog.ShowDialogClickEventSerializer;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Experimental
@ -46,14 +40,10 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
@Getter
@ApiStatus.Internal
private final ChatVersion version;
@Getter
@ApiStatus.Internal
private final DialogSerializer dialogSerializer;
public VersionedComponentSerializer(ChatVersion version)
{
this.version = version;
this.dialogSerializer = new DialogSerializer( this );
this.gson = new GsonBuilder().
registerTypeAdapter( BaseComponent.class, this ).
registerTypeAdapter( TextComponent.class, new TextComponentSerializer( this ) ).
@ -66,10 +56,6 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
registerTypeAdapter( Text.class, new TextSerializer() ).
registerTypeAdapter( Item.class, new ItemSerializer() ).
registerTypeAdapter( ItemTag.class, new ItemTag.Serializer() ).
// Dialogs
registerTypeAdapter( Dialog.class, dialogSerializer ).
registerTypeAdapter( ShowDialogClickEvent.class, new ShowDialogClickEventSerializer() ).
registerTypeAdapter( Action.class, new DialogActionSerializer() ).
create();
}
@ -261,18 +247,6 @@ public class VersionedComponentSerializer implements JsonDeserializer<BaseCompon
{
return new TextComponent( json.getAsString() );
}
if ( json.isJsonArray() )
{
JsonArray arr = json.getAsJsonArray();
BaseComponent[] components = new BaseComponent[arr.size()];
for ( int i = 0; i < arr.size(); i++ )
{
components[i] = deserialize( arr.get( i ), BaseComponent.class, context );
}
return TextComponent.fromArray( components );
}
JsonObject object = json.getAsJsonObject();
if ( object.has( "translate" ) )
{

View File

@ -564,15 +564,6 @@ public class ComponentsTest
assertEquals( "http://google.com/test", url2.getValue() );
}
@Test
public void testLong()
{
BaseComponent test = ComponentSerializer.deserialize( "{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[{\"translate\":\"%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s%1$s\",\"with\":[\"Test\"]}]}]}]}]}]}]}]}]}]}" );
assertThrows( RuntimeException.class, test::toLegacyText );
assertThrows( RuntimeException.class, test::toPlainText );
}
@Test
public void testBuilderCreate()
{
@ -877,11 +868,4 @@ public class ComponentsTest
{
return BaseComponent.toLegacyText( TextComponent.fromLegacyText( legacyText ) );
}
@Test
public void testArrayParsing()
{
assertEquals( "Outfluencer is very cool bdfg28dhzcathisisacoolcomponent",
ComponentSerializer.deserialize( "[Outfluencer,[\" \",is,[\" very\",\" cool \",[b,dfg28dhz,[c,[a,thisisacoolcomponent]]]]]]" ).toPlainText() );
}
}

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-config</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Config</name>

View File

@ -1,28 +0,0 @@
BSD 3-Clause License
Copyright (c) 2025, SpigotMC Pty. Ltd.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,38 +0,0 @@
BungeeCord-Dialog
=================
Highly experimental API, subject to breakage. All contributions welcome, including major refactors/design changes.
Sample Plugin
-------------
```java
private class TestCommand extends Command
{
public TestCommand()
{
super( "btest" );
}
@Override
public void execute(CommandSender sender, String[] args)
{
ProxiedPlayer player = (ProxiedPlayer) sender;
Dialog notice = new NoticeDialog( new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() ) );
player.showDialog( notice );
notice = new NoticeDialog(
new DialogBase( new ComponentBuilder( "Hello" ).color( ChatColor.RED ).build() )
.inputs(
Arrays.asList( new TextInput( "first", new ComponentBuilder( "First" ).build() ),
new TextInput( "second", new ComponentBuilder( "Second" ).build() )
)
) )
.action( new ActionButton( new ComponentBuilder( "Submit Button" ).build(), new CustomClickAction( "customform" ) ) );
player.sendMessage( new ComponentBuilder( "click me" ).event( new ShowDialogClickEvent( notice ) ).build() );
}
}
```

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>
</properties>
</project-shared-configuration>

View File

@ -1,36 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-dialog</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Dialog</name>
<description>Minecraft dialog API intended for use with BungeeCord</description>
<licenses>
<license>
<name>BSD-3-Clause</name>
<url>https://github.com/SpigotMC/BungeeCord/blob/master/dialog/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.api.dialog;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.dialog.action.ActionButton;
/**
* Represents a simple dialog with text and two actions at the bottom (default:
* "yes", "no").
*/
@Data
@ToString
@EqualsAndHashCode
@AllArgsConstructor
@Accessors(fluent = true)
public final class ConfirmationDialog implements Dialog
{
@NonNull
@Accessors(fluent = false)
private DialogBase base;
/**
* The "yes" click action / bottom (appears on the left).
*/
private ActionButton yes;
/**
* The "no" click action / bottom (appears on the right).
*/
private ActionButton no;
public ConfirmationDialog(@NonNull DialogBase base)
{
this( base, null, null );
}
}

View File

@ -1,29 +0,0 @@
package net.md_5.bungee.api.dialog;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a dialog GUI.
*/
public interface Dialog
{
/**
* Gets the dialog base which contains the dialog title and other options
* common to all types of dialogs.
*
* @return mutable reference to the dialog base
*/
DialogBase getBase();
/**
* Sets the dialog base.
* <br>
* For internal use only as this is mandatory and should be specified in the
* constructor.
*
* @param base the new dialog base
*/
@ApiStatus.Internal
void setBase(DialogBase base);
}

View File

@ -1,84 +0,0 @@
package net.md_5.bungee.api.dialog;
import com.google.gson.annotations.SerializedName;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.dialog.body.DialogBody;
import net.md_5.bungee.api.dialog.input.DialogInput;
/**
* Represents the title and other options common to all dialogs.
*/
@Data
@AllArgsConstructor
@Accessors(fluent = true)
public final class DialogBase
{
/**
* The mandatory dialog title.
*/
@NonNull
private BaseComponent title;
/**
* The name which is used for any buttons leading to this dialog (eg from a
* {@link DialogListDialog}). Otherwise defaults to {@link #title}.
*/
@SerializedName("external_title")
private BaseComponent externalTitle;
/**
* The inputs to the dialog.
*/
private List<DialogInput> inputs;
/**
* The body elements which make up this dialog.
*/
private List<DialogBody> body;
/**
* Whether this dialog can be closed with the escape key (default: true).
*/
@SerializedName("can_close_with_escape")
private Boolean canCloseWithEscape;
/**
* Whether this dialog should pause the game in single-player mode (default:
* true).
*/
private Boolean pause;
/**
* Action to take after the a click or submit action is performed on the
* dialog (default: close).
*/
@SerializedName("after_action")
private AfterAction afterAction;
public DialogBase(@NonNull BaseComponent title)
{
this( title, null, null, null, null, null, null );
}
/**
* Types of action which may be taken after the dialog.
*/
public enum AfterAction
{
/**
* Close the dialog.
*/
@SerializedName("close")
CLOSE,
/**
* Do nothing.
*/
@SerializedName("none")
NONE,
/**
* Show a waiting for response screen.
*/
@SerializedName("wait_for_response")
WAIT_FOR_RESPONSE;
}
}

View File

@ -1,73 +0,0 @@
package net.md_5.bungee.api.dialog;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.dialog.action.ActionButton;
/**
* Represents a dialog which contains buttons that link to other dialogs.
*/
@Data
@ToString
@EqualsAndHashCode
@Accessors(fluent = true)
public final class DialogListDialog implements Dialog
{
@NonNull
@Accessors(fluent = false)
private DialogBase base;
/**
* The child dialogs behind each button.
*/
private List<Dialog> dialogs;
/**
* The {@link ActionButton} activated when the dialog is exited.
*/
@SerializedName("exit_action")
private ActionButton exitAction;
/**
* The number of columns for the dialog buttons (default: 2).
*/
private Integer columns;
/**
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
*/
@SerializedName("button_width")
private Integer buttonWidth;
public DialogListDialog(@NonNull DialogBase base, Dialog... dialogs)
{
this( base, Arrays.asList( dialogs ), null, null, null );
}
public DialogListDialog(@NonNull DialogBase base, List<Dialog> dialogs, ActionButton exitAction, Integer columns, Integer buttonWidth)
{
this.base = base;
this.dialogs = dialogs;
this.exitAction = exitAction;
columns( columns );
buttonWidth( buttonWidth );
}
public DialogListDialog columns(Integer columns)
{
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
this.columns = columns;
return this;
}
public DialogListDialog buttonWidth(Integer buttonWidth)
{
Preconditions.checkArgument( buttonWidth == null || ( buttonWidth >= 1 && buttonWidth <= 1024 ), "buttonWidth must be between 1 and 1024" );
this.buttonWidth = buttonWidth;
return this;
}
}

View File

@ -1,64 +0,0 @@
package net.md_5.bungee.api.dialog;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.dialog.action.ActionButton;
/**
* Represents a dialog with text a list of action buttons grouped into columns
* and scrollable if necessary.
*/
@Data
@ToString
@EqualsAndHashCode
@Accessors(fluent = true)
public final class MultiActionDialog implements Dialog
{
@NonNull
@Accessors(fluent = false)
private DialogBase base;
/**
* The action buttons in the dialog. At least one must be provided.
*/
@NonNull
private List<ActionButton> actions;
/**
* The number of columns for the dialog buttons (default: 2).
*/
private Integer columns;
/**
* The {@link ActionButton} activated when the dialog is exited.
*/
@SerializedName("exit_action")
private ActionButton exitAction;
public MultiActionDialog(@NonNull DialogBase base, @NonNull ActionButton... actions)
{
this( base, Arrays.asList( actions ), null, null );
}
public MultiActionDialog(@NonNull DialogBase base, @NonNull List<ActionButton> actions, Integer columns, ActionButton exitAction)
{
Preconditions.checkArgument( !actions.isEmpty(), "At least one action must be provided" );
this.base = base;
this.actions = actions;
columns( columns );
this.exitAction = exitAction;
}
public MultiActionDialog columns(Integer columns)
{
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
this.columns = columns;
return this;
}
}

View File

@ -1,35 +0,0 @@
package net.md_5.bungee.api.dialog;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.dialog.action.ActionButton;
/**
* Represents a simple dialog with text and one action at the bottom (default:
* "OK").
*/
@Data
@ToString
@EqualsAndHashCode
@AllArgsConstructor
@Accessors(fluent = true)
public final class NoticeDialog implements Dialog
{
@NonNull
@Accessors(fluent = false)
private DialogBase base;
/**
* The "OK" action button for the dialog.
*/
private ActionButton action;
public NoticeDialog(DialogBase base)
{
this( base, null );
}
}

View File

@ -1,71 +0,0 @@
package net.md_5.bungee.api.dialog;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.dialog.action.ActionButton;
/**
* Represents a dialog which shows the links configured/sent from the server.
*/
@Data
@ToString
@EqualsAndHashCode
@Accessors(fluent = true)
public final class ServerLinksDialog implements Dialog
{
@NonNull
@Accessors(fluent = false)
private DialogBase base;
/**
* The optional {@link ActionButton} for this dialog.
*/
@SerializedName("action")
private ActionButton action;
/**
* The {@link ActionButton} activated when the dialog is exited.
*/
@SerializedName("exit_action")
private ActionButton exitAction;
/**
* The number of columns for the dialog buttons (default: 2).
*/
private Integer columns;
/**
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
*/
@SerializedName("button_width")
private Integer buttonWidth;
public ServerLinksDialog(@NonNull DialogBase base)
{
this( base, null, null, null );
}
public ServerLinksDialog(@NonNull DialogBase base, ActionButton action, Integer columns, Integer buttonWidth)
{
this.base = base;
this.action = action;
columns( columns );
buttonWidth( buttonWidth );
}
public ServerLinksDialog columns(Integer columns)
{
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
this.columns = columns;
return this;
}
public ServerLinksDialog buttonWidth(Integer buttonWidth)
{
Preconditions.checkArgument( buttonWidth == null || ( buttonWidth >= 1 && buttonWidth <= 1024 ), "buttonWidth must be between 1 and 1024" );
this.buttonWidth = buttonWidth;
return this;
}
}

View File

@ -1,6 +0,0 @@
package net.md_5.bungee.api.dialog.action;
public interface Action
{
}

View File

@ -1,54 +0,0 @@
package net.md_5.bungee.api.dialog.action;
import com.google.common.base.Preconditions;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a dialog action which will usually appear as a button.
*/
@Data
@Accessors(fluent = true)
public class ActionButton
{
/**
* The text label of the button, mandatory.
*/
@NonNull
private BaseComponent label;
/**
* The hover tooltip of the button.
*/
private BaseComponent tooltip;
/**
* The width of the button (default: 150, minimum: 1, maximum: 1024).
*/
private Integer width;
/**
* The action to take.
*/
@NonNull
private Action action;
public ActionButton(@NonNull BaseComponent label, BaseComponent tooltip, Integer width, @NonNull Action action)
{
this.label = label;
this.tooltip = tooltip;
setWidth( width );
this.action = action;
}
public ActionButton(@NonNull BaseComponent label, @NonNull Action action)
{
this( label, null, null, action );
}
public void setWidth(Integer width)
{
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
this.width = width;
}
}

View File

@ -1,27 +0,0 @@
package net.md_5.bungee.api.dialog.action;
import com.google.gson.JsonElement;
import lombok.Data;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* Submits the dialog with the given ID and values as a payload.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
public class CustomClickAction implements Action
{
/**
* The namespaced key of the submission.
*/
@NonNull
private String id;
/**
* Fields to be added to the submission payload.
*/
private JsonElement additions;
}

View File

@ -1,25 +0,0 @@
package net.md_5.bungee.api.dialog.action;
import lombok.Data;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* Executes a command. If the command requires a permission
* higher than 0, a confirmation dialog will be shown by the client.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
public class RunCommandAction implements Action
{
/**
* The template to be applied, where variables of the form
* <code>$(key)</code> will be replaced by their
* {@link net.md_5.bungee.api.dialog.input.DialogInput#key} value.
*/
@NonNull
private String template;
}

View File

@ -1,20 +0,0 @@
package net.md_5.bungee.api.dialog.action;
import lombok.Data;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.ClickEvent;
/**
* Represents a static dialog action.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
public class StaticAction implements Action
{
@NonNull
private ClickEvent clickEvent;
}

View File

@ -1,4 +0,0 @@
/**
* Contains the different actions/buttons for a {@link net.md_5.bungee.api.dialog.Dialog}.
*/
package net.md_5.bungee.api.dialog.action;

View File

@ -1,20 +0,0 @@
package net.md_5.bungee.api.dialog.body;
import lombok.Data;
import lombok.NonNull;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents the body content of a {@link net.md_5.bungee.api.dialog.Dialog}.
*/
@Data
public abstract class DialogBody
{
/**
* The internal body type.
*/
@NonNull
@ApiStatus.Internal
private final String type;
}

View File

@ -1,49 +0,0 @@
package net.md_5.bungee.api.dialog.body;
import com.google.common.base.Preconditions;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a dialog body which consists of text constrained to a certain
* width.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class PlainMessageBody extends DialogBody
{
/**
* The text body.
*/
@NonNull
private BaseComponent contents;
/**
* The maximum width (default: 200, minimum: 1, maximum: 1024).
*/
private Integer width;
public PlainMessageBody(@NonNull BaseComponent contents)
{
this( contents, null );
}
public PlainMessageBody(@NonNull BaseComponent contents, Integer width)
{
super( "minecraft:plain_message" );
this.contents = contents;
width( width );
}
public void width(Integer width)
{
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
this.width = width;
}
}

View File

@ -1,5 +0,0 @@
/**
* Contains the different {@link net.md_5.bungee.api.dialog.Dialog} body content
* types.
*/
package net.md_5.bungee.api.dialog.body;

View File

@ -1,42 +0,0 @@
package net.md_5.bungee.api.dialog.chat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.dialog.Dialog;
/**
* Click event which displays either a pre-existing dialog by key or a custom
* dialog.
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class ShowDialogClickEvent extends ClickEvent
{
/**
* Key for a pre-existing dialog to show.
*/
private String reference;
/**
* Dialog to show.
*/
private Dialog dialog;
public ShowDialogClickEvent(String reference)
{
this( reference, null );
}
public ShowDialogClickEvent(Dialog dialog)
{
this( null, dialog );
}
private ShowDialogClickEvent(String reference, Dialog dialog)
{
super( Action.SHOW_DIALOG, null );
this.reference = reference;
this.dialog = dialog;
}
}

View File

@ -1,4 +0,0 @@
/**
* Contains dialog extensions to the chat API.
*/
package net.md_5.bungee.api.dialog.chat;

View File

@ -1,54 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a checkbox input control.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class BooleanInput extends DialogInput
{
/**
* The input label.
*/
@NonNull
private BaseComponent label;
/**
* The initial value (default: false/unchecked).
*/
private Boolean initial;
/**
* The string value to be submitted when true/checked (default: "true").
*/
@SerializedName("on_true")
private String onTrue;
/**
* The string value to be submitted when false/unchecked (default: "false").
*/
@SerializedName("on_false")
private String onFalse;
public BooleanInput(@NonNull String key, @NonNull BaseComponent label)
{
this( key, label, null, "true", "false" );
}
public BooleanInput(@NonNull String key, @NonNull BaseComponent label, Boolean initial, String onTrue, String onFalse)
{
super( "minecraft:boolean", key );
this.label = label;
this.initial = initial;
this.onTrue = onTrue;
this.onFalse = onFalse;
}
}

View File

@ -1,29 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a type of input which may be displayed/submitted with a form
* dialog.
*/
@Data
@Accessors(fluent = true)
public class DialogInput
{
/**
* The internal input type.
*/
@NonNull
@ApiStatus.Internal
private final String type;
/**
* The key corresponding to this input and associated with the value
* submitted.
*/
@NonNull
private final String key;
}

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents an option choice which may form part of a
* {@link SingleOptionInput}.
*/
@Data
@AllArgsConstructor
@Accessors(fluent = true)
public class InputOption
{
/**
* The string value associated with this option, to be submitted when
* selected.
*/
@NonNull
private String id;
/**
* The text to display for this option.
*/
private BaseComponent display;
/**
* Whether this option is the one initially selected. Only one option may
* have this value as true (default: first option).
*/
private Boolean initial;
public InputOption(@NonNull String id)
{
this( id, null, null );
}
}

View File

@ -1,103 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import com.google.common.base.Preconditions;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a number slider input.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class NumberRangeInput extends DialogInput
{
/**
* The width of the input (default: 200, minimum: 1, maximum: 1024).
*/
private Integer width;
/**
* The label of the slider.
*/
@NonNull
private BaseComponent label;
/**
* A translate key used to display the label value (default:
* options.generic_value).
*/
private String labelFormat;
/**
* The start position of the slider (leftmost position).
*/
private float start;
/**
* The end position of the slider (rightmost position).
*/
private float end;
/**
* The steps in which the input will be increased or decreased, or null if
* no specific steps.
*/
private Float step;
/**
* The initial value of number input, or null to fall back to the middle.
*/
private Float initial;
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end)
{
this( key, null, label, "options.generic_value", start, end, null, null );
}
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end, Float step)
{
this( key, null, label, "options.generic_value", start, end, step, null );
}
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end, Float step, Float initial)
{
this( key, null, label, "options.generic_value", start, end, step, initial );
}
public NumberRangeInput(@NonNull String key, Integer width, @NonNull BaseComponent label, String labelFormat, float start, float end, Float step, Float initial)
{
super( "minecraft:number_range", key );
width( width );
this.label = label;
this.labelFormat = labelFormat;
this.start = start;
this.end = end;
step( step );
initial( initial );
}
public NumberRangeInput width(Integer width)
{
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "with must be between 1 and 1024" );
this.width = width;
return this;
}
public NumberRangeInput step(Float step)
{
Preconditions.checkArgument( step == null || step > 0, "step must be null or greater than zero" );
this.step = step;
return this;
}
public NumberRangeInput initial(Float initial)
{
// we need to calculate if the initial value is between start and end, regardless of the order
float min = Math.min( start, end );
float max = Math.max( start, end );
Preconditions.checkArgument( initial == null || ( initial >= min && initial <= max ), "initial must be null or between start and end" );
this.initial = initial;
return this;
}
}

View File

@ -1,66 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a single option (dropdown) input.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class SingleOptionInput extends DialogInput
{
/**
* The width of the input (default: 200, minimum: 1, maximum: 1024).
*/
private Integer width;
/**
* The input label.
*/
@NonNull
private BaseComponent label;
/**
* Whether the label is visible (default: true).
*/
@SerializedName("label_visible")
private Boolean labelVisible;
/**
* The non-empty list of options to be selected from.
*/
@NonNull
private List<InputOption> options;
public SingleOptionInput(@NonNull String key, @NonNull BaseComponent label, @NonNull InputOption... options)
{
this( key, null, label, null, Arrays.asList( options ) );
}
public SingleOptionInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, @NonNull List<InputOption> options)
{
super( "minecraft:single_option", key );
Preconditions.checkArgument( !options.isEmpty(), "At least one option must be provided" );
width( width );
this.label = label;
this.labelVisible = labelVisible;
this.options = options;
}
public SingleOptionInput width(Integer width)
{
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
this.width = width;
return this;
}
}

View File

@ -1,110 +0,0 @@
package net.md_5.bungee.api.dialog.input;
import com.google.common.base.Preconditions;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.ToString;
import lombok.experimental.Accessors;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Represents a textbox input.
*/
@Data
@Accessors(fluent = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TextInput extends DialogInput
{
/**
* The width of this text input (default: 200, minimum: 1, maximum: 1024).
*/
private Integer width;
/**
* The label of this text input.
*/
@NonNull
private BaseComponent label;
/**
* The visibility of this text input's label.
*/
@SerializedName("label_visible")
private Boolean labelVisible;
/**
* The initial value of this text input.
*/
private String initial;
/**
* The maximum length of the input (default: 32).
*/
@SerializedName("max_length")
private Integer maxLength;
/**
* If present, allows users to input multiple lines.
*/
private Multiline multiline;
public TextInput(@NonNull String key, @NonNull BaseComponent label)
{
this( key, null, label, null, null, null, null );
}
public TextInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, String initial, Integer maxLength)
{
this( key, width, label, labelVisible, initial, maxLength, null );
}
public TextInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, String initial, Integer maxLength, Multiline multiline)
{
super( "minecraft:text", key );
width( width );
this.label = label;
this.labelVisible = labelVisible;
this.initial = initial;
this.maxLength = maxLength;
this.multiline = multiline;
}
/**
* Configuration data for a multiline input.
*/
@Data
@NoArgsConstructor
@Accessors(fluent = true)
public static class Multiline
{
/**
* The maximum length of input, or null to disable any limits.
*/
@SerializedName("max_lines")
private Integer maxLines;
/**
* The height of this input (default: 32, minimum: 1, maximum: 512).
*/
private Integer height;
public Multiline(Integer maxLines, Integer height)
{
height( height ).maxLines( maxLines );
}
public Multiline height(Integer height)
{
Preconditions.checkArgument( height == null || height >= 1 && height <= 512, "height must null or be between 1 and 512" );
this.height = height;
return this;
}
}
public TextInput width(Integer width)
{
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
this.width = width;
return this;
}
}

View File

@ -1,4 +0,0 @@
/**
* Represents the various input controls which may be present on form dialogs.
*/
package net.md_5.bungee.api.dialog.input;

View File

@ -1,4 +0,0 @@
/**
* Contains the core classes for the display of a {@link net.md_5.bungee.api.dialog.Dialog}.
*/
package net.md_5.bungee.api.dialog;

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-event</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Event</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-log</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Log</name>
@ -20,9 +20,9 @@
<dependencies>
<dependency>
<groupId>org.jline</groupId>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>3.30.4</version>
<version>2.12.1</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -1,18 +1,26 @@
package net.md_5.bungee.log;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.jline.reader.LineReader;
import jline.console.ConsoleReader;
public class BungeeLogger extends Logger
{
private final LogDispatcher dispatcher = new LogDispatcher( this );
public BungeeLogger(String loggerName, String filePattern, LineReader reader)
// CHECKSTYLE:OFF
@SuppressWarnings(
{
"CallToPrintStackTrace", "CallToThreadStartDuringObjectConstruction"
})
// CHECKSTYLE:ON
@SuppressFBWarnings("SC_START_IN_CTOR")
public BungeeLogger(String loggerName, String filePattern, ConsoleReader reader)
{
super( loggerName, null );
setLevel( Level.ALL );

View File

@ -1,15 +1,15 @@
package net.md_5.bungee.log;
import java.io.IOException;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.regex.Pattern;
import jline.console.ConsoleReader;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.ChatColor;
import org.jline.jansi.Ansi;
import org.jline.reader.LineReader;
import org.fusesource.jansi.Ansi;
import org.fusesource.jansi.Ansi.Erase;
@RequiredArgsConstructor
public class ColouredWriter extends Handler
{
@ -52,7 +52,12 @@ public class ColouredWriter extends Handler
compile( ChatColor.RESET, Ansi.ansi().a( Ansi.Attribute.RESET ).toString() ),
};
//
private final LineReader console;
private final ConsoleReader console;
public ColouredWriter(ConsoleReader console)
{
this.console = console;
}
public void print(String s)
{
@ -60,7 +65,14 @@ public class ColouredWriter extends Handler
{
s = replacement.pattern.matcher( s ).replaceAll( replacement.replacement );
}
console.printAbove( s + Ansi.ansi().reset().toString() );
try
{
console.print( Ansi.ansi().eraseLine( Erase.ALL ).toString() + ConsoleReader.RESET_LINE + s + Ansi.ansi().reset().toString() );
console.drawLine();
console.flush();
} catch ( IOException ex )
{
}
}
@Override

View File

@ -18,6 +18,7 @@ public class ConciseFormatter extends Formatter
private final boolean coloured;
@Override
@SuppressWarnings("ThrowableResultIgnored")
public String format(LogRecord record)
{
StringBuilder formatted = new StringBuilder();

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-alert</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_alert</name>

View File

@ -15,7 +15,7 @@ public class CommandAlertRaw extends Command
public CommandAlertRaw()
{
super( "alertraw", "bungeecord.command.alertraw" );
super( "alertraw", "bungeecord.command.alert" );
}
@Override

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-find</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_find</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-kick</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_kick</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-list</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_list</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-send</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_send</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-cmd-server</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>cmd_server</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>pom</packaging>
<name>BungeeCord Modules</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-module-reconnect-yaml</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>reconnect_yaml</name>

View File

@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-native</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<version>1.21-R0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-Native</name>

View File

@ -1,8 +1,6 @@
package net.md_5.bungee.jni;
import com.google.common.io.ByteStreams;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@ -95,31 +93,7 @@ public final class NativeCode<T>
return loaded;
}
public static boolean hasDirectBuffers()
{
ByteBuf directBuffer = null;
boolean hasMemoryAddress = false;
try
{
directBuffer = Unpooled.directBuffer();
hasMemoryAddress = directBuffer.hasMemoryAddress();
} finally
{
if ( directBuffer != null )
{
directBuffer.release();
}
}
return hasMemoryAddress;
}
public static boolean isSupported()
{
return isSupportedPlatformAndArch() && hasDirectBuffers();
}
private static boolean isSupportedPlatformAndArch()
{
return "Linux".equals( System.getProperty( "os.name" ) ) && ( isAmd64() || isAarch64() );
}

View File

@ -1,28 +0,0 @@
BSD 3-Clause License
Copyright (c) 2025, SpigotMC Pty. Ltd.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,4 +0,0 @@
BungeeCord-NBT
=================
Minimal implementation of NBT for use in BungeeCord

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-editor-indent.CodeStyle.usedProfile>project</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>NEW_LINE</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinMethodCallParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSwitchParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinCatchParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinTryParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinSynchronizedParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinArrayInitBrackets>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinWhileParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinIfParens>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceWithinForParens>
</properties>
</project-shared-configuration>

View File

@ -1,27 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-nbt</artifactId>
<version>1.21-R0.4-SNAPSHOT</version>
<packaging>jar</packaging>
<name>BungeeCord-NBT</name>
<description>Minimal implementation of NBT for use in BungeeCord</description>
<licenses>
<license>
<name>BSD-3-Clause</name>
<url>https://github.com/SpigotMC/BungeeCord/blob/master/nbt/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>

View File

@ -1,52 +0,0 @@
package net.md_5.bungee.nbt;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.limit.NBTLimiter;
import net.md_5.bungee.nbt.type.CompoundTag;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NamedTag implements Tag
{
private String name;
private TypedTag tag;
/**
* Reads the data of the {@link DataInput} and parses it into this
* {@link NamedTag}.
*
* @param input input to read from
* @param limiter limitation of the read data
*/
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
byte type = input.readByte();
name = CompoundTag.readString( input, limiter );
tag = Tag.readById( type, input, limiter );
}
/**
* Write this {@link NamedTag} into a {@link DataOutput}.
*
* @param output the output to write to
*/
@Override
public void write(DataOutput output) throws IOException
{
Preconditions.checkNotNull( name, "name cannot be null" );
Preconditions.checkNotNull( tag, "tag cannot be null" );
output.writeByte( tag.getId() );
CompoundTag.writeString( name, output );
tag.write( output );
}
}

View File

@ -1,167 +0,0 @@
package net.md_5.bungee.nbt;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.function.Supplier;
import net.md_5.bungee.nbt.exception.NBTFormatException;
import net.md_5.bungee.nbt.limit.NBTLimiter;
import net.md_5.bungee.nbt.type.ByteArrayTag;
import net.md_5.bungee.nbt.type.ByteTag;
import net.md_5.bungee.nbt.type.CompoundTag;
import net.md_5.bungee.nbt.type.DoubleTag;
import net.md_5.bungee.nbt.type.EndTag;
import net.md_5.bungee.nbt.type.FloatTag;
import net.md_5.bungee.nbt.type.IntArrayTag;
import net.md_5.bungee.nbt.type.IntTag;
import net.md_5.bungee.nbt.type.ListTag;
import net.md_5.bungee.nbt.type.LongArrayTag;
import net.md_5.bungee.nbt.type.LongTag;
import net.md_5.bungee.nbt.type.ShortTag;
import net.md_5.bungee.nbt.type.StringTag;
public interface Tag
{
int OBJECT_HEADER = 8;
int ARRAY_HEADER = 12;
int STRING_SIZE = 28;
int OBJECT_REFERENCE = 4;
Supplier<? extends TypedTag>[] CONSTRUCTORS = new Supplier[]
{
EndTag::new,
ByteTag::new,
ShortTag::new,
IntTag::new,
LongTag::new,
FloatTag::new,
DoubleTag::new,
ByteArrayTag::new,
StringTag::new,
ListTag::new,
CompoundTag::new,
IntArrayTag::new,
LongArrayTag::new
};
byte END = 0;
byte BYTE = 1;
byte SHORT = 2;
byte INT = 3;
byte LONG = 4;
byte FLOAT = 5;
byte DOUBLE = 6;
byte BYTE_ARRAY = 7;
byte STRING = 8;
byte LIST = 9;
byte COMPOUND = 10;
byte INT_ARRAY = 11;
byte LONG_ARRAY = 12;
/**
* Reads the data into this tag.
*
* @param input the input to read from
* @param limiter the limiter for this read operation
* @throws IOException if an exception occurs during io operations
*/
void read(DataInput input, NBTLimiter limiter) throws IOException;
/**
* Writes this tag into a {@link DataOutput}.
*
* @param output the output to write to
* @throws IOException if an exception occurs during io operations
*/
void write(DataOutput output) throws IOException;
/**
* Reads a {@link Tag} from the given {@link DataInput},
* based on the specified tag type, with limitations of the
* {@link NBTLimiter}.
*
* @param id the nbt type
* @param input the input to read from
* @param limiter the limiter for this read operation
* @return the deserialized {@link Tag}
* @throws IOException if an exception occurs during io operations
*/
static TypedTag readById(byte id, DataInput input, NBTLimiter limiter) throws IOException
{
if ( id < END || id > LONG_ARRAY )
{
throw new NBTFormatException( "Invalid tag id: " + id );
}
TypedTag tag = CONSTRUCTORS[id].get();
tag.read( input, limiter );
return tag;
}
/**
* Reads a {@link NamedTag} from the given {@link DataInput},
* with limitations of the {@link NBTLimiter}.
*
* @param input the data input to read from
* @param limiter the limiter for this read operation
* @return the deserialized {@link NamedTag}
* @throws IOException if an exception occurs during io operations
*/
static NamedTag readNamedTag(DataInput input, NBTLimiter limiter) throws IOException
{
NamedTag namedTag = new NamedTag();
namedTag.read( input, limiter );
return namedTag;
}
/**
* Serializes the given {@link TypedTag} into a byte array.
* This is the inverse operation of {@link #fromByteArray(byte[])}.
*
* @param tag the tag to convert
* @return the serialized byte array
* @throws IOException if an exception occurs during io operations
*/
static byte[] toByteArray(TypedTag tag) throws IOException
{
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
DataOutputStream dataOutputStream = new DataOutputStream( byteArrayOutputStream );
dataOutputStream.writeByte( tag.getId() );
tag.write( dataOutputStream );
return byteArrayOutputStream.toByteArray();
}
/**
* Deserializes the given byte array into a {@link TypedTag}.
* This is the inverse operation of {@link #toByteArray(TypedTag)}.
*
* @param data the byte array to read from
* @return the deserialized {@link TypedTag}
* @throws IOException if an exception occurs during io operations
*/
static TypedTag fromByteArray(byte[] data) throws IOException
{
return fromByteArray( data, NBTLimiter.unlimitedSize() );
}
/**
* Deserializes the given byte array into a {@link TypedTag},
* with limitations of the {@link NBTLimiter}.
*
* @param data the byte array to read from
* @param limiter the limiter for this read operation
* @return the deserialized {@link TypedTag}
* @throws IOException if an exception occurs during io operations
*/
static TypedTag fromByteArray(byte[] data, NBTLimiter limiter) throws IOException
{
DataInputStream stream = new DataInputStream( new ByteArrayInputStream( data ) );
byte type = stream.readByte();
return readById( type, stream, limiter );
}
}

View File

@ -1,12 +0,0 @@
package net.md_5.bungee.nbt;
public interface TypedTag extends Tag
{
/**
* Gets the id of this tag's type.
*
* @return the id related to this tag's type
*/
byte getId();
}

View File

@ -1,10 +0,0 @@
package net.md_5.bungee.nbt.exception;
public class NBTException extends RuntimeException
{
public NBTException(String message)
{
super( message );
}
}

View File

@ -1,10 +0,0 @@
package net.md_5.bungee.nbt.exception;
public class NBTFormatException extends NBTException
{
public NBTFormatException(String message)
{
super( message );
}
}

View File

@ -1,10 +0,0 @@
package net.md_5.bungee.nbt.exception;
public class NBTLimitException extends NBTException
{
public NBTLimitException(String message)
{
super( message );
}
}

View File

@ -1,66 +0,0 @@
package net.md_5.bungee.nbt.limit;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.nbt.exception.NBTLimitException;
@RequiredArgsConstructor
public class NBTLimiter
{
private static final int MAX_STACK_DEPTH = 512;
//
private final long maxBytes;
private final int maxDepth;
public static NBTLimiter unlimitedSize()
{
return new NBTLimiter( Long.MAX_VALUE, MAX_STACK_DEPTH );
}
public NBTLimiter(long maxBytes)
{
this( maxBytes, MAX_STACK_DEPTH );
}
private long usedBytes;
private int depth;
public void countBytes(long amount)
{
if ( amount < 0 )
{
throw new NBTLimitException( "NBT limiter tried to count negative byte amount" );
}
if ( ( usedBytes = Math.addExact( usedBytes, amount ) ) > maxBytes )
{
throw new NBTLimitException( "NBT tag is to big, bytes > " + maxBytes );
}
}
public void countBytes(long amount, long factor)
{
if ( amount < 0 || factor < 0 )
{
throw new NBTLimitException( "NBT limiter tried to count negative byte amount" );
}
countBytes( Math.multiplyExact( amount, factor ) );
}
public void push()
{
if ( ( depth = Math.addExact( depth, 1 ) ) > maxDepth )
{
throw new NBTLimitException( "NBT tag is to complex, depth > " + maxDepth );
}
}
public void pop()
{
if ( --depth < 0 )
{
throw new NBTLimitException( "NBT limiter tried to pop depth 0" );
}
}
}

View File

@ -1,44 +0,0 @@
package net.md_5.bungee.nbt.type;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ByteArrayTag implements TypedTag
{
private byte[] value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( OBJECT_HEADER + ARRAY_HEADER + Integer.BYTES );
int length = input.readInt();
limiter.countBytes( length, Byte.BYTES );
input.readFully( value = new byte[ length ] );
}
@Override
public void write(DataOutput output) throws IOException
{
Preconditions.checkNotNull( value, "byte array value cannot be null" );
output.writeInt( value.length );
output.write( value );
}
@Override
public byte getId()
{
return Tag.BYTE_ARRAY;
}
}

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.nbt.type;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ByteTag implements TypedTag
{
private byte value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( OBJECT_HEADER + Byte.BYTES );
value = input.readByte();
}
@Override
public void write(DataOutput output) throws IOException
{
output.write( value );
}
@Override
public byte getId()
{
return Tag.BYTE;
}
}

View File

@ -1,99 +0,0 @@
package net.md_5.bungee.nbt.type;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.exception.NBTFormatException;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CompoundTag implements TypedTag
{
private static final int MAP_SIZE_IN_BYTES = 48;
private static final int MAP_ENTRY_SIZE_IN_BYTES = 32;
//
private Map<String, TypedTag> value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.push();
limiter.countBytes( MAP_SIZE_IN_BYTES );
Map<String, TypedTag> map = new LinkedHashMap<>();
for ( byte type; ( type = input.readByte() ) != Tag.END; )
{
String name = readString( input, limiter );
TypedTag tag = Tag.readById( type, input, limiter );
if ( map.put( name, tag ) == null )
{
limiter.countBytes( MAP_ENTRY_SIZE_IN_BYTES + OBJECT_REFERENCE );
}
}
limiter.pop();
value = map;
}
@Override
public void write(DataOutput output) throws IOException
{
Preconditions.checkNotNull( value, "compound tag map cannot be null" );
for ( Map.Entry<String, TypedTag> entry : value.entrySet() )
{
String name = entry.getKey();
TypedTag tag = entry.getValue();
output.writeByte( tag.getId() );
if ( tag.getId() == Tag.END )
{
throw new NBTFormatException( "invalid end tag in compound tag" );
}
writeString( name, output );
tag.write( output );
}
output.writeByte( 0 );
}
@Override
public byte getId()
{
return Tag.COMPOUND;
}
public static String readString(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( STRING_SIZE );
String string = input.readUTF();
limiter.countBytes( string.length(), Character.BYTES );
return string;
}
public static void writeString(String string, DataOutput output) throws IOException
{
output.writeUTF( string );
}
public TypedTag get(String key)
{
return value.get( key );
}
public void put(String key, TypedTag tag)
{
value.put( key, tag );
}
public int size()
{
return value.size();
}
}

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.nbt.type;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DoubleTag implements TypedTag
{
private double value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( OBJECT_HEADER + Double.BYTES );
value = input.readDouble();
}
@Override
public void write(DataOutput output) throws IOException
{
output.writeDouble( value );
}
@Override
public byte getId()
{
return Tag.DOUBLE;
}
}

View File

@ -1,34 +0,0 @@
package net.md_5.bungee.nbt.type;
import java.io.DataInput;
import java.io.DataOutput;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
public class EndTag implements TypedTag
{
public static final EndTag INSTANCE = new EndTag();
@Override
public void read(DataInput input, NBTLimiter limiter)
{
limiter.countBytes( OBJECT_HEADER );
}
@Override
public void write(DataOutput output)
{
}
@Override
public byte getId()
{
return Tag.END;
}
}

View File

@ -1,39 +0,0 @@
package net.md_5.bungee.nbt.type;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class FloatTag implements TypedTag
{
private float value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( OBJECT_HEADER + Float.BYTES );
value = input.readFloat();
}
@Override
public void write(DataOutput output) throws IOException
{
output.writeFloat( value );
}
@Override
public byte getId()
{
return Tag.FLOAT;
}
}

View File

@ -1,52 +0,0 @@
package net.md_5.bungee.nbt.type;
import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IntArrayTag implements TypedTag
{
private int[] value;
@Override
public void read(DataInput input, NBTLimiter limiter) throws IOException
{
limiter.countBytes( OBJECT_HEADER + ARRAY_HEADER + Integer.BYTES );
int length = input.readInt();
limiter.countBytes( length, Integer.BYTES );
int[] data = new int[ length ];
for ( int i = 0; i < length; i++ )
{
data[i] = input.readInt();
}
value = data;
}
@Override
public void write(DataOutput output) throws IOException
{
Preconditions.checkNotNull( value, "int array value cannot be null" );
output.writeInt( value.length );
for ( int i : value )
{
output.writeInt( i );
}
}
@Override
public byte getId()
{
return Tag.INT_ARRAY;
}
}

Some files were not shown because too many files have changed in this diff Show More