mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Initial Floodgate 2.0 commit
This commit is contained in:
77
api/pom.xml
Normal file
77
api/pom.xml
Normal file
@@ -0,0 +1,77 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>org.geysermc.floodgate</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>api</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nukkitx-release-repo</id>
|
||||
<url>https://repo.nukkitx.com/maven-releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>nukkitx-snapshot-repo</id>
|
||||
<url>https://repo.nukkitx.com/maven-snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.geysermc</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
<version>${geyser-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport</artifactId>
|
||||
<version>4.1.49.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<finalName>${outputName}</finalName>
|
||||
<shadedArtifactAttached>true</shadedArtifactAttached>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api;
|
||||
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FloodgateApi {
|
||||
/**
|
||||
* Method to determine if the given <b>online</b> player is a bedrock player
|
||||
*
|
||||
* @param uuid The uuid of the <b>online</b> player
|
||||
* @return true if the given <b>online</b> player is a Bedrock player
|
||||
*/
|
||||
boolean isBedrockPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Get info about the given Bedrock player
|
||||
*
|
||||
* @param uuid the uuid of the <b>online</b> Bedrock player
|
||||
* @return FloodgatePlayer if the given uuid is a Bedrock player
|
||||
*/
|
||||
FloodgatePlayer getPlayer(UUID uuid);
|
||||
|
||||
/**
|
||||
* Create a valid Java player uuid of a xuid
|
||||
*
|
||||
* @param xuid the xuid that should be converted
|
||||
* @return the created uuid based of the given xuid
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param uuid the uuid to check
|
||||
* @return true if the given uuid has the correct format.
|
||||
*/
|
||||
boolean isFloodgateId(UUID uuid);
|
||||
|
||||
/**
|
||||
* Returns the instance that manages all the linking.
|
||||
*/
|
||||
default PlayerLink getPlayerLink() {
|
||||
return InstanceHolder.getPlayerLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Floodgate API instance.
|
||||
* This method is equal to running {@link InstanceHolder#getInstance()}
|
||||
*/
|
||||
static FloodgateApi getInstance() {
|
||||
return InstanceHolder.getInstance();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api;
|
||||
|
||||
import lombok.Getter;
|
||||
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;
|
||||
private static UUID key;
|
||||
|
||||
public static boolean setInstance(FloodgateApi floodgateApi, PlayerLink link, UUID key) {
|
||||
if (instance == null) {
|
||||
InstanceHolder.key = key;
|
||||
} else if (!InstanceHolder.key.equals(key)) {
|
||||
return false;
|
||||
}
|
||||
instance = floodgateApi;
|
||||
playerLink = link;
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends FloodgateApi> T castApi(Class<T> cast) {
|
||||
return (T) instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api.inject;
|
||||
|
||||
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.
|
||||
*
|
||||
* @param channel the channel that the injector is injecting
|
||||
* @param proxyToServer if the the connection is between the proxy and a server
|
||||
*/
|
||||
void onInject(Channel channel, boolean proxyToServer);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param channel the channel that the injector injected
|
||||
*/
|
||||
void onRemoveInject(Channel channel);
|
||||
|
||||
/**
|
||||
* If the Injector should call {@link #onInject(Channel, boolean)}
|
||||
*
|
||||
* @return true if it should, false otherwise
|
||||
*/
|
||||
boolean shouldInject();
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
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.
|
||||
*/
|
||||
public interface PlatformInjector {
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @return true if the injection has successfully been removed
|
||||
* @throws Exception if something went wrong while removing the injection
|
||||
*/
|
||||
boolean removeInjection() throws Exception;
|
||||
|
||||
/**
|
||||
* If the server connection is currently injected.
|
||||
*
|
||||
* @return true if the server connection is currently injected, returns false otherwise
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param addon the class of the addon to remove from the addon list
|
||||
* @param <T> the addon type
|
||||
* @return the instance that was present when removing
|
||||
*/
|
||||
<T extends InjectorAddon> T removeAddon(Class<T> addon);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.geysermc.floodgate.api.link;
|
||||
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface LinkRequest {
|
||||
/**
|
||||
* Returns the Java username of the linked player.
|
||||
*/
|
||||
String getJavaUsername();
|
||||
|
||||
/**
|
||||
* Returns the Java unique id of the linked player.
|
||||
*/
|
||||
UUID getJavaUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the code that the Bedrock player has to enter in order to link the account.
|
||||
*/
|
||||
String getLinkCode();
|
||||
|
||||
/**
|
||||
* Returns the username of player being linked.
|
||||
*/
|
||||
String getBedrockUsername();
|
||||
|
||||
/**
|
||||
* Returns the unix time when the player link was requested.
|
||||
*/
|
||||
long getRequestTime();
|
||||
|
||||
/**
|
||||
* If this player link request is expired.
|
||||
*
|
||||
* @param linkTimeout the link timeout in millis
|
||||
* @return true if the difference between now and requestTime is greater then the link timout
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param player the player to check
|
||||
* @return true if the given player is the player requested
|
||||
*/
|
||||
default boolean isRequestedPlayer(FloodgatePlayer player) {
|
||||
return getBedrockUsername().equals(player.getUsername()) ||
|
||||
getBedrockUsername().equals(player.getJavaUsername());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api.link;
|
||||
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
CompletableFuture<LinkedPlayer> getLinkedPlayer(UUID bedrockId);
|
||||
|
||||
/**
|
||||
* Tells if the given player is a linked player
|
||||
*
|
||||
* @param bedrockId the bedrock uuid of the linked player
|
||||
* @return true if the player is a linked player
|
||||
*/
|
||||
CompletableFuture<Boolean> isLinkedPlayer(UUID bedrockId);
|
||||
|
||||
/**
|
||||
* Links a Java account to a Bedrock account.
|
||||
*
|
||||
* @param bedrockId the uuid of the Bedrock player
|
||||
* @param javaId the uuid of the Java player
|
||||
* @param username the username of the Java player
|
||||
* @return a future holding void on success or completed exceptionally when failed
|
||||
*/
|
||||
CompletableFuture<Void> linkPlayer(UUID bedrockId, UUID javaId, String username);
|
||||
|
||||
/**
|
||||
* Unlinks a Java account from a Bedrock account.
|
||||
*
|
||||
* @param javaId the uuid of the Java player
|
||||
* @return a future holding void on success or completed exceptionally when failed
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
boolean isEnabled();
|
||||
|
||||
/**
|
||||
* Returns the duration (in seconds) before a {@link LinkRequest} timeouts
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
boolean isAllowLinking();
|
||||
|
||||
default boolean isEnabledAndAllowed() {
|
||||
return isEnabled() && isAllowLinking();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the Floodgate plugin is going to shutdown
|
||||
*/
|
||||
void stop();
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.api.logger;
|
||||
|
||||
public interface FloodgateLogger {
|
||||
String LOGGER_NAME = "Floodgate";
|
||||
|
||||
/**
|
||||
* Logs an error message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void error(String message, Object... args);
|
||||
|
||||
/**
|
||||
* Logs an error message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param throwable the throwable to log
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void error(String message, Throwable throwable, Object... args);
|
||||
|
||||
/**
|
||||
* Logs a warning message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void warn(String message, Object... args);
|
||||
|
||||
/**
|
||||
* Logs an info message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void info(String message, Object... args);
|
||||
|
||||
/**
|
||||
* Logs a debug message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void debug(String message, Object... args);
|
||||
|
||||
/**
|
||||
* Logs a trace message to the console, with 0 or more arguments.
|
||||
*
|
||||
* @param message the message to log to the console
|
||||
* @param args the arguments to fill the missing spots in the message
|
||||
*/
|
||||
void trace(String message, Object... args);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.geysermc.floodgate.api.player;
|
||||
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
import org.geysermc.floodgate.util.InputMode;
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
import org.geysermc.floodgate.util.UiProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
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}
|
||||
*/
|
||||
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}
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
String getCorrectUsername();
|
||||
|
||||
/**
|
||||
* Returns the version of the Bedrock client
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the real username of the Bedrock client.
|
||||
* No prefix nor shortened nor replaced spaces.
|
||||
*/
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* Returns the Xbox Unique Identifier of the Bedrock client
|
||||
*/
|
||||
String getXuid();
|
||||
|
||||
/**
|
||||
* Returns the Operation System of the Bedrock client
|
||||
*/
|
||||
DeviceOs getDeviceOs();
|
||||
|
||||
/**
|
||||
* Returns the language code of the Bedrock client
|
||||
*/
|
||||
String getLanguageCode();
|
||||
|
||||
/**
|
||||
* Returns the User Interface Profile of the Bedrock client
|
||||
*/
|
||||
UiProfile getUiProfile();
|
||||
|
||||
/**
|
||||
* Returns the Input Mode of the Bedrock client
|
||||
*/
|
||||
InputMode getInputMode();
|
||||
|
||||
/**
|
||||
* Returns the LinkedPlayer object if the player is linked to a Java account.
|
||||
*/
|
||||
LinkedPlayer getLinkedPlayer();
|
||||
|
||||
/**
|
||||
* Casts the FloodgatePlayer instance to a class that extends FloodgatePlayer.
|
||||
*
|
||||
* @param <T> The instance to cast to.
|
||||
* @return The FloodgatePlayer casted to the given class
|
||||
* @throws ClassCastException when it can't cast the instance to the given class
|
||||
*/
|
||||
default <T extends FloodgatePlayer> T as(Class<T> clazz) {
|
||||
return clazz.cast(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user