mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-30 12:19:22 +00:00
Added a translate method to the logger and changed the code style a bit
This commit is contained in:
@@ -25,12 +25,18 @@
|
||||
|
||||
package org.geysermc.floodgate.api;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FloodgateApi {
|
||||
/**
|
||||
* Returns the Floodgate API instance.
|
||||
*/
|
||||
static FloodgateApi getInstance() {
|
||||
return InstanceHolder.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to determine if the given <b>online</b> player is a bedrock player
|
||||
*
|
||||
@@ -56,9 +62,9 @@ public interface FloodgateApi {
|
||||
UUID createJavaPlayerId(long xuid);
|
||||
|
||||
/**
|
||||
* Checks if the uuid of the player has the {@link #createJavaPlayerId(long)} format.
|
||||
* This method can't validate a linked player uuid, since that doesn't equal the format.
|
||||
* Use {@link #isBedrockPlayer(UUID)} if you want to include linked accounts.
|
||||
* Checks if the uuid of the player has the {@link #createJavaPlayerId(long)} format. This
|
||||
* method can't validate a linked player uuid, since that doesn't equal the format. Use {@link
|
||||
* #isBedrockPlayer(UUID)} if you want to include linked accounts.
|
||||
*
|
||||
* @param uuid the uuid to check
|
||||
* @return true if the given uuid has the correct format.
|
||||
@@ -71,11 +77,4 @@ public interface FloodgateApi {
|
||||
default PlayerLink getPlayerLink() {
|
||||
return InstanceHolder.getPlayerLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Floodgate API instance.
|
||||
*/
|
||||
static FloodgateApi getInstance() {
|
||||
return InstanceHolder.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,11 @@
|
||||
|
||||
package org.geysermc.floodgate.api;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.floodgate.api.inject.PlatformInjector;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class InstanceHolder {
|
||||
@Getter private static FloodgateApi instance;
|
||||
@Getter private static PlayerLink playerLink;
|
||||
|
||||
@@ -29,30 +29,27 @@ import io.netty.channel.Channel;
|
||||
|
||||
public interface InjectorAddon {
|
||||
/**
|
||||
* Called when injecting a specific channel
|
||||
* (every client that is connected to the server has his own channel).
|
||||
* Internally used for the Floodgate debugger and data handler but can also be used for
|
||||
* third party things.
|
||||
* Called when injecting a specific channel (every client that is connected to the server has
|
||||
* his own channel). Internally used for the Floodgate debugger and data handler but can also be
|
||||
* used for third party things.
|
||||
*
|
||||
* @param channel the channel that the injector is injecting
|
||||
* @param proxyToServer if the the connection is between the proxy and a server
|
||||
* @param channel the channel that the injector is injecting
|
||||
* @param toServer if the the connection is between a proxy and a server
|
||||
*/
|
||||
void onInject(Channel channel, boolean proxyToServer);
|
||||
void onInject(Channel channel, boolean toServer);
|
||||
|
||||
/**
|
||||
* Called when the player successfully logged in.
|
||||
* That is the moment that most of the addons can deregister.
|
||||
* Note that it is entirely optional to remove the addon from the channel,
|
||||
* the injector won't force the addon to remove.
|
||||
* Called when the player successfully logged in. That is the moment that most of the addons can
|
||||
* deregister. Note that it is entirely optional to remove the addon from the channel, the
|
||||
* injector won't force the addon to remove.
|
||||
*
|
||||
* @param channel the channel that the injector injected
|
||||
*/
|
||||
void onLoginDone(Channel channel);
|
||||
|
||||
/**
|
||||
* Called when Floodgate is removing the injection from the server.
|
||||
* The addon should remove his traces otherwise it is likely that an error will popup after
|
||||
* the server is injected again.
|
||||
* Called when Floodgate is removing the injection from the server. The addon should remove his
|
||||
* traces otherwise it is likely that an error will popup after the server is injected again.
|
||||
*
|
||||
* @param channel the channel that the injector injected
|
||||
*/
|
||||
|
||||
@@ -26,17 +26,16 @@
|
||||
package org.geysermc.floodgate.api.inject;
|
||||
|
||||
/**
|
||||
* The global interface of all the Platform Injectors.
|
||||
* The injector can be used for various things. It is used internally for getting Floodgate
|
||||
* data out of the handshake packet and for debug mode, but there is also an option to add your
|
||||
* own addons.
|
||||
* Note that every Floodgate platform that supports netty should implement this,
|
||||
* but the platform implementation isn't required to implement this.
|
||||
* The global interface of all the Platform Injectors. The injector can be used for various things.
|
||||
* It is used internally for getting Floodgate data out of the handshake packet and for debug mode,
|
||||
* but there is also an option to add your own addons. Note that every Floodgate platform that
|
||||
* supports netty should implement this, but the platform implementation isn't required to implement
|
||||
* this.
|
||||
*/
|
||||
public interface PlatformInjector {
|
||||
/**
|
||||
* Injects the server connection.
|
||||
* This will allow various addons (like getting the Floodgate data and debug mode) to work.
|
||||
* Injects the server connection. This will allow various addons (like getting the Floodgate
|
||||
* data and debug mode) to work.
|
||||
*
|
||||
* @return true if the connection has successfully been injected
|
||||
* @throws Exception if something went wrong while injecting the server connection
|
||||
@@ -44,9 +43,8 @@ public interface PlatformInjector {
|
||||
boolean inject() throws Exception;
|
||||
|
||||
/**
|
||||
* Removes the injection from the server.
|
||||
* Please note that this function should only be used internally (on plugin shutdown).
|
||||
* This method will also remove every added addon.
|
||||
* Removes the injection from the server. Please note that this function should only be used
|
||||
* internally (on plugin shutdown). This method will also remove every added addon.
|
||||
*
|
||||
* @return true if the injection has successfully been removed
|
||||
* @throws Exception if something went wrong while removing the injection
|
||||
@@ -61,9 +59,8 @@ public interface PlatformInjector {
|
||||
boolean isInjected();
|
||||
|
||||
/**
|
||||
* Adds an addon to the addon list of the Floodgate Injector
|
||||
* (the addon is called when Floodgate injects a channel).
|
||||
* See {@link InjectorAddon} for more info.
|
||||
* Adds an addon to the addon list of the Floodgate Injector (the addon is called when Floodgate
|
||||
* injects a channel). See {@link InjectorAddon} for more info.
|
||||
*
|
||||
* @param addon the addon to add to the addon list
|
||||
* @return true if the addon has been added, false if the addon is already present
|
||||
@@ -71,9 +68,8 @@ public interface PlatformInjector {
|
||||
boolean addAddon(InjectorAddon addon);
|
||||
|
||||
/**
|
||||
* Removes an addon from the addon list of the Floodgate Injector
|
||||
* (the addon is called when Floodgate injects a channel).
|
||||
* See {@link InjectorAddon} for more info.
|
||||
* Removes an addon from the addon list of the Floodgate Injector (the addon is called when
|
||||
* Floodgate injects a channel). See {@link InjectorAddon} for more info.
|
||||
*
|
||||
* @param addon the class of the addon to remove from the addon list
|
||||
* @param <T> the addon type
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
|
||||
package org.geysermc.floodgate.api.link;
|
||||
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public interface LinkRequest {
|
||||
/**
|
||||
@@ -64,10 +63,10 @@ public interface LinkRequest {
|
||||
boolean isExpired(long linkTimeout);
|
||||
|
||||
/**
|
||||
* Checks if the given FloodgatePlayer is the player requested in this LinkRequest.
|
||||
* This method will check both the real bedrock username
|
||||
* {@link FloodgatePlayer#getUsername()} and the edited username
|
||||
* {@link FloodgatePlayer#getJavaUsername()} and returns true if one of the two matches.
|
||||
* Checks if the given FloodgatePlayer is the player requested in this LinkRequest. This method
|
||||
* will check both the real bedrock username {@link FloodgatePlayer#getUsername()} and the
|
||||
* edited username {@link FloodgatePlayer#getJavaUsername()} and returns true if one of the two
|
||||
* matches.
|
||||
*
|
||||
* @param player the player to check
|
||||
* @return true if the given player is the player requested
|
||||
|
||||
@@ -25,22 +25,20 @@
|
||||
|
||||
package org.geysermc.floodgate.api.link;
|
||||
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
|
||||
/**
|
||||
* The base class of the PlayerLink database implementation.
|
||||
* The implementation is responsible for making a connection with the database
|
||||
* and keeping that connection alive so that Floodgate (or a third party plugin)
|
||||
* can check for example if a given player is linked.
|
||||
* The base class of the PlayerLink database implementation. The implementation is responsible for
|
||||
* making a connection with the database and keeping that connection alive so that Floodgate (or a
|
||||
* third party plugin) can check for example if a given player is linked.
|
||||
*/
|
||||
public interface PlayerLink {
|
||||
/**
|
||||
* Called by Floodgate after the initialization of the class.
|
||||
* In this method the implementation should start the connection with the database and
|
||||
* create the collections if they don't exist already.
|
||||
* Called by Floodgate after the initialization of the class. In this method the implementation
|
||||
* should start the connection with the database and create the collections if they don't exist
|
||||
* already.
|
||||
*/
|
||||
void load();
|
||||
|
||||
@@ -48,8 +46,8 @@ public interface PlayerLink {
|
||||
* Get a linked player by the bedrock uuid
|
||||
*
|
||||
* @param bedrockId the uuid of the bedrock player
|
||||
* @return a completable future with the {@link LinkedPlayer}.
|
||||
* The future will have a null value if that Bedrock player isn't linked
|
||||
* @return a completable future with the {@link LinkedPlayer}. The future will have a null value
|
||||
* if that Bedrock player isn't linked
|
||||
*/
|
||||
CompletableFuture<LinkedPlayer> getLinkedPlayer(UUID bedrockId);
|
||||
|
||||
@@ -80,10 +78,9 @@ public interface PlayerLink {
|
||||
CompletableFuture<Void> unlinkPlayer(UUID javaId);
|
||||
|
||||
/**
|
||||
* Return if account linking is enabled.
|
||||
* The difference between enabled and allowed is that 'enabled' still allows already linked
|
||||
* people to join with their linked account while 'allow linking' allows people to link
|
||||
* accounts using the commands.
|
||||
* Return if account linking is enabled. The difference between enabled and allowed is that
|
||||
* 'enabled' still allows already linked people to join with their linked account while 'allow
|
||||
* linking' allows people to link accounts using the commands.
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
@@ -93,10 +90,9 @@ public interface PlayerLink {
|
||||
long getVerifyLinkTimeout();
|
||||
|
||||
/**
|
||||
* Return if account linking is allowed.
|
||||
* The difference between enabled and allowed is that 'enabled' still allows already linked
|
||||
* people to join with their linked account while 'allow linking' allows people to link
|
||||
* accounts using the commands.
|
||||
* Return if account linking is allowed. The difference between enabled and allowed is that
|
||||
* 'enabled' still allows already linked people to join with their linked account while 'allow
|
||||
* linking' allows people to link accounts using the commands.
|
||||
*/
|
||||
boolean isAllowLinking();
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ public interface FloodgateLogger {
|
||||
*/
|
||||
void info(String message, Object... args);
|
||||
|
||||
void translatedInfo(String message, Object... args);
|
||||
|
||||
/**
|
||||
* Logs a debug message to the console, with 0 or more arguments.
|
||||
*
|
||||
@@ -83,9 +85,8 @@ public interface FloodgateLogger {
|
||||
void enableDebug();
|
||||
|
||||
/**
|
||||
* Disables debug mode for the Floodgate logger.
|
||||
* Debug messages can still be sent after running this method,
|
||||
* but they will be hidden from the console.
|
||||
* Disables debug mode for the Floodgate logger. Debug messages can still be sent after running
|
||||
* this method, but they will be hidden from the console.
|
||||
*/
|
||||
void disableDebug();
|
||||
}
|
||||
|
||||
@@ -25,35 +25,36 @@
|
||||
|
||||
package org.geysermc.floodgate.api.player;
|
||||
|
||||
import org.geysermc.floodgate.util.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
import org.geysermc.floodgate.util.InputMode;
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
import org.geysermc.floodgate.util.RawSkin;
|
||||
import org.geysermc.floodgate.util.UiProfile;
|
||||
|
||||
public interface FloodgatePlayer {
|
||||
/**
|
||||
* Returns the Bedrock username that will be used as username on the server.
|
||||
* This includes replace spaces (if enabled), username shortened and prefix appended.<br>
|
||||
* Note that this field is not used when the player is a {@link LinkedPlayer LinkedPlayer}
|
||||
* Returns the Bedrock username that will be used as username on the server. This includes
|
||||
* replace spaces (if enabled), username shortened and prefix appended.<br> Note that this field
|
||||
* is not used when the player is a {@link LinkedPlayer LinkedPlayer}
|
||||
*/
|
||||
String getJavaUsername();
|
||||
|
||||
/**
|
||||
* Returns the uuid that will be used as UUID on the server.<br>
|
||||
* Note that this field is not used when the player is a {@link LinkedPlayer LinkedPlayer}
|
||||
* Returns the uuid that will be used as UUID on the server.<br> Note that this field is not
|
||||
* used when the player is a {@link LinkedPlayer LinkedPlayer}
|
||||
*/
|
||||
UUID getJavaUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the uuid that the server will use as uuid of that player.
|
||||
* Will return {@link #getJavaUniqueId()} when not linked or
|
||||
* {@link LinkedPlayer#getJavaUniqueId()} when linked.
|
||||
* Returns the uuid that the server will use as uuid of that player. Will return {@link
|
||||
* #getJavaUniqueId()} when not linked or {@link LinkedPlayer#getJavaUniqueId()} when linked.
|
||||
*/
|
||||
UUID getCorrectUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the username the server will as username for that player.
|
||||
* Will return {@link #getJavaUsername()} when not linked or
|
||||
* {@link LinkedPlayer#getJavaUsername()} when linked.
|
||||
* Returns the username the server will as username for that player. Will return {@link
|
||||
* #getJavaUsername()} when not linked or {@link LinkedPlayer#getJavaUsername()} when linked.
|
||||
*/
|
||||
String getCorrectUsername();
|
||||
|
||||
@@ -63,9 +64,8 @@ public interface FloodgatePlayer {
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the real username of the Bedrock client.
|
||||
* This username doesn't have a prefix, spaces aren't replaced and the username hasn't been
|
||||
* shortened.
|
||||
* Returns the real username of the Bedrock client. This username doesn't have a prefix, spaces
|
||||
* aren't replaced and the username hasn't been shortened.
|
||||
*/
|
||||
String getUsername();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user