mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-04 15:31:48 +00:00
Proof-of-concept for Geyser-Floodgate merge
This commit is contained in:
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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 java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.api.unsafe.Unsafe;
|
||||
|
||||
public interface FloodgateApi {
|
||||
/**
|
||||
* Returns the Floodgate API instance.
|
||||
*/
|
||||
static FloodgateApi getInstance() {
|
||||
return InstanceHolder.getApi();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character(s) that will be added in front of a Bedrock player's name to prevent
|
||||
* username duplicates.
|
||||
*/
|
||||
String getPlayerPrefix();
|
||||
|
||||
/**
|
||||
* Returns all the online Floodgate players.
|
||||
*/
|
||||
Collection<FloodgatePlayer> getPlayers();
|
||||
|
||||
/**
|
||||
* Returns the number of Floodgate players who are currently online.
|
||||
*/
|
||||
int getPlayerCount();
|
||||
|
||||
/**
|
||||
* 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 isFloodgatePlayer(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 #isFloodgatePlayer(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);
|
||||
|
||||
boolean sendForm(UUID uuid, Form form);
|
||||
|
||||
boolean sendForm(UUID uuid, FormBuilder<?, ?, ?> formBuilder);
|
||||
|
||||
/**
|
||||
* @deprecated since Cumulus 1.1 and will be removed when Cumulus 2.0 releases. Please use the
|
||||
* new form classes instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean sendForm(UUID uuid, org.geysermc.cumulus.Form<?> form);
|
||||
|
||||
/**
|
||||
* @deprecated since Cumulus 1.1 and will be removed when Cumulus 2.0 releases. Please use the
|
||||
* new form classes instead.
|
||||
*/
|
||||
@Deprecated
|
||||
boolean sendForm(UUID uuid, org.geysermc.cumulus.util.FormBuilder<?, ?> formBuilder);
|
||||
|
||||
boolean transferPlayer(UUID uuid, String address, int port);
|
||||
|
||||
/**
|
||||
* Get the xuid of the user that has the given gamertag.
|
||||
*
|
||||
* @param gamertag the gamertag of the player
|
||||
* @return the xuid of the player with the given gamertag, or null when there is no player with
|
||||
* the given gamertag
|
||||
*/
|
||||
CompletableFuture<Long> getXuidFor(String gamertag);
|
||||
|
||||
/**
|
||||
* Get the xuid of the player that has the given gamertag. It does the same thing as
|
||||
* {@link #getXuidFor(String)} except that this method will return the xuid in Floodgate uuid
|
||||
* format instead of just a long
|
||||
*
|
||||
* @param gamertag the gamertag of the player
|
||||
* @return the xuid of the player with the given gamertag, or null when there is no player with
|
||||
* the given gamertag
|
||||
*/
|
||||
default CompletableFuture<UUID> getUuidFor(String gamertag) {
|
||||
return getXuidFor(gamertag).thenApply(xuid -> {
|
||||
if (xuid == null) {
|
||||
return null;
|
||||
}
|
||||
return createJavaPlayerId(xuid);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the gamertag of the user that has the given xuid.
|
||||
*
|
||||
* @param xuid the gamertag of the player
|
||||
* @return the gamertag of the player with the given xuid, or null when there is not player with
|
||||
* the given xuid
|
||||
*/
|
||||
CompletableFuture<String> getGamertagFor(long xuid);
|
||||
|
||||
/**
|
||||
* Returns the instance that manages all the linking.
|
||||
*/
|
||||
default PlayerLink getPlayerLink() {
|
||||
return InstanceHolder.getPlayerLink();
|
||||
}
|
||||
|
||||
Unsafe unsafe();
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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 java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.floodgate.api.handshake.HandshakeHandlers;
|
||||
import org.geysermc.floodgate.api.inject.PlatformInjector;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.packet.PacketHandlers;
|
||||
|
||||
public final class InstanceHolder {
|
||||
@Getter private static FloodgateApi api;
|
||||
@Getter private static PlayerLink playerLink;
|
||||
|
||||
@Getter private static PlatformInjector injector;
|
||||
@Getter private static PacketHandlers packetHandlers;
|
||||
@Getter private static HandshakeHandlers handshakeHandlers;
|
||||
private static UUID storedKey;
|
||||
|
||||
public static boolean set(
|
||||
FloodgateApi floodgateApi,
|
||||
PlayerLink link,
|
||||
PlatformInjector platformInjector,
|
||||
PacketHandlers packetHandlers,
|
||||
HandshakeHandlers handshakeHandlers,
|
||||
UUID key) {
|
||||
|
||||
if (storedKey != null) {
|
||||
if (!storedKey.equals(key)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
storedKey = key;
|
||||
}
|
||||
|
||||
api = floodgateApi;
|
||||
playerLink = link;
|
||||
injector = platformInjector;
|
||||
InstanceHolder.packetHandlers = packetHandlers;
|
||||
InstanceHolder.handshakeHandlers = handshakeHandlers;
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends FloodgateApi> T castApi(Class<T> cast) {
|
||||
return (T) api;
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.handshake;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.util.BedrockData;
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
|
||||
/**
|
||||
* For advanced users only! You shouldn't play with this unless you know what you're doing.<br>
|
||||
* <br>
|
||||
* This class allows you change specific things of a Bedrock player before it is applied to the
|
||||
* server. Note that at the time I'm writing this that the HandshakeData is created after requesting
|
||||
* the player link. So the link is present here, if applicable.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HandshakeData {
|
||||
/**
|
||||
* Returns the Channel holding the connection between the client and the server.
|
||||
*/
|
||||
Channel getChannel();
|
||||
|
||||
/**
|
||||
* Returns true if the given player is a Floodgate player, false otherwise.
|
||||
*/
|
||||
boolean isFloodgatePlayer();
|
||||
|
||||
/**
|
||||
* Returns the decrypted BedrockData sent by Geyser or null if the player isn't a Floodgate
|
||||
* player.
|
||||
*/
|
||||
BedrockData getBedrockData();
|
||||
|
||||
String getJavaUsername();
|
||||
|
||||
String getCorrectUsername();
|
||||
|
||||
UUID getJavaUniqueId();
|
||||
|
||||
UUID getCorrectUniqueId();
|
||||
|
||||
/**
|
||||
* Returns the linked account associated with the client or null if the player isn't linked or
|
||||
* not a Floodgate player.
|
||||
*/
|
||||
LinkedPlayer getLinkedPlayer();
|
||||
|
||||
/**
|
||||
* Set the LinkedPlayer. This will be ignored if the player isn't a Floodgate player
|
||||
*
|
||||
* @param player the player to use as link
|
||||
*/
|
||||
void setLinkedPlayer(LinkedPlayer player);
|
||||
|
||||
/**
|
||||
* Returns the hostname used in the handshake packet. This is the hostname after Floodgate
|
||||
* removed the data.
|
||||
*/
|
||||
String getHostname();
|
||||
|
||||
/**
|
||||
* Set the hostname of the handshake packet. Changing it here will also change it in the
|
||||
* handshake packet.
|
||||
*
|
||||
* @param hostname the new hostname
|
||||
*/
|
||||
void setHostname(String hostname);
|
||||
|
||||
/**
|
||||
* Returns the IP address of the client. The initial value is {@link BedrockData#getIp()} when
|
||||
* BedrockData isn't null, or null if BedrockData is null. This method will return the changed
|
||||
* IP if it has been changed using {@link #setIp(String)}
|
||||
*/
|
||||
String getIp();
|
||||
|
||||
/**
|
||||
* Set the IP address of the connected client. Floodgate doesn't perform any checks if the
|
||||
* provided data is valid (hence one of the reasons why this class has been made for advanced
|
||||
* users), thank you for not abusing Floodgate's trust in you :)
|
||||
*
|
||||
* @param address the IP address of the client
|
||||
*/
|
||||
void setIp(String address);
|
||||
|
||||
/**
|
||||
* Returns the reason to disconnect the current player.
|
||||
*/
|
||||
String getDisconnectReason();
|
||||
|
||||
/**
|
||||
* Set the reason to disconnect the current player.
|
||||
*
|
||||
* @param reason the reason to disconnect
|
||||
*/
|
||||
void setDisconnectReason(String reason);
|
||||
|
||||
/**
|
||||
* Returns if the player should be disconnected
|
||||
*/
|
||||
default boolean shouldDisconnect() {
|
||||
return getDisconnectReason() != null;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.handshake;
|
||||
|
||||
/**
|
||||
* This class allows you to change and/or get specific data of the Bedrock client before Floodgate
|
||||
* does something with this data. This means that Floodgate decrypts the data, then calls the
|
||||
* handshake handlers and then applies the data to the connection.<br>
|
||||
* <br>
|
||||
* /!\ Note that this class will be called for both Java and Bedrock connections, but {@link
|
||||
* HandshakeData#isFloodgatePlayer()} will be false and Floodgate related methods will return null
|
||||
* for Java players
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface HandshakeHandler {
|
||||
/**
|
||||
* Method that will be called during the time that Floodgate handles the handshake.
|
||||
*
|
||||
* @param data the data usable during the handshake
|
||||
*/
|
||||
void handle(HandshakeData data);
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.handshake;
|
||||
|
||||
/**
|
||||
* @deprecated This system has been deprecated and will not be available in the new API that will be
|
||||
* introduced when Geyser will include Floodgate (and thus will have some common base API).
|
||||
* <br>
|
||||
* It might be replaced with an event (probably internal), but that isn't certain yet.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface HandshakeHandlers {
|
||||
/**
|
||||
* Register a custom handshake handler. This can be used to check and edit the player during the
|
||||
* handshake handling.
|
||||
*
|
||||
* @param handshakeHandler the handshake handler to register
|
||||
* @return a random (unique) int to identify this handshake handler or -1 if null
|
||||
*/
|
||||
int addHandshakeHandler(HandshakeHandler handshakeHandler);
|
||||
|
||||
/**
|
||||
* Removes a custom handshake handler by id.
|
||||
*
|
||||
* @param handshakeHandlerId the id of the handshake handler to remove
|
||||
*/
|
||||
void removeHandshakeHandler(int handshakeHandlerId);
|
||||
|
||||
/**
|
||||
* Remove a custom handshake handler by instance.
|
||||
*
|
||||
* @param handshakeHandler the instance to remove
|
||||
*/
|
||||
void removeHandshakeHandler(Class<? extends HandshakeHandler> handshakeHandler);
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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 toServer if the connection is between a proxy and a server
|
||||
*/
|
||||
void onInject(Channel channel, boolean toServer);
|
||||
|
||||
/**
|
||||
* Called when the channel has been closed. Note that this method will be called for every
|
||||
* closed connection (if it is injected), so it'll also run this method for closed connections
|
||||
* between a server and the proxy (when Floodgate is running on a proxy).
|
||||
*
|
||||
* @param channel the channel that the injector injected
|
||||
*/
|
||||
default void onChannelClosed(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();
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.
|
||||
*
|
||||
* @throws Exception if the platform couldn't be injected
|
||||
*/
|
||||
void inject() throws Exception;
|
||||
|
||||
/**
|
||||
* Some platforms may not be able to remove their injection process. If so, this method will
|
||||
* return false.
|
||||
*
|
||||
* @return true if it is safe to attempt to remove our injection performed in {@link #inject()}.
|
||||
*/
|
||||
default boolean canRemoveInjection() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @throws Exception if the platform injection could not be removed
|
||||
*/
|
||||
void 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 removed addon instance
|
||||
*/
|
||||
<T extends InjectorAddon> T removeAddon(Class<T> addon);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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 java.util.UUID;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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;
|
||||
|
||||
/**
|
||||
* This enum has all the available result types of both creating a player link request and
|
||||
* validating it.
|
||||
*/
|
||||
public enum LinkRequestResult {
|
||||
/**
|
||||
* An unknown error encountered while creating / verifying the link request.
|
||||
*/
|
||||
UNKNOWN_ERROR,
|
||||
/**
|
||||
* The specified bedrock username is already linked to a Java account.
|
||||
*/
|
||||
ALREADY_LINKED,
|
||||
/**
|
||||
* The Bedrock player verified the request too late. The request has been expired.
|
||||
*/
|
||||
REQUEST_EXPIRED,
|
||||
/**
|
||||
* The Java player hasn't requested a link to this Bedrock account.
|
||||
*/
|
||||
NO_LINK_REQUESTED,
|
||||
/**
|
||||
* The entered code is invalid.
|
||||
*/
|
||||
INVALID_CODE,
|
||||
/**
|
||||
* The link request has been verified successfully!
|
||||
*/
|
||||
LINK_COMPLETED
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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 java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
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.
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<LinkedPlayer> getLinkedPlayer(@NonNull UUID bedrockId);
|
||||
|
||||
/**
|
||||
* Tells if the given player is a linked player
|
||||
*
|
||||
* @param playerId the uuid of the player to check, can be both a Java or a Bedrock uuid
|
||||
* @return true if the player is a linked player
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<Boolean> isLinkedPlayer(@NonNull UUID playerId);
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<Void> linkPlayer(
|
||||
@NonNull UUID bedrockId,
|
||||
@NonNull UUID javaId,
|
||||
@NonNull 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
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<Void> unlinkPlayer(@NonNull UUID javaId);
|
||||
|
||||
/**
|
||||
* Creates a link request for the given Java player.
|
||||
*
|
||||
* @param javaId the uuid of the Java player
|
||||
* @param javaUsername the username of the Java player
|
||||
* @param bedrockUsername the username of the Bedrock player receiving the link request
|
||||
* @return a future holding the result of the link request which will be a {@link
|
||||
* LinkRequestResult} on failure and the link code (string) on success
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<?> createLinkRequest(
|
||||
@NonNull UUID javaId,
|
||||
@NonNull String javaUsername,
|
||||
@NonNull String bedrockUsername
|
||||
);
|
||||
|
||||
/**
|
||||
* Verifies a link request for the given Bedrock player.
|
||||
*
|
||||
* @param bedrockId the uuid of the Bedrock player
|
||||
* @param javaUsername the username of the Java players who requested the link
|
||||
* @param bedrockUsername the username of the Bedrock player
|
||||
* @param code the code created in {@link #createLinkRequest(UUID, String, String)}
|
||||
* @return a future holding the result of the link verification
|
||||
*/
|
||||
@NonNull
|
||||
CompletableFuture<LinkRequestResult> verifyLinkRequest(
|
||||
@NonNull UUID bedrockId,
|
||||
@NonNull String javaUsername,
|
||||
@NonNull String bedrockUsername,
|
||||
@NonNull String code
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the name of this database implementation. This will return null when Player Linking
|
||||
* is disabled or when <b>only</b> Global Linking is used.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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);
|
||||
|
||||
void translatedInfo(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);
|
||||
|
||||
/**
|
||||
* Returns true if debugging is enabled
|
||||
*/
|
||||
boolean isDebug();
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.packet;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
/**
|
||||
* For advanced users only! You shouldn't play with this unless you know what you're doing.
|
||||
*/
|
||||
public interface PacketHandler {
|
||||
/**
|
||||
* Called when a registered packet has been seen.
|
||||
*
|
||||
* @param ctx the channel handler context of the connection
|
||||
* @param packet the packet instance
|
||||
* @param serverbound if the packet is serverbound
|
||||
* @return the packet it should forward. Can be null or a different packet / instance
|
||||
*/
|
||||
Object handle(ChannelHandlerContext ctx, Object packet, boolean serverbound);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.packet;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import org.geysermc.floodgate.api.util.TriFunction;
|
||||
|
||||
public interface PacketHandlers {
|
||||
/**
|
||||
* Register a specific class for a specific consumer.
|
||||
*
|
||||
* @param handler the packet handler instance
|
||||
* @param packetClass the class to start listening for
|
||||
* @param consumer the consumer to call once the packet has been seen
|
||||
*/
|
||||
void register(
|
||||
PacketHandler handler,
|
||||
Class<?> packetClass,
|
||||
TriFunction<ChannelHandlerContext, Object, Boolean, Object> consumer);
|
||||
|
||||
/**
|
||||
* Register a specific class for the given packet handler's {@link
|
||||
* PacketHandler#handle(ChannelHandlerContext, Object, boolean)}.
|
||||
*
|
||||
* @param handler the packet handler instance
|
||||
* @param packetClass the class to start listening for
|
||||
*/
|
||||
default void register(PacketHandler handler, Class<?> packetClass) {
|
||||
register(handler, packetClass, handler::handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register every packet for the given packet handler's {@link PacketHandler#handle(ChannelHandlerContext,
|
||||
* Object, boolean)}
|
||||
*/
|
||||
void registerAll(PacketHandler handler);
|
||||
|
||||
/**
|
||||
* Unregisters all handlers registered under the given packet handler
|
||||
*
|
||||
* @param handler the packet handler instance
|
||||
*/
|
||||
void deregister(PacketHandler handler);
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.player;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.cumulus.form.Form;
|
||||
import org.geysermc.cumulus.form.util.FormBuilder;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.util.DeviceOs;
|
||||
import org.geysermc.floodgate.util.InputMode;
|
||||
import org.geysermc.floodgate.util.LinkedPlayer;
|
||||
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}
|
||||
*/
|
||||
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. This username doesn't have a prefix, spaces
|
||||
* aren't replaced and the username hasn't been shortened.
|
||||
*/
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* Returns the Xbox Unique Identifier of the Bedrock client
|
||||
*/
|
||||
String getXuid();
|
||||
|
||||
/**
|
||||
* Returns the Operating 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 if the Floodgate player is connected through a proxy
|
||||
*/
|
||||
boolean isFromProxy();
|
||||
|
||||
/**
|
||||
* Returns the LinkedPlayer object if the player is linked to a Java account.
|
||||
*/
|
||||
LinkedPlayer getLinkedPlayer();
|
||||
|
||||
/**
|
||||
* Returns true if the player is linked to a Java account
|
||||
*/
|
||||
boolean isLinked();
|
||||
|
||||
default boolean sendForm(Form form) {
|
||||
return FloodgateApi.getInstance().sendForm(getCorrectUniqueId(), form);
|
||||
}
|
||||
|
||||
default boolean sendForm(FormBuilder<?, ?, ?> formBuilder) {
|
||||
return sendForm(formBuilder.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Cumulus 1.1 and will be removed when Cumulus 2.0 releases. Please use the
|
||||
* new form classes instead.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean sendForm(org.geysermc.cumulus.Form<?> form) {
|
||||
return sendForm(form.newForm());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Cumulus 1.1 and will be removed when Cumulus 2.0 releases. Please use the
|
||||
* new form classes instead.
|
||||
*/
|
||||
@Deprecated
|
||||
default boolean sendForm(org.geysermc.cumulus.util.FormBuilder<?, ?> formBuilder) {
|
||||
return sendForm(formBuilder.build());
|
||||
}
|
||||
|
||||
default boolean transfer(String address, int port) {
|
||||
return FloodgateApi.getInstance().transferPlayer(getCorrectUniqueId(), address, port);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
boolean hasProperty(PropertyKey key);
|
||||
|
||||
@Deprecated
|
||||
boolean hasProperty(String key);
|
||||
|
||||
@Deprecated
|
||||
<T> T getProperty(PropertyKey key);
|
||||
|
||||
@Deprecated
|
||||
<T> T getProperty(String key);
|
||||
|
||||
@Deprecated
|
||||
<T> T removeProperty(PropertyKey key);
|
||||
|
||||
@Deprecated
|
||||
<T> T removeProperty(String key);
|
||||
|
||||
@Deprecated
|
||||
<T> T addProperty(PropertyKey key, Object value);
|
||||
|
||||
@Deprecated
|
||||
<T> T addProperty(String key, Object value);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.player;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@Deprecated
|
||||
public class PropertyKey {
|
||||
/**
|
||||
* Socket Address returns the InetSocketAddress of the Bedrock player
|
||||
*/
|
||||
public static final PropertyKey SOCKET_ADDRESS =
|
||||
new PropertyKey("socket_address", false, false);
|
||||
|
||||
/**
|
||||
* Skin Uploaded returns a SkinData object containing the value and signature of the Skin
|
||||
*/
|
||||
public static final PropertyKey SKIN_UPLOADED =
|
||||
new PropertyKey("skin_uploaded", false, false);
|
||||
|
||||
private final String key;
|
||||
private final boolean changeable;
|
||||
private final boolean removable;
|
||||
|
||||
public PropertyKey(String key, boolean changeable, boolean removable) {
|
||||
this.key = key;
|
||||
this.changeable = changeable;
|
||||
this.removable = removable;
|
||||
}
|
||||
|
||||
public Result isAddAllowed(Object obj) {
|
||||
if (obj instanceof PropertyKey) {
|
||||
PropertyKey propertyKey = (PropertyKey) obj;
|
||||
|
||||
if (key.equals(propertyKey.key)) {
|
||||
if ((propertyKey.changeable == changeable || propertyKey.changeable) &&
|
||||
(propertyKey.removable == removable || propertyKey.removable)) {
|
||||
return Result.ALLOWED;
|
||||
}
|
||||
return Result.INVALID_TAGS;
|
||||
}
|
||||
return Result.NOT_EQUALS;
|
||||
}
|
||||
|
||||
if (obj instanceof String) {
|
||||
if (key.equals(obj)) {
|
||||
if (changeable) {
|
||||
return Result.ALLOWED;
|
||||
}
|
||||
return Result.NOT_ALLOWED;
|
||||
}
|
||||
return Result.INVALID_TAGS;
|
||||
}
|
||||
return Result.NOT_EQUALS;
|
||||
}
|
||||
|
||||
public enum Result {
|
||||
NOT_EQUALS,
|
||||
INVALID_TAGS,
|
||||
NOT_ALLOWED,
|
||||
ALLOWED
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.unsafe;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public interface Unsafe {
|
||||
/**
|
||||
* Send a raw Bedrock packet to the given online Bedrock player.
|
||||
*
|
||||
* @param bedrockPlayer the uuid of the online Bedrock player
|
||||
* @param packetId the id of the packet to send
|
||||
* @param packetData the raw packet data
|
||||
*/
|
||||
void sendPacket(UUID bedrockPlayer, int packetId, byte[] packetData);
|
||||
|
||||
/**
|
||||
* Send a raw Bedrock packet to the given online Bedrock player.
|
||||
*
|
||||
* @param player the Bedrock player to send the packet to
|
||||
* @param packetId the id of the packet to send
|
||||
* @param packetData the raw packet data
|
||||
*/
|
||||
default void sendPacket(FloodgatePlayer player, int packetId, byte[] packetData) {
|
||||
sendPacket(player.getCorrectUniqueId(), packetId, packetData);
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2022 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.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Represents a function that accepts three arguments and produces a result. This is the three-arity
|
||||
* specialization of {@link Function}.
|
||||
*
|
||||
* <p>This is a <a href="package-summary.html">functional interface</a>
|
||||
* whose functional method is {@link #apply(Object, Object, Object)}.
|
||||
*
|
||||
* @param <T> the type of the first argument to the function
|
||||
* @param <U> the type of the second argument to the function
|
||||
* @param <V> the type of the third argument of the function
|
||||
* @param <R> the type of the result of the function
|
||||
* @see Function
|
||||
* @since 1.8
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface TriFunction<T, U, V, R> {
|
||||
/**
|
||||
* Performs this operation on the given arguments.
|
||||
*
|
||||
* @param t the first input argument
|
||||
* @param u the second input argument
|
||||
* @param v the third input argument
|
||||
*/
|
||||
R apply(T t, U u, V v);
|
||||
|
||||
/**
|
||||
* Returns a composed function that first applies this function to its input, and then applies
|
||||
* the {@code after} function to the result. If evaluation of either function throws an
|
||||
* exception, it is relayed to the caller of the composed function.
|
||||
*
|
||||
* @param <S> the type of output of the {@code after} function, and of the composed function
|
||||
* @param after the function to apply after this function is applied
|
||||
* @return a composed function that first applies this function and then applies the {@code
|
||||
* after} function
|
||||
* @throws NullPointerException if after is null
|
||||
*/
|
||||
default <S> TriFunction<T, U, V, S> andThen(Function<? super R, ? extends S> after) {
|
||||
Objects.requireNonNull(after);
|
||||
return (T t, U u, V v) -> after.apply(apply(t, u, v));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user