use of com.voxelgameslib.voxelgameslib.utils.ItemBuilder 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 com.voxelgameslib.voxelgameslib.utils.ItemBuilder 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 com.voxelgameslib.voxelgameslib.utils.ItemBuilder in project VoxelGamesLibv2 by VoxelGamesLib.
the class EditMode method chest.
@Subcommand("chest")
@CommandPermission("%admin")
@Syntax("<name> - the name of the chest")
public void chest(@Nonnull User sender, @Nonnull String name) {
if (editMode.contains(sender.getUuid())) {
ItemStack chest = new ItemBuilder(Material.CHEST).name(name).build();
sender.getPlayer().getInventory().setItemInMainHand(chest);
} else {
Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
}
}
use of com.voxelgameslib.voxelgameslib.utils.ItemBuilder in project VoxelGamesLibv2 by VoxelGamesLib.
the class KitHandler method enable.
@Override
public void enable() {
if (!kitsDir.exists()) {
log.info("Kits dir doesn't exist, creating....");
kitsDir.mkdirs();
}
File[] files = kitsDir.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().endsWith(".json")) {
availableKits.add(file.getName().replace(".json", ""));
}
}
}
log.info("There are " + availableKits.size() + " kits available.");
// test stuff
Kit kit = new Kit("DefaultKit");
kit.addItem(0, new ItemBuilder(Material.STONE).name("Test Stone").build());
kit.addItem(1, new ItemBuilder(Material.DIAMOND_SWORD).enchantment(Enchantment.DAMAGE_ALL, 5).name(ChatColor.RED + "Cool sword").amount(2).build());
kit.addItem(2, new ItemBuilder(Material.LEATHER_BOOTS).enchantment(Enchantment.PROTECTION_EXPLOSIONS, 2).enchantment(Enchantment.PROTECTION_FALL, 5).name("Cool bots").amount(3).color(Color.RED).durability(10).lore("test").lore("Lore").build());
createKit(kit);
kit = loadKit("DefaultKit", new File(kitsDir, kit.getName() + ".json"));
System.out.println(kit);
}
use of com.voxelgameslib.voxelgameslib.utils.ItemBuilder in project VoxelGamesLibv2 by VoxelGamesLib.
the class VoteFeature method openVoteMenu.
@GameEvent
public void openVoteMenu(@Nonnull PlayerInteractEvent event, User user) {
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && openMenuItem.equals(event.getItem())) {
InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle("Vote for a map");
for (int id : availableMaps.keySet()) {
MapInfo info = availableMaps.get(id);
ItemStack item = new ItemBuilder(Material.PAPER).amount(id).name(info.getName()).lore(info.getAuthor()).build();
builder.withItem(id - 1, item, (player, clickType, itemStack) -> confirmVote(user, id), ClickType.LEFT);
}
builder.show(user.getPlayer());
}
}
Aggregations