mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-19 14:59:20 +00:00
Added a SkinApplyEvent that can cancel/edit the to be applied skin
This commit is contained in:
@@ -30,6 +30,7 @@ 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.event.FloodgateEventBus;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.api.unsafe.Unsafe;
|
||||
@@ -148,6 +149,10 @@ public interface FloodgateApi {
|
||||
*/
|
||||
CompletableFuture<String> getGamertagFor(long xuid);
|
||||
|
||||
default FloodgateEventBus getEventBus() {
|
||||
return InstanceHolder.getEventBus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance that manages all the linking.
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@ package org.geysermc.floodgate.api;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import org.geysermc.floodgate.api.event.FloodgateEventBus;
|
||||
import org.geysermc.floodgate.api.handshake.HandshakeHandlers;
|
||||
import org.geysermc.floodgate.api.inject.PlatformInjector;
|
||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||
@@ -35,6 +36,7 @@ import org.geysermc.floodgate.api.packet.PacketHandlers;
|
||||
public final class InstanceHolder {
|
||||
@Getter private static FloodgateApi api;
|
||||
@Getter private static PlayerLink playerLink;
|
||||
@Getter private static FloodgateEventBus eventBus;
|
||||
|
||||
@Getter private static PlatformInjector injector;
|
||||
@Getter private static PacketHandlers packetHandlers;
|
||||
@@ -44,11 +46,12 @@ public final class InstanceHolder {
|
||||
public static boolean set(
|
||||
FloodgateApi floodgateApi,
|
||||
PlayerLink link,
|
||||
FloodgateEventBus floodgateEventBus,
|
||||
PlatformInjector platformInjector,
|
||||
PacketHandlers packetHandlers,
|
||||
HandshakeHandlers handshakeHandlers,
|
||||
UUID key) {
|
||||
|
||||
UUID key
|
||||
) {
|
||||
if (storedKey != null) {
|
||||
if (!storedKey.equals(key)) {
|
||||
return false;
|
||||
@@ -59,14 +62,10 @@ public final class InstanceHolder {
|
||||
|
||||
api = floodgateApi;
|
||||
playerLink = link;
|
||||
eventBus = floodgateEventBus;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import org.geysermc.event.bus.EventBus;
|
||||
|
||||
public interface FloodgateEventBus extends EventBus<Object, FloodgateSubscriber<?>> {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.event;
|
||||
|
||||
import org.geysermc.event.subscribe.Subscriber;
|
||||
|
||||
public interface FloodgateSubscriber<T> extends Subscriber<T> {
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.event.skin;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||
import org.geysermc.event.Cancellable;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
/**
|
||||
* An event that's fired when Floodgate receives a player skin. The event will be cancelled by
|
||||
* default when hasSkin is true, as Floodgate by default only applies skins when the player has no
|
||||
* skin applied yet.
|
||||
*/
|
||||
public interface SkinApplyEvent extends Cancellable {
|
||||
/**
|
||||
* Returns the player that will receive the skin.
|
||||
*/
|
||||
@NonNull FloodgatePlayer player();
|
||||
|
||||
/**
|
||||
* Returns the skin texture currently applied to the player.
|
||||
*/
|
||||
@Nullable SkinData currentSkin();
|
||||
|
||||
/**
|
||||
* Returns the skin texture to be applied to the player.
|
||||
*/
|
||||
@NonNull SkinData newSkin();
|
||||
|
||||
/**
|
||||
* Sets the skin texture to be applied to the player
|
||||
*
|
||||
* @param skinData the skin to apply
|
||||
* @return this
|
||||
*/
|
||||
@This SkinApplyEvent newSkin(@NonNull SkinData skinData);
|
||||
|
||||
interface SkinData {
|
||||
/**
|
||||
* Returns the value of the skin texture.
|
||||
*/
|
||||
@NonNull String value();
|
||||
|
||||
/**
|
||||
* Returns the signature of the skin texture.
|
||||
*/
|
||||
@NonNull String signature();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user