Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim203 committed Jan 30, 2025
2 parents 462739c + 9dd5fb6 commit a978607
Show file tree
Hide file tree
Showing 94 changed files with 1,542 additions and 329 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Binaries
--------
Precompiled binaries are available for end users on [Jenkins](https://www.spigotmc.org/go/bungeecord-dl).

(c) 2012-2024 SpigotMC Pty. Ltd.
(c) 2012-2025 SpigotMC Pty. Ltd.
4 changes: 2 additions & 2 deletions api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>net.md-5</groupId>
<artifactId>bungeecord-api</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BungeeCord-API</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,18 @@ public interface PendingConnection extends Connection
*/
@ApiStatus.Experimental
CompletableFuture<byte[]> retrieveCookie(String cookie);

/**
* Sends a login payload request to the client.
*
* @param channel the channel to send this data via
* @param data the data to send
* @return a {@link CompletableFuture} that will be completed when the Login
* Payload response is received. If the Vanilla client doesn't know the
* channel, the {@link CompletableFuture} will complete with a null value
* @throws IllegalStateException if the player's version is not at least
* 1.13
*/
@ApiStatus.Experimental
CompletableFuture<byte[]> sendData(String channel, byte[] data);
}
105 changes: 84 additions & 21 deletions api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import java.util.Map;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
Expand Down Expand Up @@ -59,6 +63,9 @@ public final class PluginManager
private final Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
private final Multimap<Plugin, Listener> listenersByPlugin = ArrayListMultimap.create();

private final ReadWriteLock commandsLock = new ReentrantReadWriteLock();
private final Lock listenersLock = new ReentrantLock();

@SuppressWarnings("unchecked")
public PluginManager(ProxyServer proxy)
{
Expand Down Expand Up @@ -93,12 +100,19 @@ public PluginManager(ProxyServer proxy)
*/
public void registerCommand(Plugin plugin, Command command)
{
commandMap.put( command.getName().toLowerCase( Locale.ROOT ), command );
for ( String alias : command.getAliases() )
commandsLock.writeLock().lock();
try
{
commandMap.put( command.getName().toLowerCase( Locale.ROOT ), command );
for ( String alias : command.getAliases() )
{
commandMap.put( alias.toLowerCase( Locale.ROOT ), command );
}
commandsByPlugin.put( plugin, command );
} finally
{
commandMap.put( alias.toLowerCase( Locale.ROOT ), command );
commandsLock.writeLock().unlock();
}
commandsByPlugin.put( plugin, command );
}

/**
Expand All @@ -108,8 +122,15 @@ public void registerCommand(Plugin plugin, Command command)
*/
public void unregisterCommand(Command command)
{
while ( commandMap.values().remove( command ) );
commandsByPlugin.values().remove( command );
commandsLock.writeLock().lock();
try
{
while ( commandMap.values().remove( command ) );
commandsByPlugin.values().remove( command );
} finally
{
commandsLock.writeLock().unlock();
}
}

/**
Expand All @@ -119,11 +140,18 @@ public void unregisterCommand(Command command)
*/
public void unregisterCommands(Plugin plugin)
{
for ( Iterator<Command> it = commandsByPlugin.get( plugin ).iterator(); it.hasNext(); )
commandsLock.writeLock().lock();
try
{
Command command = it.next();
while ( commandMap.values().remove( command ) );
it.remove();
for ( Iterator<Command> it = commandsByPlugin.get( plugin ).iterator(); it.hasNext(); )
{
Command command = it.next();
while ( commandMap.values().remove( command ) );
it.remove();
}
} finally
{
commandsLock.writeLock().unlock();
}
}

Expand All @@ -137,7 +165,14 @@ private Command getCommandIfEnabled(String commandName, CommandSender sender)
return null;
}

return commandMap.get( commandLower );
commandsLock.readLock().lock();
try
{
return commandMap.get( commandLower );
} finally
{
commandsLock.readLock().unlock();
}
}

/**
Expand Down Expand Up @@ -434,13 +469,20 @@ public <T extends Event> T callEvent(T event)
*/
public void registerListener(Plugin plugin, Listener listener)
{
for ( Method method : listener.getClass().getDeclaredMethods() )
listenersLock.lock();
try
{
Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ),
for ( Method method : listener.getClass().getDeclaredMethods() )
{
Preconditions.checkArgument( !method.isAnnotationPresent( Subscribe.class ),
"Listener %s has registered using deprecated subscribe annotation! Please update to @EventHandler.", listener );
}
eventBus.register( listener );
listenersByPlugin.put( plugin, listener );
} finally
{
listenersLock.unlock();
}
eventBus.register( listener );
listenersByPlugin.put( plugin, listener );
}

/**
Expand All @@ -450,8 +492,15 @@ public void registerListener(Plugin plugin, Listener listener)
*/
public void unregisterListener(Listener listener)
{
eventBus.unregister( listener );
listenersByPlugin.values().remove( listener );
listenersLock.lock();
try
{
eventBus.unregister( listener );
listenersByPlugin.values().remove( listener );
} finally
{
listenersLock.unlock();
}
}

/**
Expand All @@ -461,10 +510,17 @@ public void unregisterListener(Listener listener)
*/
public void unregisterListeners(Plugin plugin)
{
for ( Iterator<Listener> it = listenersByPlugin.get( plugin ).iterator(); it.hasNext(); )
listenersLock.lock();
try
{
for ( Iterator<Listener> it = listenersByPlugin.get( plugin ).iterator(); it.hasNext(); )
{
eventBus.unregister( it.next() );
it.remove();
}
} finally
{
eventBus.unregister( it.next() );
it.remove();
listenersLock.unlock();
}
}

Expand All @@ -475,7 +531,14 @@ public void unregisterListeners(Plugin plugin)
*/
public Collection<Map.Entry<String, Command>> getCommands()
{
return Collections.unmodifiableCollection( commandMap.entrySet() );
commandsLock.readLock().lock();
try
{
return Collections.unmodifiableCollection( commandMap.entrySet() );
} finally
{
commandsLock.readLock().unlock();
}
}

boolean isTransitiveDepend(PluginDescription plugin, PluginDescription depend)
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>net.md-5</groupId>
<artifactId>bungeecord-bootstrap</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BungeeCord-Bootstrap</name>
Expand Down
6 changes: 3 additions & 3 deletions chat/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-parent</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.20-R0.3-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BungeeCord-Chat</name>
Expand All @@ -27,7 +27,7 @@
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<version>2.11.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
50 changes: 50 additions & 0 deletions chat/src/main/java/net/md_5/bungee/api/chat/BaseComponent.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.md_5.bungee.api.chat;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
Expand Down Expand Up @@ -129,6 +130,10 @@ public void copyFormatting(BaseComponent component, FormatRetention retention, b
{
setColor( component.getColorRaw() );
}
if ( replace || !style.hasShadowColor() )
{
setShadowColor( component.getShadowColorRaw() );
}
if ( replace || !style.hasFont() )
{
setFont( component.getFontRaw() );
Expand Down Expand Up @@ -175,6 +180,7 @@ public void retain(FormatRetention retention)
if ( retention == FormatRetention.EVENTS || retention == FormatRetention.NONE )
{
setColor( null );
setShadowColor( null );
setBold( null );
setItalic( null );
setUnderlined( null );
Expand Down Expand Up @@ -295,6 +301,46 @@ public ChatColor getColorRaw()
return style.getColor();
}

/**
* Set this component's shadow color.
*
* @param color the component shadow color, or null to use the default
*/
public void setShadowColor(Color color)
{
this.style.setShadowColor( color );
}

/**
* Returns the shadow color of this component. This uses the parent's shadow color if this
* component doesn't have one. null is returned if no shadow color is found.
*
* @return the shadow color of this component
*/
public Color getShadowColor()
{
if ( !style.hasShadowColor() )
{
if ( parent == null )
{
return null;
}
return parent.getShadowColor();
}
return style.getShadowColor();
}

/**
* Returns the shadow color of this component without checking the parents
* shadow color. May return null
*
* @return the shadow color of this component
*/
public Color getShadowColorRaw()
{
return style.getShadowColor();
}

/**
* Set this component's font.
*
Expand Down Expand Up @@ -536,6 +582,10 @@ public void applyStyle(ComponentStyle style)
{
setColor( style.getColor() );
}
if ( style.hasShadowColor() )
{
setShadowColor( style.getShadowColor() );
}
if ( style.hasFont() )
{
setFont( style.getFont() );
Expand Down
9 changes: 9 additions & 0 deletions chat/src/main/java/net/md_5/bungee/api/chat/ClickEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.jetbrains.annotations.ApiStatus;

@Getter
@ToString
Expand All @@ -23,6 +25,13 @@ public final class ClickEvent
*/
private final String value;

/**
* Returns whether this click event is used for version above 1.21.4
*/
@Setter
@ApiStatus.Internal
private boolean v1_21_5 = false;

public enum Action
{

Expand Down
Loading

0 comments on commit a978607

Please sign in to comment.