### Setup Default DisguiseAPI Provider (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Demonstrates how to obtain the default DisguiseProvider instance, which includes built-in registration for basic disguise functionality. This method simplifies integration by using the pre-configured default system.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
public void setupDefaultProvider() {
// Get default provider with built-in registration
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
// Or explicitly create with default registration
DisguiseProvider provider2 = DisguiseAPI.createProvider(
DisguiseAPI.getRegistrySystem().DEFAULT_REGISTRATION
);
// Both approaches give you basic disguise functionality
}
```
--------------------------------
### API Availability Check
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Code example to verify if DisguiseAPI is loaded and enabled before attempting to use its features.
```APIDOC
## Verify API Availability
### Description
Ensure DisguiseAPI is active in the server before calling its methods to prevent runtime errors.
### Code Example
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
private DisguiseProvider provider;
@Override
public void onEnable() {
// Check if DisguiseAPI is enabled
if (!DisguiseAPI.isEnabled()) {
getLogger().severe("FAILED TO FIND DISGUISE API!");
getPluginLoader().disablePlugin(this);
return;
}
// Get the default provider for skin changes
this.provider = DisguiseAPI.getDefaultProvider();
getLogger().info("DisguiseAPI successfully loaded!");
}
}
```
```
--------------------------------
### Install DisguiseAPI using Git and Maven
Source: https://github.com/itspinger/disguiseapi/wiki/Getting-Started
Steps to clone the DisguiseAPI repository from GitHub and build it locally using Maven. This process ensures the library is available for use in your projects.
```shell
git clone https://github.com/ITSPINGER/DisguiseAPI.git
cd DisguiseAPI
mvn clean install
```
--------------------------------
### Check DisguiseAPI Provider in Java
Source: https://github.com/itspinger/disguiseapi/wiki/Getting-Started
An example of how to check for the availability of the DisguiseAPI provider in the `onEnable` method of a Java plugin. If the provider is null, it indicates an incompatibility or missing core functionality, leading to plugin disabling.
```java
@Override
public void onEnable() {
// This might happen with new versions
// Or with versions older than 1.8
// And the plugin will not have it's core functionality
// So it is advised to disable it
if (DisguiseAPI.getProvider() == null) {
getLogger().info("Failed to find the provider for this version");
getLogger().info("Disabling...");
// Disable the plugin
this.getPluginLoader().disablePlugin(this);
return;
}
}
```
--------------------------------
### Update Player Skin with DisguiseAPI
Source: https://github.com/itspinger/disguiseapi/wiki/ChangingSkinsExplained
This Java method demonstrates how to update a player's skin using the DisguiseAPI's PacketProvider. It first updates the player's properties and then sends packets to refresh the player for all clients. Ensure DisguiseAPI and necessary Bukkit/DisguiseAPI classes are imported.
```java
private void setSkin(Player player, Skin skin) {
// Get the packet provider
PacketProvider provider = DisguiseAPI.getProvider();
// Using the provider first update the properties
// And then send the packets to refresh the player
provider.updateProperties(player, skin);
provider.sendServerPackets(player);
}
```
--------------------------------
### Verify DisguiseAPI Availability in Plugin
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Check if DisguiseAPI is enabled upon your plugin's startup to prevent NullPointerExceptions when accessing its features. This Java code snippet demonstrates how to safely initialize the API provider.
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.plugin.java.JavaPlugin;
public class MyPlugin extends JavaPlugin {
private DisguiseProvider provider;
@Override
public void onEnable() {
// Check if DisguiseAPI is enabled
if (!DisguiseAPI.isEnabled()) {
getLogger().severe("FAILED TO FIND DISGUISE API!");
getLogger().severe("FAILED TO FIND DISGUISE API!");
getLogger().severe("FAILED TO FIND DISGUISE API!");
getPluginLoader().disablePlugin(this);
return;
}
// Get the default provider for skin changes
this.provider = DisguiseAPI.getDefaultProvider();
getLogger().info("DisguiseAPI successfully loaded!");
}
}
```
--------------------------------
### Create Player Head Item from Skin (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Illustrates how to create a player head ItemStack with a specific skin texture fetched from Mojang. This is useful for custom inventory items or decorative elements. It handles potential exceptions during skin fetching and item meta modification.
```java
import net.pinger.disguise.skin.Skin;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public ItemStack createCustomHead(String playerName) {
try {
Skin skin = DisguiseAPI.getSkinManager().getFromMojang(playerName);
// Convert skin to skull item
ItemStack skull = skin.toSkull();
// Modify meta if needed
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setDisplayName("ยง6" + playerName + "'s Head");
skull.setItemMeta(meta);
return skull;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
```
--------------------------------
### Configure SkinSetter Plugin Dependency
Source: https://github.com/itspinger/disguiseapi/wiki/Getting-Started
Details the necessary configuration in the `plugin.yml` file to declare a dependency on DisguiseAPI for the SkinSetter plugin. This ensures DisguiseAPI is loaded before SkinSetter.
```yaml
main: net.pinger.skinsetter.SkinSetter
version: 1.0
name: SkinSetter
depend: [DisguiseAPI]
api-version: 1.13
```
--------------------------------
### Dependency Integration
Source: https://context7.com/itspinger/disguiseapi/llms.txt
How to add DisguiseAPI as a dependency to your Minecraft plugin project using Maven or Gradle.
```APIDOC
## Dependency Integration
### Description
Integrate DisguiseAPI into your plugin by adding it as a `provided` dependency. The API is supplied at runtime by the DisguiseAPI plugin.
### Maven
```xml
net.pinger.disguise
API
1.4.0
provided
```
### Gradle
```gradle
dependencies {
compileOnly 'net.pinger.disguise:API:1.4.0'
}
```
```
--------------------------------
### Check DisguiseAPI Status and Logging (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Provides a method to verify if DisguiseAPI is enabled and accessible. It demonstrates how to retrieve the API's logger instance for outputting status messages, warnings, and errors.
```java
import net.pinger.disguise.DisguiseAPI;
import org.slf4j.Logger;
public void checkAPIStatus() {
if (DisguiseAPI.isEnabled()) {
Logger logger = DisguiseAPI.getLogger();
logger.info("DisguiseAPI is active and ready!");
// Use logger for debugging
logger.debug("Debug information...");
logger.warn("Warning message...");
logger.error("Error occurred!");
}
}
```
--------------------------------
### Batch Update Player Disguises (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Shows an efficient way to disguise multiple players simultaneously using a single DisguiseProvider instance and fetching the skin only once. It includes error handling for individual player disguise attempts and overall skin fetching failures.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import net.pinger.disguise.skin.Skin;
import org.bukkit.entity.Player;
import java.util.List;
public void disguiseMultiplePlayers(List players, String targetName) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Fetch skin once
Skin skin = DisguiseAPI.getSkinManager().getFromMojang(targetName);
// Apply to all players
for (Player player : players) {
try {
provider.updatePlayer(player, skin, targetName);
player.sendMessage("Disguised as " + targetName);
} catch (Exception e) {
player.sendMessage("Failed to disguise you!");
}
}
} catch (Exception e) {
System.err.println("Failed to fetch skin: " + e.getMessage());
}
}
```
--------------------------------
### Create Skin from Raw Data (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Constructs a Skin object directly from base64-encoded value and signature strings. This method automatically detects the skin model (STEVE or ALEX), profile name, and texture URL. It requires the Skin class from the DisguiseAPI.
```java
import net.pinger.disguise.skin.Skin;
public Skin createSkinFromData(String value, String signature) {
// Create skin with automatic model detection
Skin skin = Skin.of(value, signature);
// Skin.of() automatically decodes and determines:
// - Skin model (STEVE or ALEX)
// - Profile name
// - Texture URL
return skin;
}
```
--------------------------------
### Create Custom DisguiseProvider (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Implements a custom disguise provider by extending DisguiseRegistration to add custom validation logic and event handling for disguise operations. It overrides methods for validating player info, handling updates, and managing resets, ensuring custom behavior in multi-plugin environments. Requires DisguiseAPI, DisguiseProvider, DisguiseRegistration, PlayerUpdateInfo, and ValidationException imports.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import net.pinger.disguise.registration.DisguiseRegistration;
import net.pinger.disguise.player.info.PlayerUpdateInfo;
import net.pinger.disguise.exception.ValidationException;
public class MyCustomRegistration extends DisguiseRegistration {
@Override
public void validatePlayerInfo(PlayerUpdateInfo info) throws ValidationException {
// Custom validation logic
// Check if another plugin is already disguising this player
if (registry.isRegistered(info.getPlayer().getId())) {
throw new ValidationException("Player is already disguised by another plugin!");
}
// Register this player to prevent conflicts
registry.register(this, info.getPlayer().getId());
}
@Override
public void onPlayerUpdateInfo(PlayerUpdateInfo info) {
// Handle player disguise updates
Player player = info.getPlayer().toBukkit();
if (info.hasSkinUpdate()) {
player.sendMessage("Your skin has been updated!");
}
if (info.hasNameUpdate()) {
player.sendMessage("Your name is now: " + info.getNameAction().getName());
}
}
@Override
public void onPlayerResetInfo(PlayerUpdateInfo info) {
// Handle player undisguise
Player player = info.getPlayer().toBukkit();
player.sendMessage("You have been undisguised!");
// Unregister player
registry.unregister(this, info.getPlayer().getId());
}
}
// Usage in plugin
public class MyPlugin extends JavaPlugin {
private DisguiseProvider customProvider;
@Override
public void onEnable() {
MyCustomRegistration registration = new MyCustomRegistration();
this.customProvider = DisguiseAPI.createProvider(registration);
// Now use customProvider for all disguise operations
}
}
```
--------------------------------
### Gradle Dependency for DisguiseAPI
Source: https://github.com/itspinger/disguiseapi/blob/master/README.md
This snippet demonstrates how to add the DisguiseAPI library as a dependency in your Gradle project. It's recommended to use the latest version. The 'compileOnly' configuration is used because the API is expected to be already present in the plugin environment.
```gradle
dependencies {
// No need for compiling it within the jar since it is already included within the plugin
compileOnly 'net.pinger.disguise:API:1.2.0'
}
```
--------------------------------
### Fetch Skin by UUID
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieve a player's skin details from Mojang's API using their unique player identifier (UUID).
```APIDOC
## Fetch Skin from Mojang by UUID
### Description
This method fetches a player's skin data using their unique Minecraft UUID, offering a more reliable lookup than player names.
### Method
`SkinManager.getFromMojang(UUID playerId)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```java
// Example usage within a Java method
import java.util.UUID;
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.skin.Skin;
import net.pinger.disguise.exception.UserNotFoundException;
public void fetchSkinByUUID(UUID playerId) {
try {
Skin skin = DisguiseAPI.getSkinManager().getFromMojang(playerId);
// Decoded value contains JSON with texture URL
String decodedValue = skin.getDecodedValue();
System.out.println("Decoded texture data: " + decodedValue);
// You can also access value, signature, model, and url as shown in the by-name example
} catch (UserNotFoundException e) {
System.err.println("Player UUID not found: " + playerId);
}
}
```
### Response
#### Success Response (200 OK)
- **skin** (Skin) - An object containing the player's skin data.
- **value** (String) - The base64 encoded skin data.
- **signature** (String) - The signature for the skin data.
- **model** (String) - The player model type (e.g., 'classic', 'slim').
- **url** (String) - The URL of the skin texture.
- **decodedValue** (String) - JSON string containing texture details, including the URL.
#### Response Example (Conceptual - object representation)
```json
{
"value": "...base64_encoded_skin_data...",
"signature": "...signature_hash...",
"model": "slim",
"url": "http://textures.minecraft.net/texture/another_texture_id",
"decodedValue": "{\"timestamp\":1678886400000,\"username\":\"SomePlayer\",\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/another_texture_id\"}}}"
}
```
#### Error Response
- **UserNotFoundException**: Thrown if the specified player UUID does not exist.
```
--------------------------------
### Maven Dependency for DisguiseAPI
Source: https://github.com/itspinger/disguiseapi/blob/master/README.md
This snippet shows how to include the DisguiseAPI library as a dependency in your Maven project. Ensure you use the latest version available in the project's pom.xml. The 'provided' scope is recommended as the API is typically included within the plugin.
```xml
net.pinger.disguise
API
1.2.0
provided
```
--------------------------------
### Fetch Skin by Player Name
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieve a player's skin details (value, signature, model, URL) from Mojang's API using their username.
```APIDOC
## Fetch Skin from Mojang by Player Name
### Description
This method fetches a player's current skin data directly from Mojang's official API based on their Minecraft username. It's a synchronous operation.
### Method
`SkinManager.getFromMojang(String playerName)`
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```java
// Example usage within a Java method
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.skin.Skin;
import net.pinger.disguise.skin.SkinManager;
import net.pinger.disguise.exception.UserNotFoundException;
public void fetchPlayerSkin(String playerName) {
SkinManager skinManager = DisguiseAPI.getSkinManager();
try {
Skin skin = skinManager.getFromMojang(playerName);
System.out.println("Skin Value: " + skin.getValue());
System.out.println("Skin Signature: " + skin.getSignature());
System.out.println("Skin Model: " + skin.getModel());
System.out.println("Skin URL: " + skin.getUrl());
// Convert to ItemStack for use in-game
ItemStack skull = skin.toSkull();
} catch (UserNotFoundException e) {
System.err.println("Player not found: " + playerName);
}
}
```
### Response
#### Success Response (200 OK)
- **skin** (Skin) - An object containing the player's skin data.
- **value** (String) - The base64 encoded skin data.
- **signature** (String) - The signature for the skin data.
- **model** (String) - The player model type (e.g., 'classic', 'slim').
- **url** (String) - The URL of the skin texture.
- **decodedValue** (String) - JSON string containing texture details, including the URL.
#### Response Example (Conceptual - object representation)
```json
{
"value": "...base64_encoded_skin_data...",
"signature": "...signature_hash...",
"model": "classic",
"url": "http://textures.minecraft.net/texture/generated_texture_id",
"decodedValue": "{\"timestamp\":1678886400000,\"username\":\"PlayerName\",\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/generated_texture_id\"}}}"
}
```
#### Error Response
- **UserNotFoundException**: Thrown if the specified player name does not exist.
```
--------------------------------
### Add DisguiseAPI Dependency for Maven
Source: https://github.com/itspinger/disguiseapi/wiki/Getting-Started
Specifies the Maven dependency configuration required to include the DisguiseAPI in your project. The scope is set to 'provided' as it's assumed to be available within the plugin environment.
```xml
net.pinger.disguise
API
1.0-SNAPSHOT
provided
```
--------------------------------
### Fetch Player Skin from Mojang by Name
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieve a player's skin details (value, signature, model, URL) from Mojang's API using their username. This is a synchronous Java operation. Handles UserNotFoundException if the player does not exist.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.skin.Skin;
import net.pinger.disguise.skin.SkinManager;
import net.pinger.disguise.exception.UserNotFoundException;
public void fetchPlayerSkin(String playerName) {
SkinManager skinManager = DisguiseAPI.getSkinManager();
try {
// Fetch skin from Mojang by player name
Skin skin = skinManager.getFromMojang(playerName);
// Skin contains value and signature
System.out.println("Skin Value: " + skin.getValue());
System.out.println("Skin Signature: " + skin.getSignature());
System.out.println("Skin Model: " + skin.getModel());
System.out.println("Skin URL: " + skin.getUrl());
// Can convert skin to skull item
ItemStack skull = skin.toSkull();
} catch (UserNotFoundException e) {
System.err.println("Player not found: " + playerName);
}
}
```
--------------------------------
### Add DisguiseAPI Dependency for Gradle
Source: https://github.com/itspinger/disguiseapi/wiki/Getting-Started
Provides the Gradle dependency declaration for integrating DisguiseAPI into your project. Similar to Maven, the dependency is marked for compile-only usage.
```gradle
dependencies {
compileOnly 'net.pinger.disguise:API:1.0-SNAPSHOT'
}
```
--------------------------------
### Add DisguiseAPI Dependency to Maven Project
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Add DisguiseAPI as a Maven dependency to your Minecraft plugin project. The API will be provided at runtime by the DisguiseAPI plugin. Ensure 'provided' scope is used.
```xml
net.pinger.disguise
API
1.4.0
provided
```
--------------------------------
### Generate Skin from Custom Image URL (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Creates a custom skin from a provided image URL using the MineSkin API. This is an asynchronous operation. It requires the DisguiseAPI and Skin classes. The input is a String representing the image URL, and the output is a Skin object upon success, or an error message.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.response.Response;
import net.pinger.disguise.skin.Skin;
public void createCustomSkin(String imageUrl) {
DisguiseAPI.getSkinManager().getFromImage(imageUrl, response -> {
if (response.success()) {
Skin customSkin = response.getData();
System.out.println("Custom skin created successfully!");
System.out.println("Value: " + customSkin.getValue());
System.out.println("Signature: " + customSkin.getSignature());
// Use the skin for disguising players
// ...
} else {
System.err.println("Failed to create custom skin: " + response.getType());
}
});
}
```
--------------------------------
### Reset Player to Original Appearance (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Restores a player to their original skin and name. This operation utilizes the DisguiseAPI and DisguiseProvider. It takes a Player object as input and resets their appearance to the default state, triggering relevant events.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import org.bukkit.entity.Player;
public void undisguisePlayer(Player player) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Reset both skin and name to original
provider.resetPlayer(player);
player.sendMessage("You have been undisguised!");
} catch (Exception e) {
player.sendMessage("Failed to reset appearance: " + e.getMessage());
}
}
```
--------------------------------
### Update Both Skin and Name (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Transforms a player's complete appearance by changing both their skin and name simultaneously. This method requires DisguiseAPI, DisguiseProvider, and Skin. It fetches the skin from Mojang based on the disguise name and then updates the player's appearance.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import net.pinger.disguise.skin.Skin;
import org.bukkit.entity.Player;
public void disguisePlayer(Player player, String disguiseName) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Fetch skin for the target player
Skin skin = DisguiseAPI.getSkinManager().getFromMojang(disguiseName);
// Update both skin and name
provider.updatePlayer(player, skin, disguiseName);
player.sendMessage("You are now disguised as " + disguiseName);
} catch (Exception e) {
player.sendMessage("Failed to disguise: " + e.getMessage());
}
}
```
--------------------------------
### Custom Registration System
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Implement a custom registration system for disguise operations, allowing for custom validation and event handling in multi-plugin environments. This enhances control over disguise actions and prevents conflicts.
```APIDOC
## Custom Registration System
### Create Custom DisguiseProvider
### Description
Implement custom validation and event handling for disguise operations in multi-plugin environments.
### Method
This involves extending the `DisguiseRegistration` class and creating a custom `DisguiseProvider`.
### Endpoint
N/A (Class Implementation and Provider Creation)
### Parameters
* **PlayerUpdateInfo** (Object) - Contains information about player updates, including skin and name changes.
* **ValidationException** (Exception) - Custom exception for validation failures.
### Request Example (Implementing Custom Registration)
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import net.pinger.disguise.registration.DisguiseRegistration;
import net.pinger.disguise.player.info.PlayerUpdateInfo;
import net.pinger.disguise.exception.ValidationException;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Player;
public class MyCustomRegistration extends DisguiseRegistration {
@Override
public void validatePlayerInfo(PlayerUpdateInfo info) throws ValidationException {
// Custom validation logic
if (registry.isRegistered(info.getPlayer().getId())) {
throw new ValidationException("Player is already disguised by another plugin!");
}
registry.register(this, info.getPlayer().getId());
}
@Override
public void onPlayerUpdateInfo(PlayerUpdateInfo info) {
Player player = info.getPlayer().toBukkit();
if (info.hasSkinUpdate()) {
player.sendMessage("Your skin has been updated!");
}
if (info.hasNameUpdate()) {
player.sendMessage("Your name is now: " + info.getNameAction().getName());
}
}
@Override
public void onPlayerResetInfo(PlayerUpdateInfo info) {
Player player = info.getPlayer().toBukkit();
player.sendMessage("You have been undisguised!");
registry.unregister(this, info.getPlayer().getId());
}
}
// Usage in plugin
public class MyPlugin extends JavaPlugin {
private DisguiseProvider customProvider;
@Override
public void onEnable() {
MyCustomRegistration registration = new MyCustomRegistration();
this.customProvider = DisguiseAPI.createProvider(registration);
// Use customProvider for all disguise operations
}
}
```
### Response
#### Success Response
Upon successful creation, a `DisguiseProvider` instance is returned, which can then be used for disguise operations.
* **DisguiseProvider** (Object) - The custom disguise provider instance.
#### Response Example
N/A (This is a code-based setup, not a direct API response)
```
--------------------------------
### Access DisguisePlayer Information (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieves comprehensive disguise data for a player, including their default and current skins, and name. It allows checking if a player is currently disguised and converts the DisguisePlayer object back to a Bukkit Player. Requires Player, DisguiseAPI, DisguisePlayer, and Skin imports.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguisePlayer;
import net.pinger.disguise.skin.Skin;
import org.bukkit.entity.Player;
public void getPlayerInfo(Player player) {
DisguisePlayer dPlayer = DisguiseAPI.getDisguisePlayer(player);
// Get default information
String defaultName = dPlayer.getDefaultName();
Skin defaultSkin = dPlayer.getDefaultSkin();
// Get current skin (may be null if not disguised)
Skin currentSkin = dPlayer.getCurrentSkin();
// Check if player is disguised
if (currentSkin != null && !currentSkin.equals(defaultSkin)) {
player.sendMessage("You are currently disguised!");
player.sendMessage("Original name: " + defaultName);
} else {
player.sendMessage("You are not disguised.");
}
// Convert back to Bukkit player if needed
Player bukkitPlayer = dPlayer.toBukkit();
}
```
--------------------------------
### Fetch Skin from Mojang Profile (Java)
Source: https://github.com/itspinger/disguiseapi/wiki/RetrievingSkinsExplained
Retrieves a player's skin synchronously from Mojang's services using either their username or UUID. This method throws a UserNotFoundException if the user is not found and may return null for other errors like IOException.
```java
Skin skinFromName = DisguiseAPI.getSkinManager().getFromMojang("Tylarzz");
Skin skinFromUuid = DisguiseAPI.getSkinManager().getFromMojang(someUuid);
```
--------------------------------
### Fetch Player Skin from Mojang by UUID
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieve a player's skin using their unique identifier (UUID) for more reliable lookups from Mojang's API. This Java function retrieves the decoded texture data and handles potential UserNotFoundException.
```java
import java.util.UUID;
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.skin.Skin;
import net.pinger.disguise.exception.UserNotFoundException;
public void fetchSkinByUUID(UUID playerId) {
try {
Skin skin = DisguiseAPI.getSkinManager().getFromMojang(playerId);
// Decoded value contains JSON with texture URL
String decodedValue = skin.getDecodedValue();
System.out.println("Decoded texture data: " + decodedValue);
} catch (UserNotFoundException e) {
System.err.println("Player UUID not found: " + playerId);
}
}
```
--------------------------------
### Fetch Skin from Image URL (Java)
Source: https://github.com/itspinger/disguiseapi/wiki/RetrievingSkinsExplained
Retrieves a player skin from a given image URL asynchronously using the Mineskin service. This method returns a Response object which contains the Skin data or an error. The success of the operation is checked via response.success(), and successful responses are cached.
```java
String skinUrl = "https://imgur.com//someLink";
// Using the SkinManager
// Try to get the skin from the url
DisguiseAPI.getSkinManager().getFromImage(skinUrl, response -> {
// Check if the response failed
if (!response.success()) {
// Do something here
// If the request was unsuccessful
return;
}
this.skin = response.get();
});
```
--------------------------------
### Find DisguisePlayer by UUID (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Looks up a DisguisePlayer object using their UUID, which is useful for offline or cached player data. It returns the DisguisePlayer object if found, or null otherwise. Requires DisguiseAPI, DisguisePlayer, and UUID imports.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguisePlayer;
import java.util.UUID;
public DisguisePlayer findPlayer(UUID playerId) {
// Returns null if player is not online/cached
DisguisePlayer dPlayer = DisguiseAPI.getDisguisePlayer(playerId);
if (dPlayer != null) {
System.out.println("Found player: " + dPlayer.getDefaultName());
System.out.println("Player UUID: " + dPlayer.getId());
return dPlayer;
}
return null;
}
```
--------------------------------
### Reset Player Skin
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Restores a player's original skin while retaining any name changes. This is useful for scenarios where only the visual appearance needs to be reverted.
```APIDOC
## Reset Player Skin Only
### Description
Restores only the player's original skin while keeping any name changes.
### Method
This is a conceptual operation, typically implemented via a method call in the DisguiseAPI.
### Endpoint
N/A (Method Call)
### Parameters
* **player** (Player) - Required - The player whose skin needs to be reset.
### Request Example
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.entity.Player;
public void resetSkinOnly(Player player) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
provider.resetPlayerSkin(player);
}
```
### Response
#### Success Response
This operation does not return a value directly but modifies the player's state.
#### Response Example
N/A
```
--------------------------------
### Access DisguisePlayer Data
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Retrieves extended player information, including their default and current skin and name details. This allows for introspection of a player's disguise status.
```APIDOC
## DisguisePlayer Information
### Access DisguisePlayer Data
### Description
Retrieve extended player information including default and current skins.
### Method
This is a conceptual operation, typically implemented via a method call in the DisguiseAPI.
### Endpoint
N/A (Method Call)
### Parameters
* **player** (Player) - Required - The player whose disguise information is to be retrieved.
### Request Example
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguisePlayer;
import net.pinger.disguise.skin.Skin;
import org.bukkit.entity.Player;
public void getPlayerInfo(Player player) {
DisguisePlayer dPlayer = DisguiseAPI.getDisguisePlayer(player);
String defaultName = dPlayer.getDefaultName();
Skin defaultSkin = dPlayer.getDefaultSkin();
Skin currentSkin = dPlayer.getCurrentSkin();
if (currentSkin != null && !currentSkin.equals(defaultSkin)) {
player.sendMessage("You are currently disguised!");
player.sendMessage("Original name: " + defaultName);
} else {
player.sendMessage("You are not disguised.");
}
Player bukkitPlayer = dPlayer.toBukkit();
}
```
### Response
#### Success Response (200)
Returns a `DisguisePlayer` object containing the player's disguise information.
* **defaultName** (String) - The player's original name.
* **defaultSkin** (Skin) - The player's original skin details.
* **currentSkin** (Skin) - The player's current skin details (null if not disguised).
#### Response Example
```json
{
"defaultName": "OriginalPlayerName",
"defaultSkin": {
"uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"name": "OriginalPlayerName",
"timestamp": 1678886400000,
"value": "...skin_value...",
"signature": "...skin_signature..."
},
"currentSkin": {
"uuid": "f0e9d8c7-b6a5-4321-0987-654321fedcba",
"name": "DisguisedName",
"timestamp": 1678886500000,
"value": "...disguised_skin_value...",
"signature": "...disguised_skin_signature..."
}
}
```
```
--------------------------------
### Update Player Skin Silently (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Changes a player's skin without triggering registration events. This method requires DisguiseAPI, DisguisePlayer, and DisguiseProvider. It takes a Player object and a Skin object as input and updates the player's appearance silently.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguisePlayer;
public void changeSkinSilently(Player player, Skin skin) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
DisguisePlayer dPlayer = DisguiseAPI.getDisguisePlayer(player);
// Silent update - no registration events fired
provider.updatePlayerSilently(dPlayer, skin, null);
}
```
--------------------------------
### Update Player Skin Only (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Changes a player's skin while keeping their original name. This operation requires the DisguiseAPI, DisguiseProvider, Skin, and ValidationException classes. It fetches a new skin from Mojang using a target player's name and updates the specified player's skin. This triggers registration events.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguiseProvider;
import net.pinger.disguise.skin.Skin;
import net.pinger.disguise.exception.ValidationException;
import org.bukkit.entity.Player;
public void changePlayerSkin(Player player, String targetPlayerName) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Fetch skin from Mojang
Skin newSkin = DisguiseAPI.getSkinManager().getFromMojang(targetPlayerName);
// Update player's skin (non-silently, triggers events)
provider.updatePlayer(player, newSkin);
player.sendMessage("Your skin has been changed!");
} catch (ValidationException e) {
player.sendMessage("Failed to change skin: " + e.getMessage());
} catch (Exception e) {
player.sendMessage("Error fetching skin: " + e.getMessage());
}
}
```
--------------------------------
### Reset Player Skin Only (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Restores a player's original skin without affecting their current name. This method requires a Player object and uses the DisguiseAPI to isolate skin changes. It catches general exceptions during the process.
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.entity.Player;
public void resetSkinOnly(Player player) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Reset only skin, keep current name
provider.resetPlayerSkin(player);
} catch (Exception e) {
e.printStackTrace();
}
}
```
--------------------------------
### Find DisguisePlayer by UUID
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Looks up a `DisguisePlayer` object using a player's UUID. This is particularly useful for retrieving disguise information for players who are currently offline or have recently logged out.
```APIDOC
## Find DisguisePlayer by UUID
### Description
Look up a DisguisePlayer object using a UUID, useful for offline player lookups.
### Method
This is a conceptual operation, typically implemented via a method call in the DisguiseAPI.
### Endpoint
N/A (Method Call)
### Parameters
* **playerId** (UUID) - Required - The unique identifier of the player.
### Request Example
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.DisguisePlayer;
import java.util.UUID;
public DisguisePlayer findPlayer(UUID playerId) {
DisguisePlayer dPlayer = DisguiseAPI.getDisguisePlayer(playerId);
if (dPlayer != null) {
System.out.println("Found player: " + dPlayer.getDefaultName());
return dPlayer;
}
return null;
}
```
### Response
#### Success Response (200)
Returns a `DisguisePlayer` object if found, otherwise returns null.
* **DisguisePlayer** (Object) - The DisguisePlayer object or null.
#### Response Example
```json
{
"defaultName": "OfflinePlayerName",
"id": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"defaultSkin": {
"uuid": "a1b2c3d4-e5f6-7890-1234-567890abcdef",
"name": "OfflinePlayerName",
"timestamp": 1678886400000,
"value": "...skin_value...",
"signature": "...skin_signature..."
},
"currentSkin": null
}
```
```
--------------------------------
### Reset Player Name
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Restores a player's original name while retaining any skin changes. This is useful for scenarios where only the player's name needs to be reverted.
```APIDOC
## Reset Player Name Only
### Description
Restores only the player's original name while keeping any skin changes.
### Method
This is a conceptual operation, typically implemented via a method call in the DisguiseAPI.
### Endpoint
N/A (Method Call)
### Parameters
* **player** (Player) - Required - The player whose name needs to be reset.
### Request Example
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.entity.Player;
public void resetNameOnly(Player player) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
provider.resetPlayerName(player);
}
```
### Response
#### Success Response
This operation does not return a value directly but modifies the player's state.
#### Response Example
N/A
```
--------------------------------
### Update Player Name Only (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Modifies a player's display name while preserving their current skin. This operation uses the DisguiseAPI and DisguiseProvider, requiring ValidationException for error handling. The input is the target Player object and the new desired name as a String.
```java
import net.pinger.disguise.DisguiseAPI;
import net.pinger.disguise.exception.ValidationException;
import org.bukkit.entity.Player;
public void changePlayerName(Player player, String newName) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Update only the name
provider.updatePlayer(player, newName);
player.sendMessage("Your name is now: " + newName);
} catch (ValidationException e) {
player.sendMessage("Failed to change name: " + e.getMessage());
}
}
```
--------------------------------
### Reset Player Name Only (Java)
Source: https://context7.com/itspinger/disguiseapi/llms.txt
Restores a player's original name without affecting their current skin. This function takes a Player object and utilizes the DisguiseAPI to revert only the name. It includes basic exception handling.
```java
import net.pinger.disguise.DisguiseAPI;
import org.bukkit.entity.Player;
public void resetNameOnly(Player player) {
DisguiseProvider provider = DisguiseAPI.getDefaultProvider();
try {
// Reset only name, keep current skin
provider.resetPlayerName(player);
} catch (Exception e) {
e.printStackTrace();
}
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.