use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.
the class EditMode method gui.
@Subcommand("gui")
@CommandPermission("%admin")
public void gui(@Nonnull User sender) {
if (editMode.contains(sender.getUuid())) {
// TODO implement paginated invs
InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle(Lang.legacy(LangKey.INV_MARKER));
for (int i = 0; i < mapHandler.getMarkerDefinitions().size(); i++) {
MarkerDefinition markerDefinition = mapHandler.getMarkerDefinitions().get(i);
ItemStack is = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(markerDefinition.getPrefix()).meta((itemMeta -> {
char prefix = markerDefinition.getPrefix().toUpperCase().charAt(0);
Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
((SkullMeta) itemMeta).setOwner(markerDefinition.getPrefix());
})).build();
builder.withItem(i, is, (player, clickType, itemStack) -> sender.getPlayer().performCommand("editmode skull " + itemStack.getItemMeta().getDisplayName()), ClickType.LEFT);
}
builder.show(sender.getPlayer());
} else {
Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
}
}
use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.
the class EditMode method skull.
@Subcommand("skull")
@CommandPermission("%admin")
@Syntax("<name> - the name of the skull")
public void skull(@Nonnull User sender, @Nonnull String name) {
if (editMode.contains(sender.getUuid())) {
ItemStack skull = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(name).meta((itemMeta -> {
char prefix = name.toUpperCase().charAt(0);
Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
((SkullMeta) itemMeta).setOwner(name);
})).build();
sender.getPlayer().getInventory().setItemInMainHand(skull);
} else {
Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
}
}
use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.
the class TextureHandler method loadSkin.
@Nullable
public Skin loadSkin(@Nonnull String name) {
try {
FileReader fr = new FileReader(new File(skinsFolder, name + ".json"));
Skin skin = gson.fromJson(fr, Skin.class);
fr.close();
loadedSkins.add(skin);
return skin;
} catch (Exception ex) {
log.log(Level.WARNING, "could not load skin " + name, ex);
}
return null;
}
use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.
the class TextureListener method doStuff.
public Skin doStuff(PlayerProfile playerProfile) {
Skin skin = textureHandler.getSkin(118300).orElseThrow(() -> new RuntimeException("d"));
playerProfile.clearProperties();
playerProfile.setProperty(new ProfileProperty("textures", skin.data.texture.value, skin.data.texture.signature));
return skin;
}
use of org.mineskin.data.Skin in project VoxelGamesLibv2 by VoxelGamesLib.
the class TextureListener method onLogin.
@EventHandler
public void onLogin(com.destroystokyo.paper.event.profile.PreLookupProfileEvent e) {
Skin skin = doStuff(Bukkit.createProfile(e.getUUID(), e.getName()));
e.setProfileProperties(new HashSet<ProfileProperty>() {
{
add(new ProfileProperty("textures", skin.data.texture.value, skin.data.texture.signature));
}
});
}
Aggregations