Skip to content

Commit e78bafb

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # .github/workflows/maven.yml # pom.xml
2 parents 78a5eaa + 3a5c731 commit e78bafb

File tree

176 files changed

+3429
-2244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+3429
-2244
lines changed

api/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>net.md-5</groupId>
88
<artifactId>bungeecord-parent</artifactId>
9-
<version>1.21-R0.3-SNAPSHOT</version>
9+
<version>1.21-R0.4-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

1313
<groupId>net.md-5</groupId>
1414
<artifactId>bungeecord-api</artifactId>
15-
<version>1.21-R0.3-SNAPSHOT</version>
15+
<version>1.21-R0.4-SNAPSHOT</version>
1616
<packaging>jar</packaging>
1717

1818
<name>BungeeCord-API</name>

api/src/main/java/net/md_5/bungee/api/event/CustomClickEvent.java

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package net.md_5.bungee.api.event;
22

3-
import java.util.Map;
3+
import com.google.gson.JsonElement;
44
import lombok.Data;
55
import lombok.EqualsAndHashCode;
66
import lombok.ToString;
@@ -20,11 +20,6 @@
2020
public class CustomClickEvent extends Event implements Cancellable
2121
{
2222

23-
/**
24-
* Map key containing the form action, if available.
25-
*/
26-
public static final String ACTION_KEY = "action";
27-
//
2823
/**
2924
* Player who clicked.
3025
*/
@@ -34,19 +29,9 @@ public class CustomClickEvent extends Event implements Cancellable
3429
*/
3530
private final String id;
3631
/**
37-
* The raw data as submitted.
38-
*/
39-
private final String rawData;
40-
/**
41-
* The parsed form data.
42-
* <br>
43-
* If a form submission, usually contains a
44-
* {@code CustomClickEvent.ACTION_KEY} key with the ID of the relevant
45-
* submission action.
46-
* <br>
47-
* If not a form submission, then may be null.
32+
* The data as submitted.
4833
*/
49-
private final Map<String, String> parsedData;
34+
private final JsonElement data;
5035
/**
5136
* Cancelled state.
5237
*/

api/src/main/java/net/md_5/bungee/api/plugin/LibraryLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
class LibraryLoader
3636
{
3737

38+
private static final String REPOSITORY_PROPERTY = "net.md_5.bungee.api.plugin.centralURL";
3839
private final Logger logger;
3940
private final RepositorySystem repository;
4041
private final DefaultRepositorySystemSession session;
@@ -68,7 +69,7 @@ public void transferStarted(TransferEvent event) throws TransferCancelledExcepti
6869
session.setSystemProperties( System.getProperties() );
6970
session.setReadOnly();
7071

71-
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) );
72+
this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", System.getProperty( REPOSITORY_PROPERTY, "https://repo.maven.apache.org/maven2" ) ).build() ) );
7273
}
7374

7475
public ClassLoader createLoader(PluginDescription desc)
Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
package net.md_5.bungee.util;
22

3-
import gnu.trove.strategy.HashingStrategy;
3+
import it.unimi.dsi.fastutil.Hash;
44
import java.util.Locale;
55

6-
class CaseInsensitiveHashingStrategy implements HashingStrategy
6+
class CaseInsensitiveHashingStrategy implements Hash.Strategy<String>
77
{
88

99
static final CaseInsensitiveHashingStrategy INSTANCE = new CaseInsensitiveHashingStrategy();
1010

1111
@Override
12-
public int computeHashCode(Object object)
12+
public int hashCode(String object)
1313
{
14-
return ( (String) object ).toLowerCase( Locale.ROOT ).hashCode();
14+
if ( object == null )
15+
{
16+
return 0;
17+
}
18+
19+
return object.toLowerCase( Locale.ROOT ).hashCode();
1520
}
1621

1722
@Override
18-
public boolean equals(Object o1, Object o2)
23+
public boolean equals(String o1, String o2)
1924
{
20-
return o1.equals( o2 ) || ( o1 instanceof String && o2 instanceof String && ( (String) o1 ).toLowerCase( Locale.ROOT ).equals( ( (String) o2 ).toLowerCase( Locale.ROOT ) ) );
25+
if ( o1 == o2 )
26+
{
27+
return true;
28+
}
29+
30+
if ( o1 == null || o2 == null )
31+
{
32+
return false;
33+
}
34+
35+
return o1.equals( o2 ) || o1.toLowerCase( Locale.ROOT ).equals( o2.toLowerCase( Locale.ROOT ) );
2136
}
2237
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package net.md_5.bungee.util;
22

3-
import gnu.trove.map.hash.TCustomHashMap;
3+
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap;
44
import java.util.Map;
55

6-
public class CaseInsensitiveMap<V> extends TCustomHashMap<String, V>
6+
public class CaseInsensitiveMap<V> extends Object2ObjectOpenCustomHashMap<String, V>
77
{
88

99
public CaseInsensitiveMap()
@@ -13,6 +13,6 @@ public CaseInsensitiveMap()
1313

1414
public CaseInsensitiveMap(Map<? extends String, ? extends V> map)
1515
{
16-
super( CaseInsensitiveHashingStrategy.INSTANCE, map );
16+
super( map, CaseInsensitiveHashingStrategy.INSTANCE );
1717
}
1818
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package net.md_5.bungee.util;
22

3-
import gnu.trove.set.hash.TCustomHashSet;
3+
import it.unimi.dsi.fastutil.objects.ObjectOpenCustomHashSet;
44
import java.util.Collection;
55

6-
public class CaseInsensitiveSet extends TCustomHashSet<String>
6+
public class CaseInsensitiveSet extends ObjectOpenCustomHashSet<String>
77
{
88

99
public CaseInsensitiveSet()
@@ -13,6 +13,6 @@ public CaseInsensitiveSet()
1313

1414
public CaseInsensitiveSet(Collection<? extends String> collection)
1515
{
16-
super( CaseInsensitiveHashingStrategy.INSTANCE, collection );
16+
super( collection, CaseInsensitiveHashingStrategy.INSTANCE );
1717
}
1818
}

api/src/test/java/net/md_5/bungee/util/CaseInsensitiveTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ public void testMaps()
1313
CaseInsensitiveMap<Object> map = new CaseInsensitiveMap<>();
1414

1515
map.put( "FOO", obj );
16-
assertTrue( map.contains( "foo" ) ); // Assert that contains is case insensitive
16+
assertTrue( map.containsKey( "foo" ) ); // Assert that contains is case insensitive
1717
assertTrue( map.entrySet().iterator().next().getKey().equals( "FOO" ) ); // Assert that case is preserved
1818

1919
// Assert that remove is case insensitive
2020
map.remove( "FoO" );
21-
assertFalse( map.contains( "foo" ) );
21+
assertFalse( map.containsKey( "foo" ) );
2222
}
2323

2424
@Test

bootstrap/pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>net.md-5</groupId>
88
<artifactId>bungeecord-parent</artifactId>
9-
<version>1.21-R0.3-SNAPSHOT</version>
9+
<version>1.21-R0.4-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

1313
<groupId>net.md-5</groupId>
1414
<artifactId>bungeecord-bootstrap</artifactId>
15-
<version>1.21-R0.3-SNAPSHOT</version>
15+
<version>1.21-R0.4-SNAPSHOT</version>
1616
<packaging>jar</packaging>
1717

1818
<name>BungeeCord-Bootstrap</name>
@@ -48,6 +48,7 @@
4848
<Main-Class>net.md_5.bungee.Bootstrap</Main-Class>
4949
<Implementation-Version>${describe}</Implementation-Version>
5050
<Specification-Version>${maven.build.timestamp}</Specification-Version>
51+
<Enable-Native-Access>ALL-UNNAMED</Enable-Native-Access>
5152
</manifestEntries>
5253
</archive>
5354
</configuration>

chat/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<parent>
77
<groupId>net.md-5</groupId>
88
<artifactId>bungeecord-parent</artifactId>
9-
<version>1.21-R0.3-SNAPSHOT</version>
9+
<version>1.21-R0.4-SNAPSHOT</version>
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

1313
<groupId>net.md-5</groupId>
1414
<artifactId>bungeecord-chat</artifactId>
15-
<version>1.21-R0.3-SNAPSHOT</version>
15+
<version>1.21-R0.4-SNAPSHOT</version>
1616
<packaging>jar</packaging>
1717

1818
<name>BungeeCord-Chat</name>

chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.ArrayList;
55
import java.util.List;
66
import lombok.AccessLevel;
7+
import lombok.Data;
78
import lombok.EqualsAndHashCode;
89
import lombok.Getter;
910
import lombok.Setter;
@@ -677,11 +678,11 @@ public boolean hasFormatting()
677678
public String toPlainText()
678679
{
679680
StringBuilder builder = new StringBuilder();
680-
toPlainText( builder );
681+
toPlainText( new LimitedStringVisitor( builder, Short.MAX_VALUE ) );
681682
return builder.toString();
682683
}
683684

684-
void toPlainText(StringBuilder builder)
685+
void toPlainText(StringVisitor builder)
685686
{
686687
if ( extra != null )
687688
{
@@ -701,11 +702,11 @@ void toPlainText(StringBuilder builder)
701702
public String toLegacyText()
702703
{
703704
StringBuilder builder = new StringBuilder();
704-
toLegacyText( builder );
705+
toLegacyText( new LimitedStringVisitor( builder, Short.MAX_VALUE ) );
705706
return builder.toString();
706707
}
707708

708-
void toLegacyText(StringBuilder builder)
709+
void toLegacyText(StringVisitor builder)
709710
{
710711
if ( extra != null )
711712
{
@@ -716,7 +717,7 @@ void toLegacyText(StringBuilder builder)
716717
}
717718
}
718719

719-
void addFormat(StringBuilder builder)
720+
void addFormat(StringVisitor builder)
720721
{
721722
builder.append( getColor() );
722723
if ( isBold() )
@@ -740,4 +741,35 @@ void addFormat(StringBuilder builder)
740741
builder.append( ChatColor.MAGIC );
741742
}
742743
}
744+
745+
@FunctionalInterface
746+
protected static interface StringVisitor
747+
{
748+
749+
void append(String s);
750+
751+
default void append(Object obj)
752+
{
753+
append( String.valueOf( obj ) );
754+
}
755+
}
756+
757+
@Data
758+
protected static class LimitedStringVisitor implements StringVisitor
759+
{
760+
761+
private final StringBuilder builder;
762+
private final int maxLength;
763+
764+
@Override
765+
public void append(String s)
766+
{
767+
if ( builder.length() >= maxLength )
768+
{
769+
throw new IllegalArgumentException( "String exceeded maximum length " + maxLength );
770+
}
771+
772+
builder.append( s );
773+
}
774+
}
743775
}

0 commit comments

Comments
 (0)