Developer API
Integrate ClothesPlus into your plugins
Getting Started
Maven Dependency
Add ClothesPlus as a dependency in your pom.xml:
<dependency>
<groupId>org.wardrobeclothes</groupId>
<artifactId>ClothesPlus</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
plugin.yml
Add ClothesPlus as a soft dependency:
softdepend: [ClothesPlus]
API Classes
| Class | Description |
|---|---|
ClothesPlusAPI |
Main entry point for the API |
SkinAPI |
Skin management operations |
OverlayAPI |
Overlay wear/unwear operations |
OutfitAPI |
Outfit save/load operations |
PlayerDataAPI |
Player data and token management |
CacheAPI |
Cache management operations |
Accessing the API
import org.wardrobeclothes.clothes.api.ClothesPlusAPI;
public class MyPlugin extends JavaPlugin {
private ClothesPlusAPI clothesPlusAPI;
@Override
public void onEnable() {
// Check if ClothesPlus is installed
if (getServer().getPluginManager().getPlugin("ClothesPlus") != null) {
clothesPlusAPI = ClothesPlusAPI.getInstance();
getLogger().info("ClothesPlus API hooked successfully!");
} else {
getLogger().warning("ClothesPlus not found!");
}
}
}
SkinAPI
Manage player skins and skin processing:
import org.wardrobeclothes.clothes.api.SkinAPI;
// Get the SkinAPI instance
SkinAPI skinAPI = ClothesPlusAPI.getInstance().getSkinAPI();
// Reset a player's skin to their original Mojang skin
skinAPI.resetToMojangSkin(player);
// Refresh a player's skin display (reapply current overlays)
skinAPI.refreshSkin(player);
// Check if a player has any overlays applied
boolean hasOverlays = skinAPI.hasOverlays(player);
// Get the player's current skin model (STEVE or ALEX)
String model = skinAPI.getPlayerModel(player);
OverlayAPI
Apply and remove clothing overlays:
import org.wardrobeclothes.clothes.api.OverlayAPI;
// Get the OverlayAPI instance
OverlayAPI overlayAPI = ClothesPlusAPI.getInstance().getOverlayAPI();
// Apply an overlay to a player
// Path is relative to plugins/ClothesPlus/overlays/
overlayAPI.wearOverlay(player, "shirts/hoodie");
// Remove a specific overlay
overlayAPI.unwearOverlay(player, "shirts/hoodie");
// Remove all overlays from a player
overlayAPI.unwearAll(player);
// Get all overlays currently worn by a player
List<String> overlays = overlayAPI.getWornOverlays(player);
// Check if player is wearing a specific overlay
boolean isWearing = overlayAPI.isWearing(player, "shirts/hoodie");
// Get available overlays in a category
List<String> shirts = overlayAPI.getOverlaysInCategory("shirts");
OutfitAPI
Manage player outfits:
import org.wardrobeclothes.clothes.api.OutfitAPI;
// Get the OutfitAPI instance
OutfitAPI outfitAPI = ClothesPlusAPI.getInstance().getOutfitAPI();
// Save the player's current overlays as an outfit
outfitAPI.saveOutfit(player, "MyOutfit");
// Load a saved outfit (applies all overlays)
outfitAPI.loadOutfit(player, "MyOutfit");
// Delete a saved outfit
outfitAPI.deleteOutfit(player, "MyOutfit");
// Get all outfit names for a player
List<String> outfits = outfitAPI.getOutfitNames(player);
// Check if an outfit exists
boolean exists = outfitAPI.outfitExists(player, "MyOutfit");
PlayerDataAPI
Access player data and token management:
import org.wardrobeclothes.clothes.api.PlayerDataAPI;
// Get the PlayerDataAPI instance
PlayerDataAPI playerDataAPI = ClothesPlusAPI.getInstance().getPlayerDataAPI();
// Get a player's token count
int tokens = playerDataAPI.getTokens(player);
// Add tokens to a player
playerDataAPI.addTokens(player, 5);
// Remove tokens from a player
playerDataAPI.removeTokens(player, 2);
// Set a player's token count
playerDataAPI.setTokens(player, 10);
// Get maximum outfit slots for a player (based on tokens)
int maxSlots = playerDataAPI.getMaxOutfitSlots(player);
CacheAPI
Manage the plugin's cache systems:
import org.wardrobeclothes.clothes.api.CacheAPI;
// Get the CacheAPI instance
CacheAPI cacheAPI = ClothesPlusAPI.getInstance().getCacheAPI();
// Clear all caches
cacheAPI.clearAll();
// Clear shared cache only
cacheAPI.clearSharedCache();
// Clear creator cache only
cacheAPI.clearCreatorCache();
// Clear base skin cache for a specific player
cacheAPI.clearBaseSkinCache(player);
// Check cache status
boolean sharedEnabled = cacheAPI.isSharedCacheEnabled();
boolean creatorEnabled = cacheAPI.isCreatorCacheEnabled();
boolean baseSkinEnabled = cacheAPI.isBaseSkinCacheEnabled();
Events
Listen for ClothesPlus events in your plugin:
OverlayWearEvent
Called when a player wears an overlay:
import org.wardrobeclothes.clothes.api.events.OverlayWearEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class MyListener implements Listener {
@EventHandler
public void onOverlayWear(OverlayWearEvent event) {
Player player = event.getPlayer();
String overlay = event.getOverlayPath();
// Cancel the event if needed
if (someCondition) {
event.setCancelled(true);
player.sendMessage("You cannot wear this overlay!");
}
// Log the action
getLogger().info(player.getName() + " is wearing: " + overlay);
}
}
OverlayUnwearEvent
Called when a player removes an overlay:
@EventHandler
public void onOverlayUnwear(OverlayUnwearEvent event) {
Player player = event.getPlayer();
String overlay = event.getOverlayPath();
player.sendMessage("You removed: " + overlay);
}
SkinResetEvent
Called when a player's skin is reset:
@EventHandler
public void onSkinReset(SkinResetEvent event) {
Player player = event.getPlayer();
// Optional: prevent reset in certain conditions
if (player.isInCombat()) {
event.setCancelled(true);
player.sendMessage("Cannot reset skin while in combat!");
}
}
PlaceholderAPI Integration
ClothesPlus provides PlaceholderAPI placeholders:
| Placeholder | Description |
|---|---|
%clothesplus_tokens% |
Player's current token count |
%clothesplus_outfits% |
Number of saved outfits |
%clothesplus_max_outfits% |
Maximum outfit slots available |
%clothesplus_overlays% |
Number of overlays currently worn |
%clothesplus_model% |
Player's skin model (steve/alex) |
Example: Complete Plugin
package com.example.myplugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.wardrobeclothes.clothes.api.ClothesPlusAPI;
import org.wardrobeclothes.clothes.api.OverlayAPI;
public class MyPlugin extends JavaPlugin {
private ClothesPlusAPI api;
@Override
public void onEnable() {
if (getServer().getPluginManager().getPlugin("ClothesPlus") != null) {
api = ClothesPlusAPI.getInstance();
getLogger().info("Hooked into ClothesPlus!");
}
}
@Override
public boolean onCommand(CommandSender sender, Command command,
String label, String[] args) {
if (!(sender instanceof Player)) return true;
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("giveshirt")) {
if (api == null) {
player.sendMessage("ClothesPlus is not installed!");
return true;
}
OverlayAPI overlayAPI = api.getOverlayAPI();
// Give player a random shirt
String shirt = "shirts/casual_tshirt";
overlayAPI.wearOverlay(player, shirt);
player.sendMessage("You've been given a new shirt!");
return true;
}
return false;
}
}
Need Help?
Have questions about the API? Join our Discord for developer support!
Developer Support on Discord