mirror of
https://git.zelz.net/catfoolyou/Project164.git
synced 2025-12-16 20:27:41 +00:00
Bungee added
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public abstract class AbstractReconnectHandler implements ReconnectHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public ServerInfo getServer(ProxiedPlayer player)
|
||||
{
|
||||
ServerInfo server = getForcedHost( player.getPendingConnection() );
|
||||
if ( server == null )
|
||||
{
|
||||
server = getStoredServer( player );
|
||||
if ( server == null )
|
||||
{
|
||||
server = ProxyServer.getInstance().getServerInfo( player.getPendingConnection().getListener().getDefaultServer() );
|
||||
}
|
||||
|
||||
Preconditions.checkState( server != null, "Default server not defined" );
|
||||
}
|
||||
|
||||
return server;
|
||||
}
|
||||
|
||||
public static ServerInfo getForcedHost(PendingConnection con)
|
||||
{
|
||||
if ( con.getVirtualHost() == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String forced = con.getListener().getForcedHosts().get( con.getVirtualHost().getHostString() );
|
||||
|
||||
if ( forced == null && con.getListener().isForceDefault() )
|
||||
{
|
||||
forced = con.getListener().getDefaultServer();
|
||||
}
|
||||
return ProxyServer.getInstance().getServerInfo( forced );
|
||||
}
|
||||
|
||||
protected abstract ServerInfo getStoredServer(ProxiedPlayer player);
|
||||
}
|
||||
19
eaglerbungee/src/main/java/net/md_5/bungee/api/Callback.java
Normal file
19
eaglerbungee/src/main/java/net/md_5/bungee/api/Callback.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
/**
|
||||
* Represents a method which may be called once a result has been computed
|
||||
* asynchronously.
|
||||
*
|
||||
* @param <V> the type of result
|
||||
*/
|
||||
public interface Callback<V>
|
||||
{
|
||||
|
||||
/**
|
||||
* Called when the result is done.
|
||||
*
|
||||
* @param result the result of the computation
|
||||
* @param error the error(s) that occurred, if any
|
||||
*/
|
||||
public void done(V result, Throwable error);
|
||||
}
|
||||
186
eaglerbungee/src/main/java/net/md_5/bungee/api/ChatColor.java
Normal file
186
eaglerbungee/src/main/java/net/md_5/bungee/api/ChatColor.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Simplistic enumeration of all supported color values for chat.
|
||||
*/
|
||||
public enum ChatColor
|
||||
{
|
||||
|
||||
/**
|
||||
* Represents black.
|
||||
*/
|
||||
BLACK( '0' ),
|
||||
/**
|
||||
* Represents dark blue.
|
||||
*/
|
||||
DARK_BLUE( '1' ),
|
||||
/**
|
||||
* Represents dark green.
|
||||
*/
|
||||
DARK_GREEN( '2' ),
|
||||
/**
|
||||
* Represents dark blue (aqua).
|
||||
*/
|
||||
DARK_AQUA( '3' ),
|
||||
/**
|
||||
* Represents dark red.
|
||||
*/
|
||||
DARK_RED( '4' ),
|
||||
/**
|
||||
* Represents dark purple.
|
||||
*/
|
||||
DARK_PURPLE( '5' ),
|
||||
/**
|
||||
* Represents gold.
|
||||
*/
|
||||
GOLD( '6' ),
|
||||
/**
|
||||
* Represents gray.
|
||||
*/
|
||||
GRAY( '7' ),
|
||||
/**
|
||||
* Represents dark gray.
|
||||
*/
|
||||
DARK_GRAY( '8' ),
|
||||
/**
|
||||
* Represents blue.
|
||||
*/
|
||||
BLUE( '9' ),
|
||||
/**
|
||||
* Represents green.
|
||||
*/
|
||||
GREEN( 'a' ),
|
||||
/**
|
||||
* Represents aqua.
|
||||
*/
|
||||
AQUA( 'b' ),
|
||||
/**
|
||||
* Represents red.
|
||||
*/
|
||||
RED( 'c' ),
|
||||
/**
|
||||
* Represents light purple.
|
||||
*/
|
||||
LIGHT_PURPLE( 'd' ),
|
||||
/**
|
||||
* Represents yellow.
|
||||
*/
|
||||
YELLOW( 'e' ),
|
||||
/**
|
||||
* Represents white.
|
||||
*/
|
||||
WHITE( 'f' ),
|
||||
/**
|
||||
* Represents magical characters that change around randomly.
|
||||
*/
|
||||
MAGIC( 'k' ),
|
||||
/**
|
||||
* Makes the text bold.
|
||||
*/
|
||||
BOLD( 'l' ),
|
||||
/**
|
||||
* Makes a line appear through the text.
|
||||
*/
|
||||
STRIKETHROUGH( 'm' ),
|
||||
/**
|
||||
* Makes the text appear underlined.
|
||||
*/
|
||||
UNDERLINE( 'n' ),
|
||||
/**
|
||||
* Makes the text italic.
|
||||
*/
|
||||
ITALIC( 'o' ),
|
||||
/**
|
||||
* Resets all previous chat colors or formats.
|
||||
*/
|
||||
RESET( 'r' );
|
||||
/**
|
||||
* The special character which prefixes all chat colour codes. Use this if
|
||||
* you need to dynamically convert colour codes from your custom format.
|
||||
*/
|
||||
public static final char COLOR_CHAR = '\u00A7';
|
||||
/**
|
||||
* Pattern to remove all colour codes.
|
||||
*/
|
||||
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile( "(?i)" + String.valueOf( COLOR_CHAR ) + "[0-9A-FK-OR]" );
|
||||
/**
|
||||
* Colour instances keyed by their active character.
|
||||
*/
|
||||
private static final Map<Character, ChatColor> BY_CHAR = new HashMap<>();
|
||||
/**
|
||||
* The code appended to {@link #COLOR_CHAR} to make usable colour.
|
||||
*/
|
||||
private final char code;
|
||||
/**
|
||||
* This colour's colour char prefixed by the {@link #COLOR_CHAR}.
|
||||
*/
|
||||
private final String toString;
|
||||
|
||||
static
|
||||
{
|
||||
for ( ChatColor colour : values() )
|
||||
{
|
||||
BY_CHAR.put( colour.code, colour );
|
||||
}
|
||||
}
|
||||
|
||||
private ChatColor(char code)
|
||||
{
|
||||
this.code = code;
|
||||
this.toString = new String( new char[]
|
||||
{
|
||||
COLOR_CHAR, code
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return toString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips the given message of all color codes
|
||||
*
|
||||
* @param input String to strip of color
|
||||
* @return A copy of the input string, without any coloring
|
||||
*/
|
||||
public static String stripColor(final String input)
|
||||
{
|
||||
if ( input == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return STRIP_COLOR_PATTERN.matcher( input ).replaceAll( "" );
|
||||
}
|
||||
|
||||
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate)
|
||||
{
|
||||
char[] b = textToTranslate.toCharArray();
|
||||
for ( int i = 0; i < b.length - 1; i++ )
|
||||
{
|
||||
if ( b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf( b[i + 1] ) > -1 )
|
||||
{
|
||||
b[i] = ChatColor.COLOR_CHAR;
|
||||
b[i + 1] = Character.toLowerCase( b[i + 1] );
|
||||
}
|
||||
}
|
||||
return new String( b );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the colour represented by the specified code.
|
||||
*
|
||||
* @param code the code to search for
|
||||
* @return the mapped colour, or null if non exists
|
||||
*/
|
||||
public static ChatColor getByChar(char code)
|
||||
{
|
||||
return BY_CHAR.get( code );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommandSender
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the unique name of this command sender.
|
||||
*
|
||||
* @return the senders username
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Send a message to this sender.
|
||||
*
|
||||
* @param message the message to send
|
||||
*/
|
||||
public void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* Send several messages to this sender. Each message will be sent
|
||||
* separately.
|
||||
*
|
||||
* @param messages the messages to send
|
||||
*/
|
||||
public void sendMessages(String... messages);
|
||||
|
||||
/**
|
||||
* Get all groups this user is part of. This returns an unmodifiable
|
||||
* collection.
|
||||
*
|
||||
* @return the users groups
|
||||
*/
|
||||
public Collection<String> getGroups();
|
||||
|
||||
/**
|
||||
* Adds groups to a this user for the current session only.
|
||||
*
|
||||
* @param groups the groups to add
|
||||
*/
|
||||
public void addGroups(String... groups);
|
||||
|
||||
/**
|
||||
* Remove groups from this user for the current session only.
|
||||
*
|
||||
* @param groups the groups to remove
|
||||
*/
|
||||
public void removeGroups(String... groups);
|
||||
|
||||
/**
|
||||
* Checks if this user has the specified permission node.
|
||||
*
|
||||
* @param permission the node to check
|
||||
* @return whether they have this node
|
||||
*/
|
||||
public boolean hasPermission(String permission);
|
||||
|
||||
/**
|
||||
* Set a permission node for this user.
|
||||
*
|
||||
* @param permission the node to set
|
||||
* @param value the value of the node
|
||||
*/
|
||||
public void setPermission(String permission, boolean value);
|
||||
|
||||
Map<String, Object> getAttachment();
|
||||
}
|
||||
25
eaglerbungee/src/main/java/net/md_5/bungee/api/MOTD.java
Normal file
25
eaglerbungee/src/main/java/net/md_5/bungee/api/MOTD.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MOTD extends QueryConnection {
|
||||
|
||||
public void sendToUser();
|
||||
|
||||
public String getLine1();
|
||||
public String getLine2();
|
||||
public List<String> getPlayerList();
|
||||
public int[] getBitmap();
|
||||
public int getOnlinePlayers();
|
||||
public int getMaxPlayers();
|
||||
public String getSubType();
|
||||
|
||||
public void setLine1(String p);
|
||||
public void setLine2(String p);
|
||||
public void setPlayerList(List<String> p);
|
||||
public void setPlayerList(String... p);
|
||||
public void setBitmap(int[] p);
|
||||
public void setOnlinePlayers(int i);
|
||||
public void setMaxPlayers(int i);
|
||||
|
||||
}
|
||||
251
eaglerbungee/src/main/java/net/md_5/bungee/api/ProxyServer.java
Normal file
251
eaglerbungee/src/main/java/net/md_5/bungee/api/ProxyServer.java
Normal file
@@ -0,0 +1,251 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import net.md_5.bungee.api.plugin.PluginManager;
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.api.scheduler.TaskScheduler;
|
||||
import net.md_5.bungee.api.tab.CustomTabList;
|
||||
|
||||
public abstract class ProxyServer
|
||||
{
|
||||
|
||||
private static ProxyServer instance;
|
||||
|
||||
public static ProxyServer getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the proxy instance. This method may only be called once per an
|
||||
* application.
|
||||
*
|
||||
* @param instance the new instance to set
|
||||
*/
|
||||
public static void setInstance(ProxyServer instance)
|
||||
{
|
||||
Preconditions.checkNotNull( instance, "instance" );
|
||||
Preconditions.checkArgument( ProxyServer.instance == null, "Instance already set" );
|
||||
ProxyServer.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the currently running proxy software.
|
||||
*
|
||||
* @return the name of this instance
|
||||
*/
|
||||
public abstract String getName();
|
||||
|
||||
/**
|
||||
* Gets the version of the currently running proxy software.
|
||||
*
|
||||
* @return the version of this instance
|
||||
*/
|
||||
public abstract String getVersion();
|
||||
|
||||
/**
|
||||
* Gets a localized string from the .properties file.
|
||||
*
|
||||
* @return the localized string
|
||||
*/
|
||||
public abstract String getTranslation(String name, Object... args);
|
||||
|
||||
/**
|
||||
* Gets the main logger which can be used as a suitable replacement for
|
||||
* {@link System#out} and {@link System#err}.
|
||||
*
|
||||
* @return the {@link Logger} instance
|
||||
*/
|
||||
public abstract Logger getLogger();
|
||||
|
||||
/**
|
||||
* Return all players currently connected.
|
||||
*
|
||||
* @return all connected players
|
||||
*/
|
||||
public abstract Collection<ProxiedPlayer> getPlayers();
|
||||
|
||||
/**
|
||||
* Gets a connected player via their unique username.
|
||||
*
|
||||
* @param name of the player
|
||||
* @return their player instance
|
||||
*/
|
||||
public abstract ProxiedPlayer getPlayer(String name);
|
||||
|
||||
/**
|
||||
* Return all servers registered to this proxy, keyed by name. Unlike the
|
||||
* methods in {@link ConfigurationAdapter#getServers()}, this will not
|
||||
* return a fresh map each time.
|
||||
*
|
||||
* @return all registered remote server destinations
|
||||
*/
|
||||
public abstract Map<String, ServerInfo> getServers();
|
||||
|
||||
/**
|
||||
* Gets the server info of a server.
|
||||
*
|
||||
* @param name the name of the configured server
|
||||
* @return the server info belonging to the specified server
|
||||
*/
|
||||
public abstract ServerInfo getServerInfo(String name);
|
||||
|
||||
/**
|
||||
* Get the {@link PluginManager} associated with loading plugins and
|
||||
* dispatching events. It is recommended that implementations use the
|
||||
* provided PluginManager class.
|
||||
*
|
||||
* @return the plugin manager
|
||||
*/
|
||||
public abstract PluginManager getPluginManager();
|
||||
|
||||
/**
|
||||
* Returns the currently in use configuration adapter.
|
||||
*
|
||||
* @return the used configuration adapter
|
||||
*/
|
||||
public abstract ConfigurationAdapter getConfigurationAdapter();
|
||||
|
||||
/**
|
||||
* Set the configuration adapter to be used. Must be called from
|
||||
* {@link Plugin#onLoad()}.
|
||||
*
|
||||
* @param adapter the adapter to use
|
||||
*/
|
||||
public abstract void setConfigurationAdapter(ConfigurationAdapter adapter);
|
||||
|
||||
/**
|
||||
* Get the currently in use reconnect handler.
|
||||
*
|
||||
* @return the in use reconnect handler
|
||||
*/
|
||||
public abstract ReconnectHandler getReconnectHandler();
|
||||
|
||||
/**
|
||||
* Sets the reconnect handler to be used for subsequent connections.
|
||||
*
|
||||
* @param handler the new handler
|
||||
*/
|
||||
public abstract void setReconnectHandler(ReconnectHandler handler);
|
||||
|
||||
/**
|
||||
* Gracefully mark this instance for shutdown.
|
||||
*/
|
||||
public abstract void stop();
|
||||
|
||||
/**
|
||||
* Start this instance so that it may accept connections.
|
||||
*
|
||||
* @throws Exception any exception thrown during startup causing the
|
||||
* instance to fail to boot
|
||||
*/
|
||||
public abstract void start() throws Exception;
|
||||
|
||||
/**
|
||||
* Register a channel for use with plugin messages. This is required by some
|
||||
* server / client implementations.
|
||||
*
|
||||
* @param channel the channel to register
|
||||
*/
|
||||
public abstract void registerChannel(String channel);
|
||||
|
||||
/**
|
||||
* Unregister a previously registered channel.
|
||||
*
|
||||
* @param channel the channel to unregister
|
||||
*/
|
||||
public abstract void unregisterChannel(String channel);
|
||||
|
||||
/**
|
||||
* Get an immutable set of all registered plugin channels.
|
||||
*
|
||||
* @return registered plugin channels
|
||||
*/
|
||||
public abstract Collection<String> getChannels();
|
||||
|
||||
/**
|
||||
* Get the Minecraft version supported by this proxy.
|
||||
*
|
||||
* @return the supported Minecraft version
|
||||
*/
|
||||
public abstract String getGameVersion();
|
||||
|
||||
/**
|
||||
* Get the Minecraft protocol version supported by this proxy.
|
||||
*
|
||||
* @return the Minecraft protocol version
|
||||
*/
|
||||
public abstract byte getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Factory method to construct an implementation specific server info
|
||||
* instance.
|
||||
*
|
||||
* @param name name of the server
|
||||
* @param address connectable Minecraft address + port of the server
|
||||
* @param restricted whether the server info restricted property will be set
|
||||
* @return the constructed instance
|
||||
*/
|
||||
public abstract ServerInfo constructServerInfo(String name, InetSocketAddress address, boolean restricted);
|
||||
|
||||
/**
|
||||
* Returns the console overlord for this proxy. Being the console, this
|
||||
* command server cannot have permissions or groups, and will be able to
|
||||
* execute anything.
|
||||
*
|
||||
* @return the console command sender of this proxy
|
||||
*/
|
||||
public abstract CommandSender getConsole();
|
||||
|
||||
/**
|
||||
* Return the folder used to load plugins from.
|
||||
*
|
||||
* @return the folder used to load plugin
|
||||
*/
|
||||
public abstract File getPluginsFolder();
|
||||
|
||||
/**
|
||||
* Get the scheduler instance for this proxy.
|
||||
*
|
||||
* @return the in use scheduler
|
||||
*/
|
||||
public abstract TaskScheduler getScheduler();
|
||||
|
||||
/**
|
||||
* Get the current number of connected users. The default implementation is
|
||||
* more efficient than {@link #getPlayers()} as it does not take a lock or
|
||||
* make a copy.
|
||||
*
|
||||
* @return the current number of connected players
|
||||
*/
|
||||
public abstract int getOnlineCount();
|
||||
|
||||
/**
|
||||
* Send the specified message to the console and all connected players.
|
||||
*
|
||||
* @param message the message to broadcast
|
||||
*/
|
||||
public abstract void broadcast(String message);
|
||||
|
||||
/**
|
||||
* Gets a new instance of this proxies custom tab list.
|
||||
*
|
||||
* @param player the player to generate this list in the context of
|
||||
* @return a new {@link CustomTabList} instance
|
||||
*/
|
||||
public abstract CustomTabList customTabList(ProxiedPlayer player);
|
||||
|
||||
/**
|
||||
* Gets the commands which are disabled and will not be run on this proxy.
|
||||
*
|
||||
* @return the set of disabled commands
|
||||
*/
|
||||
public abstract Collection<String> getDisabledCommands();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import net.md_5.bungee.BungeeCord;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.eaglercraft.EaglercraftBungee;
|
||||
|
||||
public interface QueryConnection {
|
||||
|
||||
public InetAddress getRemoteAddress();
|
||||
public ListenerInfo getListener();
|
||||
|
||||
public String getAccept();
|
||||
public void setReturnType(String type);
|
||||
public String getReturnType();
|
||||
|
||||
public int availableRequests();
|
||||
|
||||
public default JSONObject readRequestData() {
|
||||
String s = readRequestString();
|
||||
return s == null ? null : new JSONObject(s);
|
||||
}
|
||||
|
||||
public String readRequestString();
|
||||
public long getConnectionTimestamp();
|
||||
|
||||
public default long getConnectionAge() {
|
||||
return System.currentTimeMillis() - getConnectionTimestamp();
|
||||
}
|
||||
|
||||
public default void writeResponse(JSONObject msg) {
|
||||
JSONObject toSend = new JSONObject();
|
||||
toSend.put("type", getReturnType());
|
||||
toSend.put("name", BungeeCord.getInstance().config.getServerName());
|
||||
toSend.put("brand", EaglercraftBungee.brand);
|
||||
toSend.put("vers", EaglercraftBungee.version);
|
||||
toSend.put("cracked", EaglercraftBungee.cracked);
|
||||
toSend.put("secure", false);
|
||||
toSend.put("time", System.currentTimeMillis());
|
||||
toSend.put("uuid", BungeeCord.getInstance().config.getUuid());
|
||||
toSend.put("data", msg);
|
||||
writeResponseRaw(toSend.toString());
|
||||
}
|
||||
|
||||
public default void writeResponse(String msg) {
|
||||
JSONObject toSend = new JSONObject();
|
||||
toSend.put("type", getReturnType());
|
||||
toSend.put("name", BungeeCord.getInstance().config.getServerName());
|
||||
toSend.put("brand", EaglercraftBungee.brand);
|
||||
toSend.put("vers", EaglercraftBungee.version);
|
||||
toSend.put("cracked", EaglercraftBungee.cracked);
|
||||
toSend.put("secure", false);
|
||||
toSend.put("time", System.currentTimeMillis());
|
||||
toSend.put("uuid", BungeeCord.getInstance().config.getUuid());
|
||||
toSend.put("data", msg);
|
||||
writeResponseRaw(toSend.toString());
|
||||
}
|
||||
|
||||
public void writeResponseRaw(String msg);
|
||||
public void writeResponseBinary(byte[] blob);
|
||||
|
||||
public void keepAlive(boolean yes);
|
||||
public boolean shouldKeepAlive();
|
||||
public boolean isClosed();
|
||||
public void close();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public interface ReconnectHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets the initial server name for a connecting player.
|
||||
*
|
||||
* @param player the connecting player
|
||||
* @return the server to connect to
|
||||
*/
|
||||
ServerInfo getServer(ProxiedPlayer player);
|
||||
|
||||
/**
|
||||
* Save the server of this player before they disconnect so it can be
|
||||
* retrieved later.
|
||||
*
|
||||
* @param player the player to save
|
||||
*/
|
||||
void setServer(ProxiedPlayer player); // TOOD: String + String arguments?
|
||||
|
||||
/**
|
||||
* Save all pending reconnect locations. Whilst not used for database
|
||||
* connections, this method will be called at a predefined interval to allow
|
||||
* the saving of reconnect files.
|
||||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Close all connections indicating that the proxy is about to shutdown and
|
||||
* all data should be saved. No new requests will be made after this method
|
||||
* has been called.
|
||||
*
|
||||
*/
|
||||
void close();
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public class ServerIcon {
|
||||
|
||||
public static int[] createServerIcon(BufferedImage awtIcon) {
|
||||
BufferedImage icon = awtIcon;
|
||||
boolean gotScaled = false;
|
||||
if(icon.getWidth() != 64 || icon.getHeight() != 64) {
|
||||
icon = new BufferedImage(64, 64, awtIcon.getType());
|
||||
Graphics2D g = (Graphics2D) icon.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, (awtIcon.getWidth() < 64 || awtIcon.getHeight() < 64) ?
|
||||
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR : RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
g.setBackground(new Color(0, true));
|
||||
g.clearRect(0, 0, 64, 64);
|
||||
int ow = awtIcon.getWidth();
|
||||
int oh = awtIcon.getHeight();
|
||||
int nw, nh;
|
||||
float aspectRatio = (float)oh / (float)ow;
|
||||
if(aspectRatio >= 1.0f) {
|
||||
nw = (int)(64 / aspectRatio);
|
||||
nh = 64;
|
||||
}else {
|
||||
nw = 64;
|
||||
nh = (int)(64 * aspectRatio);
|
||||
}
|
||||
g.drawImage(awtIcon, (64 - nw) / 2, (64 - nh) / 2, (64 - nw) / 2 + nw, (64 - nh) / 2 + nh, 0, 0, awtIcon.getWidth(), awtIcon.getHeight(), null);
|
||||
g.dispose();
|
||||
gotScaled = true;
|
||||
}
|
||||
int[] pxls = icon.getRGB(0, 0, 64, 64, new int[4096], 0, 64);
|
||||
if(gotScaled) {
|
||||
for(int i = 0; i < pxls.length; ++i) {
|
||||
if((pxls[i] & 0xFFFFFF) == 0) {
|
||||
pxls[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return pxls;
|
||||
}
|
||||
|
||||
public static int[] createServerIcon(InputStream f) {
|
||||
try {
|
||||
return createServerIcon(ImageIO.read(f));
|
||||
}catch(Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] createServerIcon(File f) {
|
||||
try {
|
||||
return createServerIcon(ImageIO.read(f));
|
||||
}catch(Throwable t) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
107
eaglerbungee/src/main/java/net/md_5/bungee/api/ServerPing.java
Normal file
107
eaglerbungee/src/main/java/net/md_5/bungee/api/ServerPing.java
Normal file
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
public class ServerPing {
|
||||
private final byte protocolVersion;
|
||||
private final String gameVersion;
|
||||
private final String motd;
|
||||
private final int currentPlayers;
|
||||
private final int maxPlayers;
|
||||
|
||||
@ConstructorProperties({ "protocolVersion", "gameVersion", "motd", "currentPlayers", "maxPlayers" })
|
||||
public ServerPing(final byte protocolVersion, final String gameVersion, final String motd, final int currentPlayers, final int maxPlayers) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
this.gameVersion = gameVersion;
|
||||
this.motd = motd;
|
||||
this.currentPlayers = currentPlayers;
|
||||
this.maxPlayers = maxPlayers;
|
||||
}
|
||||
|
||||
public byte getProtocolVersion() {
|
||||
return this.protocolVersion;
|
||||
}
|
||||
|
||||
public String getGameVersion() {
|
||||
return this.gameVersion;
|
||||
}
|
||||
|
||||
public String getMotd() {
|
||||
return this.motd;
|
||||
}
|
||||
|
||||
public int getCurrentPlayers() {
|
||||
return this.currentPlayers;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return this.maxPlayers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerPing)) {
|
||||
return false;
|
||||
}
|
||||
final ServerPing other = (ServerPing) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (this.getProtocolVersion() != other.getProtocolVersion()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$gameVersion = this.getGameVersion();
|
||||
final Object other$gameVersion = other.getGameVersion();
|
||||
Label_0078: {
|
||||
if (this$gameVersion == null) {
|
||||
if (other$gameVersion == null) {
|
||||
break Label_0078;
|
||||
}
|
||||
} else if (this$gameVersion.equals(other$gameVersion)) {
|
||||
break Label_0078;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$motd = this.getMotd();
|
||||
final Object other$motd = other.getMotd();
|
||||
if (this$motd == null) {
|
||||
if (other$motd == null) {
|
||||
return this.getCurrentPlayers() == other.getCurrentPlayers() && this.getMaxPlayers() == other.getMaxPlayers();
|
||||
}
|
||||
} else if (this$motd.equals(other$motd)) {
|
||||
return this.getCurrentPlayers() == other.getCurrentPlayers() && this.getMaxPlayers() == other.getMaxPlayers();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ServerPing;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + this.getProtocolVersion();
|
||||
final Object $gameVersion = this.getGameVersion();
|
||||
result = result * 31 + (($gameVersion == null) ? 0 : $gameVersion.hashCode());
|
||||
final Object $motd = this.getMotd();
|
||||
result = result * 31 + (($motd == null) ? 0 : $motd.hashCode());
|
||||
result = result * 31 + this.getCurrentPlayers();
|
||||
result = result * 31 + this.getMaxPlayers();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerPing(protocolVersion=" + this.getProtocolVersion() + ", gameVersion=" + this.getGameVersion() + ", motd=" + this.getMotd() + ", currentPlayers=" + this.getCurrentPlayers() + ", maxPlayers=" + this.getMaxPlayers()
|
||||
+ ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AuthServiceInfo {
|
||||
|
||||
private final boolean enabled;
|
||||
private final boolean registerEnabled;
|
||||
private final String authfile;
|
||||
private final int ipLimit;
|
||||
private final List<String> joinMessages;
|
||||
private final int loginTimeout;
|
||||
|
||||
public AuthServiceInfo(boolean enabled, boolean registerEnabled, String authfile,
|
||||
int timeout, List<String> joinMessages, int loginTimeout) {
|
||||
this.enabled = enabled;
|
||||
this.registerEnabled = registerEnabled;
|
||||
this.authfile = authfile;
|
||||
this.ipLimit = timeout;
|
||||
this.joinMessages = joinMessages;
|
||||
this.loginTimeout = loginTimeout;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public boolean isRegisterEnabled() {
|
||||
return registerEnabled;
|
||||
}
|
||||
|
||||
public String getAuthfile() {
|
||||
return authfile;
|
||||
}
|
||||
|
||||
public int getIpLimit() {
|
||||
return ipLimit;
|
||||
}
|
||||
|
||||
public List<String> getJoinMessages() {
|
||||
return joinMessages;
|
||||
}
|
||||
|
||||
public int getLoginTimeout() {
|
||||
return loginTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ConfigurationAdapter {
|
||||
void load();
|
||||
|
||||
int getInt(final String p0, final int p1);
|
||||
|
||||
String getString(final String p0, final String p1);
|
||||
|
||||
boolean getBoolean(final String p0, final boolean p1);
|
||||
|
||||
Map<String, ServerInfo> getServers();
|
||||
|
||||
Collection<ListenerInfo> getListeners();
|
||||
|
||||
Collection<String> getGroups(final String p0);
|
||||
|
||||
Collection<String> getPermissions(final String p0);
|
||||
|
||||
Collection<String> getBlacklistURLs();
|
||||
|
||||
Collection<String> getBlacklistSimpleWhitelist();
|
||||
|
||||
Collection<String> getDisabledCommands();
|
||||
|
||||
Collection<String> getICEServers();
|
||||
|
||||
AuthServiceInfo getAuthSettings();
|
||||
|
||||
Map<String, Object> getMap();
|
||||
|
||||
void forceSave();
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Map;
|
||||
|
||||
import net.md_5.bungee.api.ServerIcon;
|
||||
import net.md_5.bungee.api.tab.TabListHandler;
|
||||
import net.md_5.bungee.eaglercraft.WebSocketRateLimiter;
|
||||
|
||||
public class ListenerInfo {
|
||||
private final String hostString;
|
||||
private final InetSocketAddress host;
|
||||
private final InetSocketAddress javaHost;
|
||||
private final String motd;
|
||||
private final int maxPlayers;
|
||||
private final int tabListSize;
|
||||
private final String defaultServer;
|
||||
private final String fallbackServer;
|
||||
private final boolean forceDefault;
|
||||
private final boolean websocket;
|
||||
private final boolean forwardIp;
|
||||
private final String forwardIpHeader;
|
||||
private final Map<String, String> forcedHosts;
|
||||
private final TexturePackInfo texturePack;
|
||||
private final Class<? extends TabListHandler> tabList;
|
||||
private final String serverIcon;
|
||||
private final int[] serverIconCache;
|
||||
private boolean serverIconLoaded;
|
||||
private boolean serverIconSet;
|
||||
private final boolean allowMOTD;
|
||||
private final boolean allowQuery;
|
||||
private final MOTDCacheConfiguration cacheConfig;
|
||||
private final WebSocketRateLimiter rateLimitIP;
|
||||
private final WebSocketRateLimiter rateLimitLogin;
|
||||
private final WebSocketRateLimiter rateLimitMOTD;
|
||||
private final WebSocketRateLimiter rateLimitQuery;
|
||||
|
||||
|
||||
public ListenerInfo(final String hostString, final InetSocketAddress host, final InetSocketAddress javaHost,
|
||||
final String forwardIpHeader, final String motd, final int maxPlayers, final int tabListSize,
|
||||
final String defaultServer, final String fallbackServer, final boolean forceDefault,
|
||||
final boolean websocket, final boolean forwardIp, final Map<String, String> forcedHosts,
|
||||
final TexturePackInfo texturePack, final Class<? extends TabListHandler> tabList, final String serverIcon,
|
||||
final MOTDCacheConfiguration cacheConfig, final boolean allowMOTD, final boolean allowQuery,
|
||||
final WebSocketRateLimiter rateLimitIP, final WebSocketRateLimiter rateLimitLogin,
|
||||
final WebSocketRateLimiter rateLimitMOTD, final WebSocketRateLimiter rateLimitQuery) {
|
||||
this.hostString = hostString;
|
||||
this.host = host;
|
||||
this.javaHost = javaHost;
|
||||
this.motd = motd;
|
||||
this.maxPlayers = maxPlayers;
|
||||
this.tabListSize = tabListSize;
|
||||
this.defaultServer = defaultServer;
|
||||
this.fallbackServer = fallbackServer;
|
||||
this.forceDefault = forceDefault;
|
||||
this.websocket = websocket;
|
||||
this.forwardIp = forwardIp;
|
||||
this.forwardIpHeader = forwardIpHeader;
|
||||
this.forcedHosts = forcedHosts;
|
||||
this.texturePack = texturePack;
|
||||
this.tabList = tabList;
|
||||
this.serverIcon = serverIcon;
|
||||
this.serverIconCache = new int[4096];
|
||||
this.serverIconLoaded = false;
|
||||
this.serverIconSet = false;
|
||||
this.allowMOTD = allowMOTD;
|
||||
this.allowQuery = allowQuery;
|
||||
this.cacheConfig = cacheConfig;
|
||||
this.rateLimitIP = rateLimitIP;
|
||||
this.rateLimitLogin = rateLimitLogin;
|
||||
this.rateLimitMOTD = rateLimitMOTD;
|
||||
this.rateLimitQuery = rateLimitQuery;
|
||||
}
|
||||
|
||||
public String getHostString() {
|
||||
return this.hostString;
|
||||
}
|
||||
|
||||
public InetSocketAddress getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public InetSocketAddress getJavaHost() {
|
||||
return this.javaHost;
|
||||
}
|
||||
|
||||
public String getMotd() {
|
||||
return this.motd;
|
||||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return this.maxPlayers;
|
||||
}
|
||||
|
||||
public int getTabListSize() {
|
||||
return this.tabListSize;
|
||||
}
|
||||
|
||||
public String getDefaultServer() {
|
||||
return this.defaultServer;
|
||||
}
|
||||
|
||||
public String getFallbackServer() {
|
||||
return this.fallbackServer;
|
||||
}
|
||||
|
||||
public boolean isForceDefault() {
|
||||
return this.forceDefault;
|
||||
}
|
||||
|
||||
public Map<String, String> getForcedHosts() {
|
||||
return this.forcedHosts;
|
||||
}
|
||||
|
||||
public TexturePackInfo getTexturePack() {
|
||||
return this.texturePack;
|
||||
}
|
||||
|
||||
public Class<? extends TabListHandler> getTabList() {
|
||||
return this.tabList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ListenerInfo)) {
|
||||
return false;
|
||||
}
|
||||
final ListenerInfo other = (ListenerInfo) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$host = this.getHost();
|
||||
final Object other$host = other.getHost();
|
||||
Label_0065: {
|
||||
if (this$host == null) {
|
||||
if (other$host == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$host.equals(other$host)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$motd = this.getMotd();
|
||||
final Object other$motd = other.getMotd();
|
||||
Label_0102: {
|
||||
if (this$motd == null) {
|
||||
if (other$motd == null) {
|
||||
break Label_0102;
|
||||
}
|
||||
} else if (this$motd.equals(other$motd)) {
|
||||
break Label_0102;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this.getMaxPlayers() != other.getMaxPlayers()) {
|
||||
return false;
|
||||
}
|
||||
if (this.getTabListSize() != other.getTabListSize()) {
|
||||
return false;
|
||||
}
|
||||
if (this.isWebsocket() != other.isWebsocket()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$defaultServer = this.getDefaultServer();
|
||||
final Object other$defaultServer = other.getDefaultServer();
|
||||
Label_0165: {
|
||||
if (this$defaultServer == null) {
|
||||
if (other$defaultServer == null) {
|
||||
break Label_0165;
|
||||
}
|
||||
} else if (this$defaultServer.equals(other$defaultServer)) {
|
||||
break Label_0165;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$fallbackServer = this.getFallbackServer();
|
||||
final Object other$fallbackServer = other.getFallbackServer();
|
||||
Label_0202: {
|
||||
if (this$fallbackServer == null) {
|
||||
if (other$fallbackServer == null) {
|
||||
break Label_0202;
|
||||
}
|
||||
} else if (this$fallbackServer.equals(other$fallbackServer)) {
|
||||
break Label_0202;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this.isForceDefault() != other.isForceDefault()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$forcedHosts = this.getForcedHosts();
|
||||
final Object other$forcedHosts = other.getForcedHosts();
|
||||
Label_0252: {
|
||||
if (this$forcedHosts == null) {
|
||||
if (other$forcedHosts == null) {
|
||||
break Label_0252;
|
||||
}
|
||||
} else if (this$forcedHosts.equals(other$forcedHosts)) {
|
||||
break Label_0252;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$texturePack = this.getTexturePack();
|
||||
final Object other$texturePack = other.getTexturePack();
|
||||
Label_0289: {
|
||||
if (this$texturePack == null) {
|
||||
if (other$texturePack == null) {
|
||||
break Label_0289;
|
||||
}
|
||||
} else if (this$texturePack.equals(other$texturePack)) {
|
||||
break Label_0289;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$tabList = this.getTabList();
|
||||
final Object other$tabList = other.getTabList();
|
||||
if (this$tabList == null) {
|
||||
if (other$tabList == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$tabList.equals(other$tabList)) {
|
||||
return true;
|
||||
}
|
||||
final Object this$getServerIcon = this.getServerIcon();
|
||||
final Object other$getServerIcon = other.getServerIcon();
|
||||
if (this$getServerIcon == null) {
|
||||
if (other$getServerIcon == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$getServerIcon.equals(other$getServerIcon)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ListenerInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $host = this.getHost();
|
||||
result = result * 31 + (($host == null) ? 0 : $host.hashCode());
|
||||
final Object $motd = this.getMotd();
|
||||
result = result * 31 + (($motd == null) ? 0 : $motd.hashCode());
|
||||
result = result * 31 + this.getMaxPlayers();
|
||||
result = result * 31 + this.getTabListSize();
|
||||
final Object $defaultServer = this.getDefaultServer();
|
||||
result = result * 31 + (($defaultServer == null) ? 0 : $defaultServer.hashCode());
|
||||
final Object $fallbackServer = this.getFallbackServer();
|
||||
result = result * 31 + (($fallbackServer == null) ? 0 : $fallbackServer.hashCode());
|
||||
result = result * 31 + (this.isForceDefault() ? 1231 : 1237);
|
||||
final Object $forcedHosts = this.getForcedHosts();
|
||||
result = result * 31 + (($forcedHosts == null) ? 0 : $forcedHosts.hashCode());
|
||||
final Object $texturePack = this.getTexturePack();
|
||||
result = result * 31 + (($texturePack == null) ? 0 : $texturePack.hashCode());
|
||||
final Object $tabList = this.getTabList();
|
||||
result = result * 31 + (($tabList == null) ? 0 : $tabList.hashCode());
|
||||
final Object $serverIconCache = this.getTabList();
|
||||
result = result * 31 + (($serverIconCache == null) ? 0 : $serverIconCache.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ListenerInfo(host=" + this.getHost() + ", motd=" + this.getMotd() + ", maxPlayers=" + this.getMaxPlayers() + ", tabListSize=" + this.getTabListSize() + ", defaultServer=" + this.getDefaultServer() + ", fallbackServer="
|
||||
+ this.getFallbackServer() + ", forceDefault=" + this.isForceDefault() + ", websocket=" + this.isWebsocket() + ", forcedHosts=" + this.getForcedHosts() + ", texturePack=" + this.getTexturePack() + ", tabList=" + this.getTabList() + ")";
|
||||
}
|
||||
|
||||
public boolean isWebsocket() {
|
||||
return websocket;
|
||||
}
|
||||
|
||||
public boolean hasForwardedHeaders() {
|
||||
return forwardIp;
|
||||
}
|
||||
|
||||
public String getForwardedIPHeader() {
|
||||
return forwardIpHeader;
|
||||
}
|
||||
|
||||
public String getServerIcon() {
|
||||
return serverIcon;
|
||||
}
|
||||
|
||||
public int[] getServerIconCache() {
|
||||
if(!serverIconLoaded) {
|
||||
if(serverIcon != null) {
|
||||
int[] img = ServerIcon.createServerIcon(new File(serverIcon));
|
||||
if(img != null) {
|
||||
System.arraycopy(img, 0, serverIconCache, 0, img.length);
|
||||
serverIconSet = true;
|
||||
}else {
|
||||
serverIconSet = false;
|
||||
}
|
||||
}else {
|
||||
serverIconSet = false;
|
||||
}
|
||||
serverIconLoaded = true;
|
||||
}
|
||||
return serverIconCache;
|
||||
}
|
||||
|
||||
public boolean isIconSet() {
|
||||
getServerIconCache();
|
||||
return serverIconSet;
|
||||
}
|
||||
|
||||
public boolean isForwardIp() {
|
||||
return forwardIp;
|
||||
}
|
||||
|
||||
public boolean isServerIconLoaded() {
|
||||
return serverIconLoaded;
|
||||
}
|
||||
|
||||
public boolean isServerIconSet() {
|
||||
return serverIconSet;
|
||||
}
|
||||
|
||||
public boolean isAllowMOTD() {
|
||||
return allowMOTD;
|
||||
}
|
||||
|
||||
public boolean isAllowQuery() {
|
||||
return allowQuery;
|
||||
}
|
||||
|
||||
public MOTDCacheConfiguration getCacheConfig() {
|
||||
return cacheConfig;
|
||||
}
|
||||
|
||||
public WebSocketRateLimiter getRateLimitIP() {
|
||||
return rateLimitIP;
|
||||
}
|
||||
|
||||
public WebSocketRateLimiter getRateLimitLogin() {
|
||||
return rateLimitLogin;
|
||||
}
|
||||
|
||||
public WebSocketRateLimiter getRateLimitMOTD() {
|
||||
return rateLimitMOTD;
|
||||
}
|
||||
|
||||
public WebSocketRateLimiter getRateLimitQuery() {
|
||||
return rateLimitQuery;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
public class MOTDCacheConfiguration {
|
||||
|
||||
public final int cacheTTL;
|
||||
public final boolean cacheServerListAnimation;
|
||||
public final boolean cacheServerListResults;
|
||||
public final boolean cacheServerListTrending;
|
||||
public final boolean cacheServerListPortfolios;
|
||||
|
||||
public MOTDCacheConfiguration(int cacheTTL, boolean cacheServerListAnimation, boolean cacheServerListResults,
|
||||
boolean cacheServerListTrending, boolean cacheServerListPortfolios) {
|
||||
this.cacheTTL = cacheTTL;
|
||||
this.cacheServerListAnimation = cacheServerListAnimation;
|
||||
this.cacheServerListResults = cacheServerListResults;
|
||||
this.cacheServerListTrending = cacheServerListTrending;
|
||||
this.cacheServerListPortfolios = cacheServerListPortfolios;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collection;
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
* Class used to represent a server to connect to.
|
||||
*/
|
||||
public interface ServerInfo
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the name of this server.
|
||||
*
|
||||
* @return the configured name for this server address
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Gets the connectable host + port pair for this server. Implementations
|
||||
* expect this to be used as the unique identifier per each instance of this
|
||||
* class.
|
||||
*
|
||||
* @return the IP and port pair for this server
|
||||
*/
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
/**
|
||||
* Get the set of all players on this server.
|
||||
*
|
||||
* @return an unmodifiable collection of all players on this server
|
||||
*/
|
||||
Collection<ProxiedPlayer> getPlayers();
|
||||
|
||||
/**
|
||||
* Returns the MOTD which should be used when this server is a forced host.
|
||||
*
|
||||
* @return the motd
|
||||
*/
|
||||
|
||||
/**
|
||||
* Whether the player can access this server. It will only return false when
|
||||
* the player has no permission and this server is restricted.
|
||||
*
|
||||
* @param sender the player to check access for
|
||||
* @return whether access is granted to this server
|
||||
*/
|
||||
boolean canAccess(CommandSender sender);
|
||||
|
||||
/**
|
||||
* Send data by any available means to this server.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
void sendData(String channel, byte[] data);
|
||||
|
||||
/**
|
||||
* Asynchronously gets the current player count on this server.
|
||||
*
|
||||
* @param callback the callback to call when the count has been retrieved.
|
||||
*/
|
||||
void ping(Callback<ServerPing> callback);
|
||||
|
||||
String getRedirect();
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.config;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
public class TexturePackInfo {
|
||||
private final String url;
|
||||
private final int size;
|
||||
|
||||
@ConstructorProperties({ "url", "size" })
|
||||
public TexturePackInfo(final String url, final int size) {
|
||||
this.url = url;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof TexturePackInfo)) {
|
||||
return false;
|
||||
}
|
||||
final TexturePackInfo other = (TexturePackInfo) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$url = this.getUrl();
|
||||
final Object other$url = other.getUrl();
|
||||
if (this$url == null) {
|
||||
if (other$url == null) {
|
||||
return this.getSize() == other.getSize();
|
||||
}
|
||||
} else if (this$url.equals(other$url)) {
|
||||
return this.getSize() == other.getSize();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof TexturePackInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $url = this.getUrl();
|
||||
result = result * 31 + (($url == null) ? 0 : $url.hashCode());
|
||||
result = result * 31 + this.getSize();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TexturePackInfo(url=" + this.getUrl() + ", size=" + this.getSize() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
/**
|
||||
* Represents a player physically connected to the world hosted on this server.
|
||||
*/
|
||||
public interface ConnectedPlayer extends ProxiedPlayer
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import net.md_5.bungee.protocol.packet.DefinedPacket;
|
||||
|
||||
/**
|
||||
* A proxy connection is defined as a connection directly connected to a socket.
|
||||
* It should expose information about the remote peer, however not be specific
|
||||
* to a type of connection, whether server or player.
|
||||
*/
|
||||
public interface Connection
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets the remote address of this connection.
|
||||
*
|
||||
* @return the remote address
|
||||
*/
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
/**
|
||||
* Disconnects this end of the connection for the specified reason. If this
|
||||
* is an {@link ProxiedPlayer} the respective server connection will be
|
||||
* closed too.
|
||||
*
|
||||
* @param reason the reason shown to the player / sent to the server on
|
||||
* disconnect
|
||||
*/
|
||||
void disconnect(String reason);
|
||||
|
||||
/**
|
||||
* Get the unsafe methods of this class.
|
||||
*
|
||||
* @return the unsafe method interface
|
||||
*/
|
||||
Unsafe unsafe();
|
||||
|
||||
interface Unsafe
|
||||
{
|
||||
|
||||
/**
|
||||
* Send a packet to this connection.
|
||||
*
|
||||
* @param packet the packet to send
|
||||
*/
|
||||
void sendPacket(DefinedPacket packet);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
|
||||
/**
|
||||
* Represents a user attempting to log into the proxy.
|
||||
*/
|
||||
public interface PendingConnection extends Connection
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the requested username.
|
||||
*
|
||||
* @return the requested username, or null if not set
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the numerical client version of the player attempting to log in.
|
||||
*
|
||||
* @return the protocol version of the remote client
|
||||
*/
|
||||
byte getVersion();
|
||||
|
||||
/**
|
||||
* Get the requested virtual host that the client tried to connect to.
|
||||
*
|
||||
* @return request virtual host or null if invalid / not specified.
|
||||
*/
|
||||
InetSocketAddress getVirtualHost();
|
||||
|
||||
/**
|
||||
* Get the listener that accepted this connection.
|
||||
*
|
||||
* @return the accepting listener
|
||||
*/
|
||||
ListenerInfo getListener();
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.tab.TabListHandler;
|
||||
|
||||
/**
|
||||
* Represents a player who's connection is being connected to somewhere else,
|
||||
* whether it be a remote or embedded server.
|
||||
*/
|
||||
public interface ProxiedPlayer extends Connection, CommandSender
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets this player's display name.
|
||||
*
|
||||
* @return the players current display name
|
||||
*/
|
||||
String getDisplayName();
|
||||
|
||||
/**
|
||||
* Sets this players display name to be used as their nametag and tab list
|
||||
* name.
|
||||
*
|
||||
* @param name the name to set
|
||||
*/
|
||||
void setDisplayName(String name);
|
||||
|
||||
/**
|
||||
* Connects / transfers this user to the specified connection, gracefully
|
||||
* closing the current one. Depending on the implementation, this method
|
||||
* might return before the user has been connected.
|
||||
*
|
||||
* @param target the new server to connect to
|
||||
*/
|
||||
void connect(ServerInfo target);
|
||||
|
||||
/**
|
||||
* Gets the server this player is connected to.
|
||||
*
|
||||
* @return the server this player is connected to
|
||||
*/
|
||||
Server getServer();
|
||||
|
||||
/**
|
||||
* Gets the ping time between the proxy and this connection.
|
||||
*
|
||||
* @return the current ping time
|
||||
*/
|
||||
int getPing();
|
||||
|
||||
/**
|
||||
* Send a plugin message to this player.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
void sendData(String channel, byte[] data);
|
||||
|
||||
/**
|
||||
* Get the pending connection that belongs to this player.
|
||||
*
|
||||
* @return the pending connection that this player used
|
||||
*/
|
||||
PendingConnection getPendingConnection();
|
||||
|
||||
/**
|
||||
* Make this player chat (say something), to the server he is currently on.
|
||||
*
|
||||
* @param message the message to say
|
||||
*/
|
||||
void chat(String message);
|
||||
|
||||
/**
|
||||
* Sets the new tab list for the user. At this stage it is not advisable to
|
||||
* change after the user has logged in!
|
||||
*
|
||||
* @param list the new list
|
||||
*/
|
||||
void setTabList(TabListHandler list);
|
||||
|
||||
/**
|
||||
* Get the current tab list.
|
||||
*
|
||||
* @return the tab list in use by this user
|
||||
*/
|
||||
TabListHandler getTabList();
|
||||
|
||||
/**
|
||||
* Get the server which this player will be sent to next time the log in.
|
||||
*
|
||||
* @return the server, or null if default
|
||||
*/
|
||||
ServerInfo getReconnectServer();
|
||||
|
||||
/**
|
||||
* Set the server which this player will be sent to next time the log in.
|
||||
*
|
||||
* @param server the server to set
|
||||
*/
|
||||
void setReconnectServer(ServerInfo server);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.md_5.bungee.api.connection;
|
||||
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
|
||||
/**
|
||||
* Represents a destination which this proxy might connect to.
|
||||
*/
|
||||
public interface Server extends Connection
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the basic information about this server.
|
||||
*
|
||||
* @return the {@link ServerInfo} for this server
|
||||
*/
|
||||
public ServerInfo getInfo();
|
||||
|
||||
/**
|
||||
* Send data by any available means to this server.
|
||||
*
|
||||
* @param channel the channel to send this data via
|
||||
* @param data the data to send
|
||||
*/
|
||||
public abstract void sendData(String channel, byte[] data);
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
public class AsyncEvent<T> extends Event {
|
||||
private final Callback<T> done;
|
||||
private final Set<Plugin> intents;
|
||||
private final AtomicBoolean fired;
|
||||
private final AtomicInteger latch;
|
||||
|
||||
@Override
|
||||
public void postCall() {
|
||||
this.fired.set(true);
|
||||
if (this.latch.get() == 0) {
|
||||
this.done.done((T) this, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void registerIntent(final Plugin plugin) {
|
||||
Preconditions.checkState(!this.fired.get(), "Event %s has already been fired", new Object[] { this });
|
||||
Preconditions.checkState(!this.intents.contains(plugin), "Plugin %s already registered intent for event %s", new Object[] { plugin, this });
|
||||
this.intents.add(plugin);
|
||||
this.latch.incrementAndGet();
|
||||
}
|
||||
|
||||
public void completeIntent(final Plugin plugin) {
|
||||
Preconditions.checkState(this.intents.contains(plugin), "Plugin %s has not registered intent for event %s", new Object[] { plugin, this });
|
||||
this.intents.remove(plugin);
|
||||
if (this.latch.decrementAndGet() == 0 && this.fired.get()) {
|
||||
this.done.done((T) this, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ConstructorProperties({ "done" })
|
||||
public AsyncEvent(final Callback<T> done) {
|
||||
this.intents = Collections.newSetFromMap(new ConcurrentHashMap<Plugin, Boolean>());
|
||||
this.fired = new AtomicBoolean();
|
||||
this.latch = new AtomicInteger();
|
||||
this.done = done;
|
||||
}
|
||||
|
||||
public Callback<T> getDone() {
|
||||
return this.done;
|
||||
}
|
||||
|
||||
public Set<Plugin> getIntents() {
|
||||
return this.intents;
|
||||
}
|
||||
|
||||
public AtomicBoolean getFired() {
|
||||
return this.fired;
|
||||
}
|
||||
|
||||
public AtomicInteger getLatch() {
|
||||
return this.latch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AsyncEvent(super=" + super.toString() + ", done=" + this.getDone() + ", intents=" + this.getIntents() + ", fired=" + this.getFired() + ", latch=" + this.getLatch() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof AsyncEvent)) {
|
||||
return false;
|
||||
}
|
||||
final AsyncEvent<?> other = (AsyncEvent<?>) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$done = this.getDone();
|
||||
final Object other$done = other.getDone();
|
||||
Label_0075: {
|
||||
if (this$done == null) {
|
||||
if (other$done == null) {
|
||||
break Label_0075;
|
||||
}
|
||||
} else if (this$done.equals(other$done)) {
|
||||
break Label_0075;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$intents = this.getIntents();
|
||||
final Object other$intents = other.getIntents();
|
||||
Label_0112: {
|
||||
if (this$intents == null) {
|
||||
if (other$intents == null) {
|
||||
break Label_0112;
|
||||
}
|
||||
} else if (this$intents.equals(other$intents)) {
|
||||
break Label_0112;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$fired = this.getFired();
|
||||
final Object other$fired = other.getFired();
|
||||
Label_0149: {
|
||||
if (this$fired == null) {
|
||||
if (other$fired == null) {
|
||||
break Label_0149;
|
||||
}
|
||||
} else if (this$fired.equals(other$fired)) {
|
||||
break Label_0149;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$latch = this.getLatch();
|
||||
final Object other$latch = other.getLatch();
|
||||
if (this$latch == null) {
|
||||
if (other$latch == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$latch.equals(other$latch)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof AsyncEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + super.hashCode();
|
||||
final Object $done = this.getDone();
|
||||
result = result * 31 + (($done == null) ? 0 : $done.hashCode());
|
||||
final Object $intents = this.getIntents();
|
||||
result = result * 31 + (($intents == null) ? 0 : $intents.hashCode());
|
||||
final Object $fired = this.getFired();
|
||||
result = result * 31 + (($fired == null) ? 0 : $fired.hashCode());
|
||||
final Object $latch = this.getLatch();
|
||||
result = result * 31 + (($latch == null) ? 0 : $latch.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
public class ChatEvent extends TargetedEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private String message;
|
||||
|
||||
public ChatEvent(final Connection sender, final Connection receiver, final String message) {
|
||||
super(sender, receiver);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public boolean isCommand() {
|
||||
return this.message.length() > 0 && this.message.charAt(0) == '/';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public void setMessage(final String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ChatEvent(super=" + super.toString() + ", cancelled=" + this.isCancelled() + ", message=" + this.getMessage() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ChatEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ChatEvent other = (ChatEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isCancelled() != other.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$message = this.getMessage();
|
||||
final Object other$message = other.getMessage();
|
||||
if (this$message == null) {
|
||||
if (other$message == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$message.equals(other$message)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ChatEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + super.hashCode();
|
||||
result = result * 31 + (this.isCancelled() ? 1231 : 1237);
|
||||
final Object $message = this.getMessage();
|
||||
result = result * 31 + (($message == null) ? 0 : $message.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.Callback;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
public class LoginEvent extends AsyncEvent<LoginEvent> implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private String cancelReason;
|
||||
private final PendingConnection connection;
|
||||
|
||||
public LoginEvent(final PendingConnection connection, final Callback<LoginEvent> done) {
|
||||
super(done);
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public String getCancelReason() {
|
||||
return this.cancelReason;
|
||||
}
|
||||
|
||||
public PendingConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public void setCancelReason(final String cancelReason) {
|
||||
this.cancelReason = cancelReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "LoginEvent(cancelled=" + this.isCancelled() + ", cancelReason=" + this.getCancelReason() + ", connection=" + this.getConnection() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof LoginEvent)) {
|
||||
return false;
|
||||
}
|
||||
final LoginEvent other = (LoginEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isCancelled() != other.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$cancelReason = this.getCancelReason();
|
||||
final Object other$cancelReason = other.getCancelReason();
|
||||
Label_0078: {
|
||||
if (this$cancelReason == null) {
|
||||
if (other$cancelReason == null) {
|
||||
break Label_0078;
|
||||
}
|
||||
} else if (this$cancelReason.equals(other$cancelReason)) {
|
||||
break Label_0078;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$connection = this.getConnection();
|
||||
final Object other$connection = other.getConnection();
|
||||
if (this$connection == null) {
|
||||
if (other$connection == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$connection.equals(other$connection)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof LoginEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + (this.isCancelled() ? 1231 : 1237);
|
||||
final Object $cancelReason = this.getCancelReason();
|
||||
result = result * 31 + (($cancelReason == null) ? 0 : $cancelReason.hashCode());
|
||||
final Object $connection = this.getConnection();
|
||||
result = result * 31 + (($connection == null) ? 0 : $connection.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class PermissionCheckEvent extends Event {
|
||||
private final CommandSender sender;
|
||||
private final String permission;
|
||||
private boolean hasPermission;
|
||||
|
||||
public boolean hasPermission() {
|
||||
return this.hasPermission;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public void setHasPermission(final boolean hasPermission) {
|
||||
this.hasPermission = hasPermission;
|
||||
}
|
||||
|
||||
@ConstructorProperties({ "sender", "permission", "hasPermission" })
|
||||
public PermissionCheckEvent(final CommandSender sender, final String permission, final boolean hasPermission) {
|
||||
this.sender = sender;
|
||||
this.permission = permission;
|
||||
this.hasPermission = hasPermission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PermissionCheckEvent(sender=" + this.getSender() + ", permission=" + this.getPermission() + ", hasPermission=" + this.hasPermission + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PermissionCheckEvent)) {
|
||||
return false;
|
||||
}
|
||||
final PermissionCheckEvent other = (PermissionCheckEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$sender = this.getSender();
|
||||
final Object other$sender = other.getSender();
|
||||
Label_0065: {
|
||||
if (this$sender == null) {
|
||||
if (other$sender == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$sender.equals(other$sender)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$permission = this.getPermission();
|
||||
final Object other$permission = other.getPermission();
|
||||
if (this$permission == null) {
|
||||
if (other$permission == null) {
|
||||
return this.hasPermission == other.hasPermission;
|
||||
}
|
||||
} else if (this$permission.equals(other$permission)) {
|
||||
return this.hasPermission == other.hasPermission;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof PermissionCheckEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $sender = this.getSender();
|
||||
result = result * 31 + (($sender == null) ? 0 : $sender.hashCode());
|
||||
final Object $permission = this.getPermission();
|
||||
result = result * 31 + (($permission == null) ? 0 : $permission.hashCode());
|
||||
result = result * 31 + (this.hasPermission ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class PlayerDisconnectEvent extends Event {
|
||||
private final ProxiedPlayer player;
|
||||
|
||||
@ConstructorProperties({ "player" })
|
||||
public PlayerDisconnectEvent(final ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PlayerDisconnectEvent(player=" + this.getPlayer() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PlayerDisconnectEvent)) {
|
||||
return false;
|
||||
}
|
||||
final PlayerDisconnectEvent other = (PlayerDisconnectEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof PlayerDisconnectEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.protocol.packet.Packet2Handshake;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
/**
|
||||
* Event called to represent a player first making their presence and username
|
||||
* known.
|
||||
*/
|
||||
public class PlayerHandshakeEvent extends Event
|
||||
{
|
||||
|
||||
/**
|
||||
* Connection attempting to login.
|
||||
*/
|
||||
private final PendingConnection connection;
|
||||
/**
|
||||
* The handshake.
|
||||
*/
|
||||
private final Packet2Handshake handshake;
|
||||
|
||||
public PlayerHandshakeEvent(PendingConnection connection, Packet2Handshake handshake)
|
||||
{
|
||||
this.connection = connection;
|
||||
this.handshake = handshake;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
|
||||
public class PluginMessageEvent extends TargetedEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private final String tag;
|
||||
private final byte[] data;
|
||||
|
||||
public PluginMessageEvent(final Connection sender, final Connection receiver, final String tag, final byte[] data) {
|
||||
super(sender, receiver);
|
||||
this.tag = tag;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PluginMessageEvent(super=" + super.toString() + ", cancelled=" + this.isCancelled() + ", tag=" + this.getTag() + ", data=" + Arrays.toString(this.getData()) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PluginMessageEvent)) {
|
||||
return false;
|
||||
}
|
||||
final PluginMessageEvent other = (PluginMessageEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (!super.equals(o)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isCancelled() != other.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$tag = this.getTag();
|
||||
final Object other$tag = other.getTag();
|
||||
if (this$tag == null) {
|
||||
if (other$tag == null) {
|
||||
return Arrays.equals(this.getData(), other.getData());
|
||||
}
|
||||
} else if (this$tag.equals(other$tag)) {
|
||||
return Arrays.equals(this.getData(), other.getData());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//@Override
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof PluginMessageEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + super.hashCode();
|
||||
result = result * 31 + (this.isCancelled() ? 1231 : 1237);
|
||||
final Object $tag = this.getTag();
|
||||
result = result * 31 + (($tag == null) ? 0 : $tag.hashCode());
|
||||
result = result * 31 + Arrays.hashCode(this.getData());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class PostLoginEvent extends Event {
|
||||
private final ProxiedPlayer player;
|
||||
|
||||
@ConstructorProperties({ "player" })
|
||||
public PostLoginEvent(final ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PostLoginEvent(player=" + this.getPlayer() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof PostLoginEvent)) {
|
||||
return false;
|
||||
}
|
||||
final PostLoginEvent other = (PostLoginEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof PostLoginEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.ServerPing;
|
||||
import net.md_5.bungee.api.connection.PendingConnection;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class ProxyPingEvent extends Event {
|
||||
private final PendingConnection connection;
|
||||
private ServerPing response;
|
||||
|
||||
public PendingConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
public ServerPing getResponse() {
|
||||
return this.response;
|
||||
}
|
||||
|
||||
public void setResponse(final ServerPing response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@ConstructorProperties({ "connection", "response" })
|
||||
public ProxyPingEvent(final PendingConnection connection, final ServerPing response) {
|
||||
this.connection = connection;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ProxyPingEvent(connection=" + this.getConnection() + ", response=" + this.getResponse() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ProxyPingEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ProxyPingEvent other = (ProxyPingEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$connection = this.getConnection();
|
||||
final Object other$connection = other.getConnection();
|
||||
Label_0065: {
|
||||
if (this$connection == null) {
|
||||
if (other$connection == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$connection.equals(other$connection)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$response = this.getResponse();
|
||||
final Object other$response = other.getResponse();
|
||||
if (this$response == null) {
|
||||
if (other$response == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$response.equals(other$response)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ProxyPingEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $connection = this.getConnection();
|
||||
result = result * 31 + (($connection == null) ? 0 : $connection.hashCode());
|
||||
final Object $response = this.getResponse();
|
||||
result = result * 31 + (($response == null) ? 0 : $response.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class ServerConnectEvent extends Event implements Cancellable {
|
||||
private final ProxiedPlayer player;
|
||||
private ServerInfo target;
|
||||
private boolean cancelled;
|
||||
|
||||
public ServerConnectEvent(final ProxiedPlayer player, final ServerInfo target) {
|
||||
this.player = player;
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public ServerInfo getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setTarget(final ServerInfo target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerConnectEvent(player=" + this.getPlayer() + ", target=" + this.getTarget() + ", cancelled=" + this.isCancelled() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerConnectEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ServerConnectEvent other = (ServerConnectEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
Label_0065: {
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$target = this.getTarget();
|
||||
final Object other$target = other.getTarget();
|
||||
if (this$target == null) {
|
||||
if (other$target == null) {
|
||||
return this.isCancelled() == other.isCancelled();
|
||||
}
|
||||
} else if (this$target.equals(other$target)) {
|
||||
return this.isCancelled() == other.isCancelled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ServerConnectEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
final Object $target = this.getTarget();
|
||||
result = result * 31 + (($target == null) ? 0 : $target.hashCode());
|
||||
result = result * 31 + (this.isCancelled() ? 1231 : 1237);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class ServerConnectedEvent extends Event {
|
||||
private final ProxiedPlayer player;
|
||||
private final Server server;
|
||||
|
||||
@ConstructorProperties({ "player", "server" })
|
||||
public ServerConnectedEvent(final ProxiedPlayer player, final Server server) {
|
||||
this.player = player;
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return this.server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerConnectedEvent(player=" + this.getPlayer() + ", server=" + this.getServer() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerConnectedEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ServerConnectedEvent other = (ServerConnectedEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
Label_0065: {
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$server = this.getServer();
|
||||
final Object other$server = other.getServer();
|
||||
if (this$server == null) {
|
||||
if (other$server == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$server.equals(other$server)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ServerConnectedEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
final Object $server = this.getServer();
|
||||
result = result * 31 + (($server == null) ? 0 : $server.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Cancellable;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
/**
|
||||
* Represents a player getting kicked from a server.
|
||||
*/
|
||||
|
||||
public class ServerKickEvent extends Event implements Cancellable
|
||||
{
|
||||
|
||||
private boolean cancelled;
|
||||
private final ProxiedPlayer player;
|
||||
private String kickReason;
|
||||
private ServerInfo cancelServer;
|
||||
private State state;
|
||||
|
||||
public enum State
|
||||
{
|
||||
|
||||
CONNECTING, CONNECTED, UNKNOWN;
|
||||
}
|
||||
|
||||
public ServerKickEvent(ProxiedPlayer player, String kickReason, ServerInfo cancelServer)
|
||||
{
|
||||
this( player, kickReason, cancelServer, State.UNKNOWN );
|
||||
}
|
||||
|
||||
public ServerKickEvent(ProxiedPlayer player, String kickReason, ServerInfo cancelServer, State state)
|
||||
{
|
||||
this.player = player;
|
||||
this.kickReason = kickReason;
|
||||
this.cancelServer = cancelServer;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getKickReason() {
|
||||
return this.kickReason;
|
||||
}
|
||||
|
||||
public ServerInfo getCancelServer() {
|
||||
return this.cancelServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(final boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public void setKickReason(final String kickReason) {
|
||||
this.kickReason = kickReason;
|
||||
}
|
||||
|
||||
public void setCancelServer(final ServerInfo cancelServer) {
|
||||
this.cancelServer = cancelServer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerKickEvent(cancelled=" + this.isCancelled() + ", player=" + this.getPlayer() + ", kickReason=" + this.getKickReason() + ", cancelServer=" + this.getCancelServer() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerKickEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ServerKickEvent other = (ServerKickEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
if (this.isCancelled() != other.isCancelled()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
Label_0078: {
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
break Label_0078;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
break Label_0078;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$kickReason = this.getKickReason();
|
||||
final Object other$kickReason = other.getKickReason();
|
||||
Label_0115: {
|
||||
if (this$kickReason == null) {
|
||||
if (other$kickReason == null) {
|
||||
break Label_0115;
|
||||
}
|
||||
} else if (this$kickReason.equals(other$kickReason)) {
|
||||
break Label_0115;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$cancelServer = this.getCancelServer();
|
||||
final Object other$cancelServer = other.getCancelServer();
|
||||
if (this$cancelServer == null) {
|
||||
if (other$cancelServer == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$cancelServer.equals(other$cancelServer)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ServerKickEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
result = result * 31 + (this.isCancelled() ? 1231 : 1237);
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
final Object $kickReason = this.getKickReason();
|
||||
result = result * 31 + (($kickReason == null) ? 0 : $kickReason.hashCode());
|
||||
final Object $cancelServer = this.getCancelServer();
|
||||
result = result * 31 + (($cancelServer == null) ? 0 : $cancelServer.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class ServerSwitchEvent extends Event {
|
||||
private final ProxiedPlayer player;
|
||||
|
||||
@ConstructorProperties({ "player" })
|
||||
public ServerSwitchEvent(final ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerSwitchEvent(player=" + this.getPlayer() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof ServerSwitchEvent)) {
|
||||
return false;
|
||||
}
|
||||
final ServerSwitchEvent other = (ServerSwitchEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$player = this.getPlayer();
|
||||
final Object other$player = other.getPlayer();
|
||||
if (this$player == null) {
|
||||
if (other$player == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$player.equals(other$player)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof ServerSwitchEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $player = this.getPlayer();
|
||||
result = result * 31 + (($player == null) ? 0 : $player.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
import net.md_5.bungee.api.connection.Connection;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public abstract class TargetedEvent extends Event {
|
||||
private final Connection sender;
|
||||
private final Connection receiver;
|
||||
|
||||
public Connection getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public Connection getReceiver() {
|
||||
return this.receiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TargetedEvent(sender=" + this.getSender() + ", receiver=" + this.getReceiver() + ")";
|
||||
}
|
||||
|
||||
@ConstructorProperties({ "sender", "receiver" })
|
||||
public TargetedEvent(final Connection sender, final Connection receiver) {
|
||||
this.sender = sender;
|
||||
this.receiver = receiver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof TargetedEvent)) {
|
||||
return false;
|
||||
}
|
||||
final TargetedEvent other = (TargetedEvent) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$sender = this.getSender();
|
||||
final Object other$sender = other.getSender();
|
||||
Label_0065: {
|
||||
if (this$sender == null) {
|
||||
if (other$sender == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$sender.equals(other$sender)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$receiver = this.getReceiver();
|
||||
final Object other$receiver = other.getReceiver();
|
||||
if (this$receiver == null) {
|
||||
if (other$receiver == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$receiver.equals(other$receiver)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof TargetedEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $sender = this.getSender();
|
||||
result = result * 31 + (($sender == null) ? 0 : $sender.hashCode());
|
||||
final Object $receiver = this.getReceiver();
|
||||
result = result * 31 + (($receiver == null) ? 0 : $receiver.hashCode());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import net.md_5.bungee.api.MOTD;
|
||||
|
||||
public class WebsocketMOTDEvent extends WebsocketQueryEvent {
|
||||
|
||||
public WebsocketMOTDEvent(MOTD connection) {
|
||||
super(connection);
|
||||
}
|
||||
|
||||
public MOTD getMOTD() {
|
||||
return (MOTD)connection;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.md_5.bungee.api.event;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import net.md_5.bungee.api.QueryConnection;
|
||||
import net.md_5.bungee.api.config.ListenerInfo;
|
||||
import net.md_5.bungee.api.plugin.Event;
|
||||
|
||||
public class WebsocketQueryEvent extends Event {
|
||||
|
||||
protected final QueryConnection connection;
|
||||
|
||||
public WebsocketQueryEvent(QueryConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public InetAddress getRemoteAddress() {
|
||||
return connection.getRemoteAddress();
|
||||
}
|
||||
|
||||
public ListenerInfo getListener() {
|
||||
return connection.getListener();
|
||||
}
|
||||
|
||||
public String getAccept() {
|
||||
return connection.getAccept();
|
||||
}
|
||||
|
||||
public QueryConnection getQuery() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
/**
|
||||
* Events that implement this indicate that they may be cancelled and thus
|
||||
* prevented from happening.
|
||||
*/
|
||||
public interface Cancellable
|
||||
{
|
||||
|
||||
/**
|
||||
* Get whether or not this event is cancelled.
|
||||
*
|
||||
* @return the cancelled state of this event
|
||||
*/
|
||||
public boolean isCancelled();
|
||||
|
||||
/**
|
||||
* Sets the cancelled state of this event.
|
||||
*
|
||||
* @param cancel the state to set
|
||||
*/
|
||||
public void setCancelled(boolean cancel);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
public abstract class Command {
|
||||
private final String name;
|
||||
private final String permission;
|
||||
private final String[] aliases;
|
||||
|
||||
public Command(final String name) {
|
||||
this(name, null, new String[0]);
|
||||
}
|
||||
|
||||
public Command(final String name, final String permission, final String... aliases) {
|
||||
Preconditions.checkArgument(name != null, (Object) "name");
|
||||
this.name = name;
|
||||
this.permission = permission;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
|
||||
public abstract void execute(final CommandSender p0, final String[] p1);
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getPermission() {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
public String[] getAliases() {
|
||||
return this.aliases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Command)) {
|
||||
return false;
|
||||
}
|
||||
final Command other = (Command) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$name = this.getName();
|
||||
final Object other$name = other.getName();
|
||||
Label_0065: {
|
||||
if (this$name == null) {
|
||||
if (other$name == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$name.equals(other$name)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$permission = this.getPermission();
|
||||
final Object other$permission = other.getPermission();
|
||||
if (this$permission == null) {
|
||||
if (other$permission == null) {
|
||||
return Arrays.deepEquals(this.getAliases(), other.getAliases());
|
||||
}
|
||||
} else if (this$permission.equals(other$permission)) {
|
||||
return Arrays.deepEquals(this.getAliases(), other.getAliases());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof Command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $name = this.getName();
|
||||
result = result * 31 + (($name == null) ? 0 : $name.hashCode());
|
||||
final Object $permission = this.getPermission();
|
||||
result = result * 31 + (($permission == null) ? 0 : $permission.hashCode());
|
||||
result = result * 31 + Arrays.deepHashCode(this.getAliases());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Command(name=" + this.getName() + ", permission=" + this.getPermission() + ", aliases=" + Arrays.deepToString(this.getAliases()) + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
/**
|
||||
* Dummy class which all callable events must extend.
|
||||
*/
|
||||
public abstract class Event
|
||||
{
|
||||
|
||||
/**
|
||||
* Method called after this event has been dispatched to all handlers.
|
||||
*/
|
||||
public void postCall()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
/**
|
||||
* Dummy interface which all event subscribers and listeners must implement.
|
||||
*/
|
||||
public interface Listener
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.util.logging.Logger;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ConfigurationAdapter;
|
||||
|
||||
/**
|
||||
* Represents any Plugin that may be loaded at runtime to enhance existing
|
||||
* functionality.
|
||||
*/
|
||||
public class Plugin
|
||||
{
|
||||
private PluginDescription description;
|
||||
private ProxyServer proxy;
|
||||
private File file;
|
||||
private Logger logger;
|
||||
|
||||
protected Plugin() {
|
||||
}
|
||||
|
||||
protected Plugin(PluginDescription forceDesc) {
|
||||
this.description = forceDesc;
|
||||
}
|
||||
|
||||
public PluginDescription getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public ProxyServer getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the plugin has just been loaded. Most of the proxy will not
|
||||
* be initialized, so only use it for registering
|
||||
* {@link ConfigurationAdapter}'s and other predefined behavior.
|
||||
*/
|
||||
public void onLoad()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this plugin is enabled.
|
||||
*/
|
||||
public void onEnable()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this plugin is disabled.
|
||||
*/
|
||||
public void onDisable()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data folder where this plugin may store arbitrary data. It will
|
||||
* be a child of {@link ProxyServer#getPluginsFolder()}.
|
||||
*
|
||||
* @return the data folder of this plugin
|
||||
*/
|
||||
public final File getDataFolder()
|
||||
{
|
||||
return new File( getProxy().getPluginsFolder(), getDescription().getName() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a resource from within this plugins jar or container. Care must be
|
||||
* taken to close the returned stream.
|
||||
*
|
||||
* @param name the full path name of this resource
|
||||
* @return the stream for getting this resource, or null if it does not
|
||||
* exist
|
||||
*/
|
||||
public final InputStream getResourceAsStream(String name)
|
||||
{
|
||||
return getClass().getClassLoader().getResourceAsStream( name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by the loader to initialize the fields in this plugin.
|
||||
*
|
||||
*/
|
||||
final void init(ProxyServer proxy, PluginDescription description)
|
||||
{
|
||||
this.proxy = proxy;
|
||||
this.description = description;
|
||||
this.file = description.getFile();
|
||||
this.logger = new PluginLogger( this );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
public class PluginClassloader extends URLClassLoader
|
||||
{
|
||||
|
||||
private static final Set<PluginClassloader> allLoaders = new CopyOnWriteArraySet<>();
|
||||
|
||||
static
|
||||
{
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
|
||||
public PluginClassloader(URL[] urls)
|
||||
{
|
||||
super( urls );
|
||||
allLoaders.add( this );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
|
||||
{
|
||||
return loadClass0( name, resolve, true );
|
||||
}
|
||||
|
||||
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException
|
||||
{
|
||||
try
|
||||
{
|
||||
return super.loadClass( name, resolve );
|
||||
} catch ( ClassNotFoundException ex )
|
||||
{
|
||||
}
|
||||
if ( checkOther )
|
||||
{
|
||||
for ( PluginClassloader loader : allLoaders )
|
||||
{
|
||||
if ( loader != this )
|
||||
{
|
||||
try
|
||||
{
|
||||
return loader.loadClass0( name, resolve, false );
|
||||
} catch ( ClassNotFoundException ex )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new ClassNotFoundException( name );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
/**
|
||||
* POJO representing the plugin.yml file.
|
||||
*/
|
||||
|
||||
//@Data
|
||||
|
||||
public class PluginDescription
|
||||
{
|
||||
public PluginDescription(){
|
||||
|
||||
}
|
||||
|
||||
public PluginDescription(String name, String main, String version, String author, Set<String> depends, File file) {
|
||||
this.name = name;
|
||||
this.main = main;
|
||||
this.version = version;
|
||||
this.author = author;
|
||||
this.depends = depends;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getMain() {
|
||||
return main;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public Set<String> getDepends() {
|
||||
return depends;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setMain(String main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public void setDepends(Set<String> depends) {
|
||||
this.depends = depends;
|
||||
}
|
||||
|
||||
public void setFile(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Friendly name of the plugin.
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* Plugin main class. Needs to extend {@link Plugin}.
|
||||
*/
|
||||
private String main;
|
||||
/**
|
||||
* Plugin version.
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* Plugin author.
|
||||
*/
|
||||
private String author;
|
||||
/**
|
||||
* Plugin hard dependencies.
|
||||
*/
|
||||
private Set<String> depends = new HashSet<>();
|
||||
/**
|
||||
* File we were loaded from.
|
||||
*/
|
||||
private File file = null;
|
||||
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class PluginLogger extends Logger
|
||||
{
|
||||
|
||||
private String pluginName;
|
||||
|
||||
protected PluginLogger(Plugin plugin)
|
||||
{
|
||||
super( plugin.getClass().getCanonicalName(), null );
|
||||
pluginName = "[" + plugin.getDescription().getName() + "] ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(LogRecord logRecord)
|
||||
{
|
||||
logRecord.setMessage( pluginName + logRecord.getMessage() );
|
||||
ProxyServer.getInstance().getLogger().log( logRecord );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.event.EventBus;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
/**
|
||||
* Class to manage bridging between plugin duties and implementation duties, for
|
||||
* example event handling and plugin management.
|
||||
*/
|
||||
public class PluginManager
|
||||
{
|
||||
|
||||
private static final Pattern argsSplit = Pattern.compile( " " );
|
||||
/*========================================================================*/
|
||||
private final ProxyServer proxy;
|
||||
/*========================================================================*/
|
||||
private final Yaml yaml = new Yaml();
|
||||
private final EventBus eventBus;
|
||||
private final Map<String, Plugin> plugins = new LinkedHashMap<>();
|
||||
private final Map<String, Command> commandMap = new HashMap<>();
|
||||
private Map<String, PluginDescription> toLoad = new HashMap<>();
|
||||
private Multimap<Plugin, Command> commandsByPlugin = ArrayListMultimap.create();
|
||||
private Multimap<Plugin, Listener> listenersByPlugin = ArrayListMultimap.create();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public PluginManager(ProxyServer proxy)
|
||||
{
|
||||
this.proxy = proxy;
|
||||
eventBus = new EventBus( proxy.getLogger() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a command so that it may be executed.
|
||||
*
|
||||
* @param plugin the plugin owning this command
|
||||
* @param command the command to register
|
||||
*/
|
||||
public void registerCommand(Plugin plugin, Command command)
|
||||
{
|
||||
commandMap.put( command.getName().toLowerCase(), command );
|
||||
for ( String alias : command.getAliases() )
|
||||
{
|
||||
commandMap.put( alias.toLowerCase(), command );
|
||||
}
|
||||
commandsByPlugin.put( plugin, command );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a command so it will no longer be executed.
|
||||
*
|
||||
* @param command the command to unregister
|
||||
*/
|
||||
public void unregisterCommand(Command command)
|
||||
{
|
||||
commandMap.values().remove( command );
|
||||
commandsByPlugin.values().remove( command );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all commands owned by a {@link Plugin}
|
||||
*
|
||||
* @param plugin the plugin to register the commands of
|
||||
*/
|
||||
public void unregisterCommands(Plugin plugin)
|
||||
{
|
||||
for ( Iterator<Command> it = commandsByPlugin.get( plugin ).iterator(); it.hasNext(); )
|
||||
{
|
||||
commandMap.values().remove( it.next() );
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine)
|
||||
{
|
||||
return dispatchCommand( sender, commandLine, null );
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a command if it is registered, else return false.
|
||||
*
|
||||
* @param sender the sender executing the command
|
||||
* @param commandLine the complete command line including command name and
|
||||
* arguments
|
||||
* @return whether the command was handled
|
||||
*/
|
||||
public boolean dispatchCommand(CommandSender sender, String commandLine, List<String> tabResults)
|
||||
{
|
||||
String[] split = argsSplit.split( commandLine );
|
||||
// Check for chat that only contains " "
|
||||
if ( split.length == 0 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String commandName = split[0].toLowerCase();
|
||||
if ( proxy.getDisabledCommands().contains( commandName ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Command command = commandMap.get( commandName );
|
||||
if ( command == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String permission = command.getPermission();
|
||||
if ( permission != null && !permission.isEmpty() && !sender.hasPermission( permission ) )
|
||||
{
|
||||
sender.sendMessage( proxy.getTranslation( "no_permission" ) );
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] args = Arrays.copyOfRange( split, 1, split.length );
|
||||
try
|
||||
{
|
||||
if ( tabResults == null )
|
||||
{
|
||||
command.execute( sender, args );
|
||||
} else if ( command instanceof TabExecutor )
|
||||
{
|
||||
for ( String s : ( (TabExecutor) command ).onTabComplete( sender, args ) )
|
||||
{
|
||||
tabResults.add( s );
|
||||
}
|
||||
}
|
||||
} catch ( Exception ex )
|
||||
{
|
||||
sender.sendMessage( ChatColor.RED + "An internal error occurred whilst executing this command, please check the console log for details." );
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Error in dispatching command", ex );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Plugin} objects corresponding to all loaded plugins.
|
||||
*
|
||||
* @return the set of loaded plugins
|
||||
*/
|
||||
public Collection<Plugin> getPlugins()
|
||||
{
|
||||
return plugins.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a loaded plugin identified by the specified name.
|
||||
*
|
||||
* @param name of the plugin to retrieve
|
||||
* @return the retrieved plugin or null if not loaded
|
||||
*/
|
||||
public Plugin getPlugin(String name)
|
||||
{
|
||||
return plugins.get( name );
|
||||
}
|
||||
|
||||
public void loadAndEnablePlugins()
|
||||
{
|
||||
Map<PluginDescription, Boolean> pluginStatuses = new HashMap<>();
|
||||
for ( Map.Entry<String, PluginDescription> entry : toLoad.entrySet() )
|
||||
{
|
||||
PluginDescription plugin = entry.getValue();
|
||||
if ( !enablePlugin( pluginStatuses, new Stack<PluginDescription>(), plugin ) )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().warning( "Failed to enable " + entry.getKey() );
|
||||
}
|
||||
}
|
||||
toLoad.clear();
|
||||
toLoad = null;
|
||||
|
||||
for ( Plugin plugin : plugins.values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
plugin.onEnable();
|
||||
ProxyServer.getInstance().getLogger().log( Level.INFO, "Enabled plugin {0} version {1} by {2}", new Object[]
|
||||
{
|
||||
plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getAuthor()
|
||||
} );
|
||||
} catch ( Throwable t )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Exception encountered when loading plugin: " + plugin.getDescription().getName(), t );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enablePlugin(Map<PluginDescription, Boolean> pluginStatuses, Stack<PluginDescription> dependStack, PluginDescription plugin)
|
||||
{
|
||||
if ( pluginStatuses.containsKey( plugin ) )
|
||||
{
|
||||
return pluginStatuses.get( plugin );
|
||||
}
|
||||
|
||||
// success status
|
||||
boolean status = true;
|
||||
|
||||
// try to load dependencies first
|
||||
for ( String dependName : plugin.getDepends() )
|
||||
{
|
||||
PluginDescription depend = toLoad.get( dependName );
|
||||
Boolean dependStatus = ( depend != null ) ? pluginStatuses.get( depend ) : Boolean.FALSE;
|
||||
|
||||
if ( dependStatus == null )
|
||||
{
|
||||
if ( dependStack.contains( depend ) )
|
||||
{
|
||||
StringBuilder dependencyGraph = new StringBuilder();
|
||||
for ( PluginDescription element : dependStack )
|
||||
{
|
||||
dependencyGraph.append( element.getName() ).append( " -> " );
|
||||
}
|
||||
dependencyGraph.append( plugin.getName() ).append( " -> " ).append( dependName );
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Circular dependency detected: " + dependencyGraph );
|
||||
status = false;
|
||||
} else
|
||||
{
|
||||
dependStack.push( plugin );
|
||||
dependStatus = this.enablePlugin( pluginStatuses, dependStack, depend );
|
||||
dependStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
if ( dependStatus == Boolean.FALSE )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} (required by {1}) is unavailable", new Object[]
|
||||
{
|
||||
String.valueOf( depend.getName() ), plugin.getName()
|
||||
} );
|
||||
status = false;
|
||||
}
|
||||
|
||||
if ( !status )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// do actual loading
|
||||
if ( status )
|
||||
{
|
||||
try
|
||||
{
|
||||
URLClassLoader loader = new PluginClassloader( new URL[]
|
||||
{
|
||||
plugin.getFile().toURI().toURL()
|
||||
} );
|
||||
Class<?> main = loader.loadClass( plugin.getMain() );
|
||||
Plugin clazz = (Plugin) main.getDeclaredConstructor().newInstance();
|
||||
|
||||
clazz.init( proxy, plugin );
|
||||
plugins.put( plugin.getName(), clazz );
|
||||
clazz.onLoad();
|
||||
ProxyServer.getInstance().getLogger().log( Level.INFO, "Loaded plugin {0} version {1} by {2}", new Object[]
|
||||
{
|
||||
plugin.getName(), plugin.getVersion(), plugin.getAuthor()
|
||||
} );
|
||||
} catch ( Throwable t )
|
||||
{
|
||||
proxy.getLogger().log( Level.WARNING, "Error enabling plugin " + plugin.getName(), t );
|
||||
}
|
||||
}
|
||||
|
||||
pluginStatuses.put( plugin, status );
|
||||
return status;
|
||||
}
|
||||
|
||||
public void addInternalPlugin(Plugin plug) {
|
||||
this.plugins.put(plug.getDescription().getName(), plug);
|
||||
plug.init(proxy, plug.getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all plugins from the specified folder.
|
||||
*
|
||||
* @param folder the folder to search for plugins in
|
||||
*/
|
||||
public void detectPlugins(File folder)
|
||||
{
|
||||
Preconditions.checkNotNull( folder, "folder" );
|
||||
Preconditions.checkArgument( folder.isDirectory(), "Must load from a directory" );
|
||||
|
||||
for ( File file : folder.listFiles() )
|
||||
{
|
||||
if ( file.isFile() && file.getName().endsWith( ".jar" ) )
|
||||
{
|
||||
try ( JarFile jar = new JarFile( file ) )
|
||||
{
|
||||
JarEntry pdf = jar.getJarEntry( "plugin.yml" );
|
||||
Preconditions.checkNotNull( pdf, "Plugin must have a plugin.yml" );
|
||||
|
||||
try ( InputStream in = jar.getInputStream( pdf ) )
|
||||
{
|
||||
PluginDescription desc = yaml.loadAs( in, PluginDescription.class );
|
||||
desc.setFile( file );
|
||||
toLoad.put( desc.getName(), desc );
|
||||
}
|
||||
} catch ( Exception ex )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not load plugin from file " + file, ex );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch an event to all subscribed listeners and return the event once
|
||||
* it has been handled by these listeners.
|
||||
*
|
||||
* @param <T> the type bounds, must be a class which extends event
|
||||
* @param event the event to call
|
||||
* @return the called event
|
||||
*/
|
||||
public <T extends Event> T callEvent(T event)
|
||||
{
|
||||
Preconditions.checkNotNull( event, "event" );
|
||||
|
||||
long start = System.nanoTime();
|
||||
eventBus.post( event );
|
||||
event.postCall();
|
||||
|
||||
long elapsed = start - System.nanoTime();
|
||||
if ( elapsed > 250000 )
|
||||
{
|
||||
ProxyServer.getInstance().getLogger().log( Level.WARNING, "Event {0} took more {1}ns to process!", new Object[]
|
||||
{
|
||||
event, elapsed
|
||||
} );
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a {@link Listener} for receiving called events. Methods in this
|
||||
* Object which wish to receive events must be annotated with the
|
||||
* {@link EventHandler} annotation.
|
||||
*
|
||||
* @param plugin the owning plugin
|
||||
* @param listener the listener to register events for
|
||||
*/
|
||||
public void registerListener(Plugin plugin, Listener listener)
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a {@link Listener} so that the events do not reach it anymore.
|
||||
*
|
||||
* @param listener the listener to unregister
|
||||
*/
|
||||
public void unregisterListener(Listener listener)
|
||||
{
|
||||
eventBus.unregister( listener );
|
||||
listenersByPlugin.values().remove( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister all of a Plugin's listener.
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public void unregisterListeners(Plugin plugin)
|
||||
{
|
||||
for ( Iterator<Listener> it = listenersByPlugin.get( plugin ).iterator(); it.hasNext(); )
|
||||
{
|
||||
eventBus.unregister( it.next() );
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.md_5.bungee.api.plugin;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
|
||||
|
||||
public interface TabExecutor
|
||||
{
|
||||
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package net.md_5.bungee.api.scheduler;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* Represents a task scheduled for execution by the {@link TaskScheduler}.
|
||||
*/
|
||||
public interface ScheduledTask
|
||||
{
|
||||
|
||||
/**
|
||||
* Gets the unique ID of this task.
|
||||
*
|
||||
* @return this tasks ID
|
||||
*/
|
||||
int getId();
|
||||
|
||||
/**
|
||||
* Return the plugin which scheduled this task for execution.
|
||||
*
|
||||
* @return the owning plugin
|
||||
*/
|
||||
Plugin getOwner();
|
||||
|
||||
/**
|
||||
* Get the actual method which will be executed by this task.
|
||||
*
|
||||
* @return the {@link Runnable} behind this task
|
||||
*/
|
||||
Runnable getTask();
|
||||
|
||||
/**
|
||||
* Cancel this task to suppress subsequent executions.
|
||||
*/
|
||||
void cancel();
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package net.md_5.bungee.api.scheduler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* This interface represents a scheduler which may be used to queue, delay and
|
||||
* execute tasks in an asynchronous fashion.
|
||||
*/
|
||||
public interface TaskScheduler
|
||||
{
|
||||
|
||||
/**
|
||||
* Cancel a task to prevent it from executing, or if its a repeating task,
|
||||
* prevent its further execution.
|
||||
*
|
||||
* @param id the id of the task to cancel
|
||||
*/
|
||||
void cancel(int id);
|
||||
|
||||
/**
|
||||
* Cancel a task to prevent it from executing, or if its a repeating task,
|
||||
* prevent its further execution.
|
||||
*
|
||||
* @param task the task to cancel
|
||||
*/
|
||||
void cancel(ScheduledTask task);
|
||||
|
||||
/**
|
||||
* Cancel all tasks owned by this plugin, this preventing them from being
|
||||
* executed hereon in.
|
||||
*
|
||||
* @param plugin the plugin owning the tasks to be cancelled
|
||||
* @return the number of tasks cancelled by this method
|
||||
*/
|
||||
int cancel(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Schedule a task to be executed asynchronously. The task will commence
|
||||
* running as soon as this method returns.
|
||||
*
|
||||
* @param owner the plugin owning this task
|
||||
* @param task the task to run
|
||||
* @return the scheduled task
|
||||
*/
|
||||
ScheduledTask runAsync(Plugin owner, Runnable task);
|
||||
|
||||
/**
|
||||
* Schedules a task to be executed asynchronously after the specified delay
|
||||
* is up.
|
||||
*
|
||||
* @param owner the plugin owning this task
|
||||
* @param task the task to run
|
||||
* @param delay the delay before this task will be executed
|
||||
* @param unit the unit in which the delay will be measured
|
||||
* @return the scheduled task
|
||||
*/
|
||||
ScheduledTask schedule(Plugin owner, Runnable task, long delay, TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Schedules a task to be executed asynchronously after the specified delay
|
||||
* is up. The scheduled task will continue running at the specified
|
||||
* interval. The interval will not begin to count down until the last task
|
||||
* invocation is complete.
|
||||
*
|
||||
* @param owner the plugin owning this task
|
||||
* @param task the task to run
|
||||
* @param delay the delay in milliseconds before this task will be executed
|
||||
* @param period the interval before subsequent executions of this task
|
||||
* @param unit the unit in which the delay and period will be measured
|
||||
* @return the scheduled task
|
||||
*/
|
||||
ScheduledTask schedule(Plugin owner, Runnable task, long delay, long period, TimeUnit unit);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package net.md_5.bungee.api.score;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
/**
|
||||
* Represents an objective entry.
|
||||
*/
|
||||
public class Objective
|
||||
{
|
||||
|
||||
/**
|
||||
* Name of the objective.
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* Value of the objective.
|
||||
*/
|
||||
private final String value; // displayName
|
||||
|
||||
@ConstructorProperties({ "name", "value" })
|
||||
public Objective(final String name, final String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Objective)) {
|
||||
return false;
|
||||
}
|
||||
final Objective other = (Objective) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$name = this.getName();
|
||||
final Object other$name = other.getName();
|
||||
Label_0065: {
|
||||
if (this$name == null) {
|
||||
if (other$name == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$name.equals(other$name)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$value = this.getValue();
|
||||
final Object other$value = other.getValue();
|
||||
if (this$value == null) {
|
||||
if (other$value == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$value.equals(other$value)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof Objective;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $name = this.getName();
|
||||
result = result * 31 + (($name == null) ? 0 : $name.hashCode());
|
||||
final Object $value = this.getValue();
|
||||
result = result * 31 + (($value == null) ? 0 : $value.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Objective(name=" + this.getName() + ", value=" + this.getValue() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.md_5.bungee.api.score;
|
||||
|
||||
/**
|
||||
* Represents locations for a scoreboard to be displayed.
|
||||
*/
|
||||
public enum Position
|
||||
{
|
||||
|
||||
LIST, SIDEBAR, BELOW;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package net.md_5.bungee.api.score;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
|
||||
/**
|
||||
* Represents a scoreboard score entry.
|
||||
*/
|
||||
public class Score
|
||||
{
|
||||
|
||||
/**
|
||||
* Name to be displayed in the list.
|
||||
*/
|
||||
private final String itemName; // Player
|
||||
/**
|
||||
* Unique name of the score.
|
||||
*/
|
||||
private final String scoreName; // Score
|
||||
/**
|
||||
* Value of the score.
|
||||
*/
|
||||
private final int value;
|
||||
|
||||
@ConstructorProperties({ "itemName", "scoreName", "value" })
|
||||
public Score(final String itemName, final String scoreName, final int value) {
|
||||
this.itemName = itemName;
|
||||
this.scoreName = scoreName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return this.itemName;
|
||||
}
|
||||
|
||||
public String getScoreName() {
|
||||
return this.scoreName;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Score)) {
|
||||
return false;
|
||||
}
|
||||
final Score other = (Score) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$itemName = this.getItemName();
|
||||
final Object other$itemName = other.getItemName();
|
||||
Label_0065: {
|
||||
if (this$itemName == null) {
|
||||
if (other$itemName == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$itemName.equals(other$itemName)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$scoreName = this.getScoreName();
|
||||
final Object other$scoreName = other.getScoreName();
|
||||
if (this$scoreName == null) {
|
||||
if (other$scoreName == null) {
|
||||
return this.getValue() == other.getValue();
|
||||
}
|
||||
} else if (this$scoreName.equals(other$scoreName)) {
|
||||
return this.getValue() == other.getValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof Score;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $itemName = this.getItemName();
|
||||
result = result * 31 + (($itemName == null) ? 0 : $itemName.hashCode());
|
||||
final Object $scoreName = this.getScoreName();
|
||||
result = result * 31 + (($scoreName == null) ? 0 : $scoreName.hashCode());
|
||||
result = result * 31 + this.getValue();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Score(itemName=" + this.getItemName() + ", scoreName=" + this.getScoreName() + ", value=" + this.getValue() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.score;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public class Scoreboard {
|
||||
private String name;
|
||||
private Position position;
|
||||
private final Map<String, Objective> objectives;
|
||||
private final Map<String, Score> scores;
|
||||
private final Map<String, Team> teams;
|
||||
|
||||
public Collection<Objective> getObjectives() {
|
||||
return Collections.unmodifiableCollection((Collection<? extends Objective>) this.objectives.values());
|
||||
}
|
||||
|
||||
public Collection<Score> getScores() {
|
||||
return Collections.unmodifiableCollection((Collection<? extends Score>) this.scores.values());
|
||||
}
|
||||
|
||||
public Collection<Team> getTeams() {
|
||||
return Collections.unmodifiableCollection((Collection<? extends Team>) this.teams.values());
|
||||
}
|
||||
|
||||
public void addObjective(final Objective objective) {
|
||||
Preconditions.checkNotNull((Object) objective, (Object) "objective");
|
||||
Preconditions.checkArgument(!this.objectives.containsKey(objective.getName()), "Objective %s already exists in this scoreboard", new Object[] { objective.getName() });
|
||||
this.objectives.put(objective.getName(), objective);
|
||||
}
|
||||
|
||||
public void addScore(final Score score) {
|
||||
Preconditions.checkNotNull((Object) score, (Object) "score");
|
||||
this.scores.put(score.getItemName(), score);
|
||||
}
|
||||
|
||||
public void addTeam(final Team team) {
|
||||
Preconditions.checkNotNull((Object) team, (Object) "team");
|
||||
Preconditions.checkArgument(!this.teams.containsKey(team.getName()), "Team %s already exists in this scoreboard", new Object[] { team.getName() });
|
||||
this.teams.put(team.getName(), team);
|
||||
}
|
||||
|
||||
public Team getTeam(final String name) {
|
||||
return this.teams.get(name);
|
||||
}
|
||||
|
||||
public void removeObjective(final String objectiveName) {
|
||||
this.objectives.remove(objectiveName);
|
||||
}
|
||||
|
||||
public void removeScore(final String scoreName) {
|
||||
this.scores.remove(scoreName);
|
||||
}
|
||||
|
||||
public void removeTeam(final String teamName) {
|
||||
this.teams.remove(teamName);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.name = null;
|
||||
this.position = null;
|
||||
this.objectives.clear();
|
||||
this.scores.clear();
|
||||
this.teams.clear();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Position getPosition() {
|
||||
return this.position;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPosition(final Position position) {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Scoreboard)) {
|
||||
return false;
|
||||
}
|
||||
final Scoreboard other = (Scoreboard) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$name = this.getName();
|
||||
final Object other$name = other.getName();
|
||||
Label_0065: {
|
||||
if (this$name == null) {
|
||||
if (other$name == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$name.equals(other$name)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$position = this.getPosition();
|
||||
final Object other$position = other.getPosition();
|
||||
Label_0102: {
|
||||
if (this$position == null) {
|
||||
if (other$position == null) {
|
||||
break Label_0102;
|
||||
}
|
||||
} else if (this$position.equals(other$position)) {
|
||||
break Label_0102;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$objectives = this.getObjectives();
|
||||
final Object other$objectives = other.getObjectives();
|
||||
Label_0139: {
|
||||
if (this$objectives == null) {
|
||||
if (other$objectives == null) {
|
||||
break Label_0139;
|
||||
}
|
||||
} else if (this$objectives.equals(other$objectives)) {
|
||||
break Label_0139;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$scores = this.getScores();
|
||||
final Object other$scores = other.getScores();
|
||||
Label_0176: {
|
||||
if (this$scores == null) {
|
||||
if (other$scores == null) {
|
||||
break Label_0176;
|
||||
}
|
||||
} else if (this$scores.equals(other$scores)) {
|
||||
break Label_0176;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$teams = this.getTeams();
|
||||
final Object other$teams = other.getTeams();
|
||||
if (this$teams == null) {
|
||||
if (other$teams == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$teams.equals(other$teams)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof Scoreboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $name = this.getName();
|
||||
result = result * 31 + (($name == null) ? 0 : $name.hashCode());
|
||||
final Object $position = this.getPosition();
|
||||
result = result * 31 + (($position == null) ? 0 : $position.hashCode());
|
||||
final Object $objectives = this.getObjectives();
|
||||
result = result * 31 + (($objectives == null) ? 0 : $objectives.hashCode());
|
||||
final Object $scores = this.getScores();
|
||||
result = result * 31 + (($scores == null) ? 0 : $scores.hashCode());
|
||||
final Object $teams = this.getTeams();
|
||||
result = result * 31 + (($teams == null) ? 0 : $teams.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Scoreboard(name=" + this.getName() + ", position=" + this.getPosition() + ", objectives=" + this.getObjectives() + ", scores=" + this.getScores() + ", teams=" + this.getTeams() + ")";
|
||||
}
|
||||
|
||||
public Scoreboard() {
|
||||
this.objectives = new HashMap<String, Objective>();
|
||||
this.scores = new HashMap<String, Score>();
|
||||
this.teams = new HashMap<String, Team>();
|
||||
}
|
||||
}
|
||||
183
eaglerbungee/src/main/java/net/md_5/bungee/api/score/Team.java
Normal file
183
eaglerbungee/src/main/java/net/md_5/bungee/api/score/Team.java
Normal file
@@ -0,0 +1,183 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.score;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class Team {
|
||||
private final String name;
|
||||
private String displayName;
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
private boolean friendlyFire;
|
||||
private Set<String> players;
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return (Collection<String>) (Collection<?>) Collections.unmodifiableSet((Set<?>) this.players);
|
||||
}
|
||||
|
||||
public void addPlayer(final String name) {
|
||||
this.players.add(name);
|
||||
}
|
||||
|
||||
public void removePlayer(final String name) {
|
||||
this.players.remove(name);
|
||||
}
|
||||
|
||||
@ConstructorProperties({ "name" })
|
||||
public Team(final String name) {
|
||||
this.players = new HashSet<String>();
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public String getSuffix() {
|
||||
return this.suffix;
|
||||
}
|
||||
|
||||
public boolean isFriendlyFire() {
|
||||
return this.friendlyFire;
|
||||
}
|
||||
|
||||
public void setDisplayName(final String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public void setPrefix(final String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public void setSuffix(final String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public void setFriendlyFire(final boolean friendlyFire) {
|
||||
this.friendlyFire = friendlyFire;
|
||||
}
|
||||
|
||||
public void setPlayers(final Set<String> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Team)) {
|
||||
return false;
|
||||
}
|
||||
final Team other = (Team) o;
|
||||
if (!other.canEqual(this)) {
|
||||
return false;
|
||||
}
|
||||
final Object this$name = this.getName();
|
||||
final Object other$name = other.getName();
|
||||
Label_0065: {
|
||||
if (this$name == null) {
|
||||
if (other$name == null) {
|
||||
break Label_0065;
|
||||
}
|
||||
} else if (this$name.equals(other$name)) {
|
||||
break Label_0065;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$displayName = this.getDisplayName();
|
||||
final Object other$displayName = other.getDisplayName();
|
||||
Label_0102: {
|
||||
if (this$displayName == null) {
|
||||
if (other$displayName == null) {
|
||||
break Label_0102;
|
||||
}
|
||||
} else if (this$displayName.equals(other$displayName)) {
|
||||
break Label_0102;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$prefix = this.getPrefix();
|
||||
final Object other$prefix = other.getPrefix();
|
||||
Label_0139: {
|
||||
if (this$prefix == null) {
|
||||
if (other$prefix == null) {
|
||||
break Label_0139;
|
||||
}
|
||||
} else if (this$prefix.equals(other$prefix)) {
|
||||
break Label_0139;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
final Object this$suffix = this.getSuffix();
|
||||
final Object other$suffix = other.getSuffix();
|
||||
Label_0176: {
|
||||
if (this$suffix == null) {
|
||||
if (other$suffix == null) {
|
||||
break Label_0176;
|
||||
}
|
||||
} else if (this$suffix.equals(other$suffix)) {
|
||||
break Label_0176;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (this.isFriendlyFire() != other.isFriendlyFire()) {
|
||||
return false;
|
||||
}
|
||||
final Object this$players = this.getPlayers();
|
||||
final Object other$players = other.getPlayers();
|
||||
if (this$players == null) {
|
||||
if (other$players == null) {
|
||||
return true;
|
||||
}
|
||||
} else if (this$players.equals(other$players)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canEqual(final Object other) {
|
||||
return other instanceof Team;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 31;
|
||||
int result = 1;
|
||||
final Object $name = this.getName();
|
||||
result = result * 31 + (($name == null) ? 0 : $name.hashCode());
|
||||
final Object $displayName = this.getDisplayName();
|
||||
result = result * 31 + (($displayName == null) ? 0 : $displayName.hashCode());
|
||||
final Object $prefix = this.getPrefix();
|
||||
result = result * 31 + (($prefix == null) ? 0 : $prefix.hashCode());
|
||||
final Object $suffix = this.getSuffix();
|
||||
result = result * 31 + (($suffix == null) ? 0 : $suffix.hashCode());
|
||||
result = result * 31 + (this.isFriendlyFire() ? 1231 : 1237);
|
||||
final Object $players = this.getPlayers();
|
||||
result = result * 31 + (($players == null) ? 0 : $players.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Team(name=" + this.getName() + ", displayName=" + this.getDisplayName() + ", prefix=" + this.getPrefix() + ", suffix=" + this.getSuffix() + ", friendlyFire=" + this.isFriendlyFire() + ", players=" + this.getPlayers() + ")";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.md_5.bungee.api.tab;
|
||||
|
||||
/**
|
||||
* Represents a custom tab list, which may have slots manipulated.
|
||||
*/
|
||||
public interface CustomTabList extends TabListHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Blank out this tab list and update immediately.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Gets the columns in this list.
|
||||
*
|
||||
* @return the width of this list
|
||||
*/
|
||||
int getColumns();
|
||||
|
||||
/**
|
||||
* Gets the rows in this list.
|
||||
*
|
||||
* @return the height of this list
|
||||
*/
|
||||
int getRows();
|
||||
|
||||
/**
|
||||
* Get the total size of this list.
|
||||
*
|
||||
* @return {@link #getRows()} * {@link #getColumns()}
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* Set the text in the specified slot and update immediately.
|
||||
*
|
||||
* @param row the row to set
|
||||
* @param column the column to set
|
||||
* @param text the text to set
|
||||
* @return the padded text
|
||||
*/
|
||||
String setSlot(int row, int column, String text);
|
||||
|
||||
/**
|
||||
* Set the text in the specified slot.
|
||||
*
|
||||
* @param row the row to set
|
||||
* @param column the column to set
|
||||
* @param text the text to set
|
||||
* @param update whether or not to invoke {@link #update()} upon completion
|
||||
* @return the padded text
|
||||
*/
|
||||
String setSlot(int row, int column, String text, boolean update);
|
||||
|
||||
/**
|
||||
* Flush all queued changes to the user.
|
||||
*/
|
||||
void update();
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Decompiled by Procyon v0.5.36
|
||||
//
|
||||
|
||||
package net.md_5.bungee.api.tab;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public abstract class TabListAdapter implements TabListHandler {
|
||||
private ProxiedPlayer player;
|
||||
|
||||
@Override
|
||||
public void init(final ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnect() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnect() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServerChange() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPingChange(final int ping) {
|
||||
}
|
||||
|
||||
public ProxiedPlayer getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.md_5.bungee.api.tab;
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
public interface TabListHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* Called so that this class may set member fields to keep track of its
|
||||
* internal state. You should not do any packet sending or manipulation of
|
||||
* the passed player, other than storing it.
|
||||
*
|
||||
* @param player the player to be associated with this list
|
||||
*/
|
||||
void init(ProxiedPlayer player);
|
||||
|
||||
/**
|
||||
* Called when this player first connects to the proxy.
|
||||
*/
|
||||
void onConnect();
|
||||
|
||||
/**
|
||||
* Called when a player first connects to the proxy.
|
||||
*
|
||||
* @param player the connecting player
|
||||
*/
|
||||
void onServerChange();
|
||||
|
||||
/**
|
||||
* Called when a players ping changes. The new ping will have not updated in
|
||||
* the player instance until this method returns.
|
||||
*
|
||||
* @param player the player who's ping changed
|
||||
* @param ping the player's new ping.
|
||||
*/
|
||||
void onPingChange(int ping);
|
||||
|
||||
/**
|
||||
* Called when a player disconnects.
|
||||
*
|
||||
* @param player the disconnected player
|
||||
*/
|
||||
void onDisconnect();
|
||||
|
||||
/**
|
||||
* Called when a list update packet is sent from server to client.
|
||||
*
|
||||
* @param player receiving this packet
|
||||
* @param name the player which this packet is relevant to
|
||||
* @param online whether the subject player is online
|
||||
* @param ping ping of the subject player
|
||||
* @return whether to send the packet to the client
|
||||
*/
|
||||
boolean onListUpdate(String name, boolean online, int ping);
|
||||
}
|
||||
Reference in New Issue
Block a user