Geyser/api/src/main/java/org/geysermc/geyser/api/event/bedrock/SessionSkinApplyEvent.java

145 lines
4.2 KiB
Java
Raw Normal View History

2024-03-17 17:50:39 +00:00
/*
* Copyright (c) 2019-2024 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/Geyser
*/
2024-03-19 20:27:30 +00:00
package org.geysermc.geyser.api.event.bedrock;
2024-03-17 17:50:39 +00:00
import org.checkerframework.checker.nullness.qual.NonNull;
2024-03-19 20:27:30 +00:00
import org.geysermc.geyser.api.connection.GeyserConnection;
import org.geysermc.geyser.api.event.connection.ConnectionEvent;
2024-03-17 17:50:39 +00:00
import org.geysermc.geyser.api.skin.Cape;
import org.geysermc.geyser.api.skin.Skin;
import org.geysermc.geyser.api.skin.SkinData;
import org.geysermc.geyser.api.skin.SkinGeometry;
import java.util.UUID;
2024-03-18 09:00:28 +00:00
/**
* Called when a skin is applied to a player.
* <p>
* Won't be called when a fake player is spawned for a player skull.
*/
2024-03-19 20:27:30 +00:00
public abstract class SessionSkinApplyEvent extends ConnectionEvent {
2024-03-17 17:50:39 +00:00
private final String username;
private final UUID uuid;
private final boolean slim;
2024-04-25 15:30:32 +00:00
private final boolean bedrock;
2024-04-26 23:07:49 +00:00
private final SkinData originalSkinData;
2024-03-17 17:50:39 +00:00
2024-04-25 15:30:32 +00:00
public SessionSkinApplyEvent(@NonNull GeyserConnection connection, String username, UUID uuid, boolean slim, boolean bedrock, SkinData skinData) {
2024-03-19 20:27:30 +00:00
super(connection);
2024-03-17 17:50:39 +00:00
this.username = username;
this.uuid = uuid;
this.slim = slim;
2024-04-25 15:30:32 +00:00
this.bedrock = bedrock;
2024-04-26 23:07:49 +00:00
this.originalSkinData = skinData;
2024-03-17 17:50:39 +00:00
}
2024-04-25 15:30:32 +00:00
/**
* The username of the player.
*
* @return the username of the player
*/
2024-03-17 17:50:39 +00:00
public String username() {
return username;
}
2024-04-25 15:30:32 +00:00
/**
* The UUID of the player.
*
* @return the UUID of the player
*/
2024-03-17 17:50:39 +00:00
public UUID uuid() {
return uuid;
}
2024-04-25 15:30:32 +00:00
/**
* If the player is using a slim model.
*
* @return if the player is using a slim model
*/
2024-03-17 17:50:39 +00:00
public boolean slim() {
return slim;
}
2024-04-25 15:30:32 +00:00
/**
2024-04-25 15:34:03 +00:00
* If the player is a Bedrock player.
2024-04-25 15:30:32 +00:00
*
2024-04-25 15:34:03 +00:00
* @return if the player is a Bedrock player
2024-04-25 15:30:32 +00:00
*/
public boolean bedrock() {
return bedrock;
2024-03-17 17:50:39 +00:00
}
2024-04-26 23:07:49 +00:00
/**
* The original skin data of the player.
*
* @return the original skin data of the player
*/
public SkinData originalSkin() {
return originalSkinData;
}
2024-04-25 15:30:32 +00:00
/**
* The skin data of the player.
*
* @return the skin data of the player
*/
2024-04-26 23:07:49 +00:00
public abstract SkinData skinData();
2024-03-17 17:50:39 +00:00
2024-04-25 15:30:32 +00:00
/**
* Change the skin of the player.
*
* @param newSkin the new skin
*/
2024-03-17 17:50:39 +00:00
public abstract void skin(@NonNull Skin newSkin);
2024-04-25 15:30:32 +00:00
/**
* Change the cape of the player.
*
* @param newCape the new cape
*/
2024-03-17 17:50:39 +00:00
public abstract void cape(@NonNull Cape newCape);
2024-04-25 15:30:32 +00:00
/**
* Change the geometry of the player.
*
* @param newGeometry the new geometry
*/
2024-03-17 17:50:39 +00:00
public abstract void geometry(@NonNull SkinGeometry newGeometry);
2024-04-25 15:30:32 +00:00
/**
* Change the geometry of the player.
* <p>
* Constructs a generic {@link SkinGeometry} object with the given data.
*
* @param geometryName the name of the geometry
* @param geometryData the data of the geometry
*/
2024-03-17 17:50:39 +00:00
public void geometry(@NonNull String geometryName, @NonNull String geometryData) {
geometry(new SkinGeometry("{\"geometry\" :{\"default\" :\"" + geometryName + "\"}}", geometryData));
}
}