Search in sources :

Example 1 with Button

use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.

the class Menu method strengthPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying item attributes strength.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void strengthPane(final Player player, final ItemMap itemMap, final String attribute, final boolean isLeather) {
    Interface strengthPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        strengthPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the custom attributes menu."), event -> attributePane(player, itemMap, isLeather)));
        strengthPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom Strength", "&7", "&7*Click to set a custom strength", "&7value for the custom attribute."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "STRENGTH";
            placeHolders[15] = "14.0";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            if (StringUtils.isInt(ChatColor.stripColor(event.getMessage())) || StringUtils.isDouble(ChatColor.stripColor(event.getMessage()))) {
                Map<String, Double> attributeList = itemMap.getAttributes();
                attributeList.put(attribute, Double.parseDouble(ChatColor.stripColor(event.getMessage())));
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "STRENGTH";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            } else {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = ChatColor.stripColor(event.getMessage());
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.noInteger", player, placeHolders);
            }
            attributePane(event.getPlayer(), itemMap, isLeather);
        }));
        for (double i = 1; i < 90; i++) {
            final double k = i;
            strengthPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "PINK_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:6"), 1, false, "&9&lStrength: &a&l" + k, "&7", "&7*Click to set the strength", "&7 of the custom attribute."), event -> {
                Map<String, Double> attributeList = itemMap.getAttributes();
                attributeList.put(attribute, k);
                attributePane(player, itemMap, isLeather);
            }));
        }
    });
    strengthPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Map(java.util.Map) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) HashMap(java.util.HashMap) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 2 with Button

use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.

the class Menu method preventPane.

/**
 * Opens the Pane for the Player.
 *
 * @param player - The Player to have the Pane opened.
 */
private static void preventPane(final Player player) {
    Interface preventPane = new Interface(false, 3, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        List<String> bypassList = new ArrayList<String>();
        for (String bypass : ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Bypass").replace(" ", "").split(",")) {
            if (bypass != null && !bypass.isEmpty()) {
                bypassList.add(bypass);
            }
        }
        preventPane.addButton(new Button(fillerPaneBItem), 3);
        preventPane.addButton(new Button(ItemHandler.getItem(StringUtils.containsValue(bypassList, "CREATIVE") ? (ServerUtils.hasSpecificUpdate("1_13") ? "ENCHANTED_GOLDEN_APPLE" : "322:1") : (ServerUtils.hasSpecificUpdate("1_13") ? "GOLDEN_APPLE" : "322"), 1, StringUtils.containsValue(bypassList, "CREATIVE"), "&bCreative Bypass", "&7", "&7*Players in creative mode", "&7will ignore the prevent actions.", "&9&lENABLED: &a" + (StringUtils.containsValue(bypassList, "CREATIVE") + "").toUpperCase()), event -> {
            if (StringUtils.containsValue(bypassList, "CREATIVE")) {
                bypassList.remove("CREATIVE");
            } else {
                bypassList.add("CREATIVE");
            }
            if (bypassList.isEmpty()) {
                bypassList.add("DISABLED");
            } else if (StringUtils.containsValue(bypassList, "DISABLED")) {
                bypassList.remove("DISABLED");
            } else if (StringUtils.containsValue(bypassList, "DISABLE")) {
                bypassList.remove("DISABLE");
            }
            File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
            FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
            dataFile.set("Prevent.Bypass", bypassList.toString().replace("[", "").replace("]", ""));
            ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
            ConfigHandler.getConfig().softReload();
            SchedulerUtils.runLater(2L, () -> preventPane(player));
        }));
        preventPane.addButton(new Button(fillerPaneBItem));
        preventPane.addButton(new Button(ItemHandler.getItem("DIAMOND", 1, StringUtils.containsValue(bypassList, "OP"), "&bOP Bypass", "&7", "&7*Players that are OP", "&7will ignore the prevent actions.", "&9&lENABLED: &a" + (StringUtils.containsValue(bypassList, "OP") + "").toUpperCase()), event -> {
            if (StringUtils.containsValue(bypassList, "OP")) {
                bypassList.remove("OP");
            } else {
                bypassList.add("OP");
            }
            if (bypassList.isEmpty()) {
                bypassList.add("DISABLED");
            } else if (StringUtils.containsValue(bypassList, "DISABLED")) {
                bypassList.remove("DISABLED");
            } else if (StringUtils.containsValue(bypassList, "DISABLE")) {
                bypassList.remove("DISABLE");
            }
            File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
            FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
            dataFile.set("Prevent.Bypass", bypassList.toString().replace("[", "").replace("]", ""));
            ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
            ConfigHandler.getConfig().softReload();
            SchedulerUtils.runLater(2L, () -> preventPane(player));
        }));
        preventPane.addButton(new Button(fillerPaneBItem), 4);
        preventPane.addButton(new Button(ItemHandler.getItem("CHEST", 1, false, "&c&l&nPrevent Pickups", "&7", "&7*Prevent players from picking up", "&7ANY items, not just custom items.", "&9&lENABLED: &a" + ((!StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Pickups"), "DISABLE") ? ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Pickups") : "FALSE")).toUpperCase()), event -> worldPane(player, "Prevent.Pickups")));
        preventPane.addButton(new Button(fillerPaneBItem));
        preventPane.addButton(new Button(ItemHandler.getItem("BEDROCK", 1, false, "&c&l&nPrevent Movement", "&7", "&7*Prevent players from moving", "&7ANY items around in their", "&7inventory, not just custom items.", "&9&lENABLED: &a" + ((!StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.itemMovement"), "DISABLE") ? ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.itemMovement") : "FALSE")).toUpperCase()), event -> worldPane(player, "Prevent.itemMovement")));
        preventPane.addButton(new Button(fillerPaneBItem));
        preventPane.addButton(new Button(ItemHandler.getItem("HOPPER", 1, false, "&c&l&nPrevent Drops", "&7", "&7*Prevent players from dropping", "&7ANY items, not just custom items.", "&9&lENABLED: &a" + ((!StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Self-Drops"), "DISABLE") ? ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Self-Drops") : "FALSE")).toUpperCase()), event -> worldPane(player, "Prevent.Self-Drops")));
        preventPane.addButton(new Button(fillerPaneBItem));
        preventPane.addButton(new Button(ItemHandler.getItem("BONE", 1, false, "&c&l&nPrevent Death Drops", "&7", "&7*Prevent players from dropping", "&7ANY items on death, not just custom items.", "&9&lENABLED: &a" + ((!StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Death-Drops"), "DISABLE") ? ConfigHandler.getConfig().getFile("config.yml").getString("Prevent.Death-Drops") : "FALSE")).toUpperCase()), event -> worldPane(player, "Prevent.Death-Drops")));
        preventPane.addButton(new Button(fillerPaneBItem));
        preventPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item settings menu."), event -> itemSettings(player)));
        preventPane.addButton(new Button(fillerPaneBItem), 7);
        preventPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item settings menu."), event -> itemSettings(player)));
    });
    preventPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ArrayList(java.util.ArrayList) File(java.io.File) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 3 with Button

use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.

the class Menu method materialPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for modifying an items Material.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 * @param stage - The stage of the modification.
 */
private static void materialPane(final Player player, final ItemMap itemMap, final int stage, final int position) {
    Interface materialPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        if (stage != 0 && stage != 2 && stage != 3) {
            materialPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item definition menu."), event -> {
                creatingPane(player, itemMap);
            }));
        } else if (stage == 2) {
            materialPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the commands menu."), event -> {
                commandPane(player, itemMap);
            }));
        } else if (stage == 3) {
            materialPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the recipe menu."), event -> {
                recipePane(player, itemMap);
            }));
        }
        materialPane.addButton(new Button(ItemHandler.getItem("STICK", 1, true, "&b&lBukkit Material", "&7", "&7*If you know the name", "&7of the BUKKIT material type", "&7simply click and type it."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            if (stage == 2) {
                placeHolders[16] = "ITEM COST";
            } else {
                placeHolders[16] = "BUKKIT MATERIAL";
            }
            placeHolders[15] = "IRON_SWORD";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            if (ItemHandler.getMaterial(ChatColor.stripColor(event.getMessage()), null) != null) {
                if (stage == 2) {
                    itemMap.setItemCost(ChatColor.stripColor(event.getMessage()).toUpperCase());
                } else if (stage != 3) {
                    itemMap.setMaterial(ItemHandler.getMaterial(ChatColor.stripColor(event.getMessage()), null));
                    if (!ServerUtils.hasSpecificUpdate("1_13") && ChatColor.stripColor(event.getMessage()).contains(":")) {
                        String[] dataValue = ChatColor.stripColor(event.getMessage()).split(":");
                        if (StringUtils.isInt(dataValue[1])) {
                            itemMap.setDataValue((short) Integer.parseInt(dataValue[1]));
                        }
                    }
                }
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                if (stage == 2) {
                    placeHolders[16] = "ITEM COST";
                } else {
                    placeHolders[16] = "BUKKIT MATERIAL";
                }
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
                if (stage == 3) {
                    setIngredients(event.getPlayer(), itemMap, ItemHandler.getMaterial(ChatColor.stripColor(event.getMessage()), null).name(), position);
                } else if (stage == 2) {
                    commandPane(event.getPlayer(), itemMap);
                } else {
                    creatingPane(event.getPlayer(), itemMap);
                }
            } else {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = ChatColor.stripColor(event.getMessage());
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.noMaterial", player, placeHolders);
                materialPane(player, itemMap, stage, position);
            }
        }));
        Inventory inventoryCheck = Bukkit.getServer().createInventory(null, 9, GUIName);
        for (Material material : Material.values()) {
            if (!material.name().contains("LEGACY") && material.name() != "AIR" && safeMaterial(ItemHandler.getItem(material.toString(), 1, false, "", ""), inventoryCheck)) {
                if (!ServerUtils.hasSpecificUpdate("1_13") && LegacyAPI.getDataValue(material) != 0) {
                    for (int i = 0; i <= LegacyAPI.getDataValue(material); i++) {
                        if (!material.toString().equalsIgnoreCase("STEP") || material.toString().equalsIgnoreCase("STEP") && i != 2) {
                            final int dataValue = i;
                            materialPane.addButton(new Button(ItemHandler.getItem(material.toString() + ":" + dataValue, 1, false, "", "&7", "&7*Click to set the material."), event -> {
                                if (stage == 2) {
                                    itemMap.setItemCost(material.toString());
                                } else if (stage != 3) {
                                    itemMap.setMaterial(material);
                                    if (dataValue != 0) {
                                        itemMap.setDataValue((short) dataValue);
                                    }
                                }
                                if (stage == 0) {
                                    switchPane(player, itemMap, 0);
                                } else if (stage == 2) {
                                    commandPane(player, itemMap);
                                } else if (stage == 3) {
                                    setIngredients(player, itemMap, material.name(), position);
                                } else {
                                    creatingPane(player, itemMap);
                                }
                            }));
                        }
                    }
                } else {
                    materialPane.addButton(new Button(ItemHandler.getItem(material.toString(), 1, false, "", "&7", "&7*Click to set the material."), event -> {
                        if (stage == 2) {
                            itemMap.setItemCost(material.toString());
                        } else if (stage != 3) {
                            itemMap.setMaterial(material);
                        }
                        if (stage == 0) {
                            switchPane(player, itemMap, 0);
                        } else if (stage == 2) {
                            commandPane(player, itemMap);
                        } else if (stage == 3) {
                            setIngredients(player, itemMap, material.name(), position);
                        } else {
                            creatingPane(player, itemMap);
                        }
                    }));
                }
            }
        }
        inventoryCheck.clear();
    });
    materialPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Material(org.bukkit.Material) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) Inventory(org.bukkit.inventory.Inventory) PlayerInventory(org.bukkit.inventory.PlayerInventory)

Example 4 with Button

use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.

the class Menu method soundPitchPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting an item commands sound pitch.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void soundPitchPane(final Player player, final ItemMap itemMap, final int stage) {
    Interface soundPane = new Interface(true, 6, GUIName, player);
    SchedulerUtils.runAsync(() -> {
        if (stage != 3) {
            soundPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the teleport menu."), event -> teleportPane(player, itemMap, stage)));
        } else {
            soundPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item commands menu."), event -> commandPane(player, itemMap)));
        }
        soundPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom Pitch", "&7", "&7*Click to set a custom sound pitch", "&7value for the command sound."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "SOUND PITCH";
            placeHolders[15] = "0.8";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            if (StringUtils.isDouble(ChatColor.stripColor(event.getMessage()))) {
                if (stage != 3) {
                    itemMap.setTeleportPitch(Double.parseDouble(ChatColor.stripColor(event.getMessage())));
                    teleportPane(player, itemMap, stage);
                } else {
                    itemMap.setCommandPitch(Double.parseDouble(ChatColor.stripColor(event.getMessage())));
                    commandPane(player, itemMap);
                }
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "SOUND PITCH";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            } else {
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = ChatColor.stripColor(event.getMessage());
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.noInteger", player, placeHolders);
                soundPitchPane(event.getPlayer(), itemMap, stage);
            }
        }));
        for (int i = 1; i <= 64; i++) {
            final int k = i;
            soundPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "BLUE_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:11"), k, false, "&9&lPitch: &a&l" + k, "&7", "&7*Click to set the sound pitch", "&7for the command sound."), event -> {
                if (stage != 3) {
                    itemMap.setTeleportPitch((double) k);
                    teleportPane(player, itemMap, stage);
                } else {
                    itemMap.setCommandPitch((double) k);
                    commandPane(player, itemMap);
                }
            }));
        }
    });
    soundPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Example 5 with Button

use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.

the class Menu method triggerCPane.

/**
 * Opens the Pane for the Player.
 * This Pane is for setting the trigger conditions.
 *
 * @param player - The Player to have the Pane opened.
 * @param itemMap - The ItemMap currently being modified.
 */
private static void triggerCPane(final Player player, final ItemMap itemMap) {
    Interface conditionsPane = new Interface(true, 2, GUIName, player);
    conditionsPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the item conditions menu."), event -> conditionsPane(player, itemMap)));
    SchedulerUtils.runAsync(() -> {
        conditionsPane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, (StringUtils.nullCheck(itemMap.getTriggerMessage()) != "NONE"), "&c&lTrigger Fail Message", "&7", "&7*An optional message to be", "&7sent when the player does not", "&7meet the trigger conditions.", "&7", "&9&lMESSAGE: &a" + (StringUtils.nullCheck(itemMap.getTriggerMessage()) != "NONE" ? itemMap.getTriggerMessage() : "NONE")), event -> {
            if (StringUtils.nullCheck(itemMap.getTriggerMessage()) != "NONE") {
                itemMap.setTriggerMessage(null);
                triggerCPane(player, itemMap);
            } else {
                player.closeInventory();
                String[] placeHolders = LanguageAPI.getLang(false).newString();
                placeHolders[16] = "TRIGGER FAIL MESSAGE";
                placeHolders[15] = "&cYou do not meet the conditions to receive this item.";
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
                LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
            }
        }, event -> {
            itemMap.setTriggerMessage(ChatColor.stripColor(event.getMessage()));
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "TRIGGER FAIL MESSAGE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            triggerCPane(event.getPlayer(), itemMap);
        }));
        conditionsPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, true, "&b&lAdd Condition", "&7", "&7*Condition(s) that must be met", "&7in order to receive the item."), event -> {
            player.closeInventory();
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "FIRST VALUE";
            placeHolders[15] = "100";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
        }, event -> {
            String[] placeHolders = LanguageAPI.getLang(false).newString();
            placeHolders[16] = "FIRST VALUE";
            LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
            addConditionPane(event.getPlayer(), itemMap, null, "trigger-conditions", ChatColor.stripColor(event.getMessage()));
        }));
        for (String condition : itemMap.getTriggerConditions()) {
            conditionsPane.addButton(new Button(ItemHandler.getItem("PAPER", 1, false, "&f" + condition, "&7", "&7*Click to remove this condition."), event -> {
                List<String> conditions = itemMap.getTriggerConditions();
                conditions.remove(condition);
                itemMap.setTriggerConditions(conditions);
                triggerCPane(player, itemMap);
            }));
        }
    });
    conditionsPane.open(player);
}
Also used : ItemHandler(me.RockinChaos.itemjoin.handlers.ItemHandler) PatternType(org.bukkit.block.banner.PatternType) Enchantment(org.bukkit.enchantments.Enchantment) GameProfile(com.mojang.authlib.GameProfile) Player(org.bukkit.entity.Player) LanguageAPI(me.RockinChaos.itemjoin.utils.api.LanguageAPI) Inventory(org.bukkit.inventory.Inventory) DependAPI(me.RockinChaos.itemjoin.utils.api.DependAPI) World(org.bukkit.World) Map(java.util.Map) PlayerInventory(org.bukkit.inventory.PlayerInventory) Material(org.bukkit.Material) FireworkEffectMeta(org.bukkit.inventory.meta.FireworkEffectMeta) Bukkit(org.bukkit.Bukkit) Action(me.RockinChaos.itemjoin.item.ItemCommand.Action) CommandSender(org.bukkit.command.CommandSender) UUID(java.util.UUID) Sound(org.bukkit.Sound) ItemMap(me.RockinChaos.itemjoin.item.ItemMap) EntityType(org.bukkit.entity.EntityType) FireworkMeta(org.bukkit.inventory.meta.FireworkMeta) ItemUtilities(me.RockinChaos.itemjoin.item.ItemUtilities) ItemStack(org.bukkit.inventory.ItemStack) List(java.util.List) SchedulerUtils(me.RockinChaos.itemjoin.utils.SchedulerUtils) StringUtils(me.RockinChaos.itemjoin.utils.StringUtils) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemJoin(me.RockinChaos.itemjoin.ItemJoin) PotionEffectType(org.bukkit.potion.PotionEffectType) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) ItemMeta(org.bukkit.inventory.meta.ItemMeta) Pattern(org.bukkit.block.banner.Pattern) BookMeta(org.bukkit.inventory.meta.BookMeta) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface) HashMap(java.util.HashMap) HeadDatabaseAPI(me.arcaniax.hdb.api.HeadDatabaseAPI) BannerMeta(org.bukkit.inventory.meta.BannerMeta) ServerUtils(me.RockinChaos.itemjoin.utils.ServerUtils) ArrayList(java.util.ArrayList) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) Environment(org.bukkit.World.Environment) Property(com.mojang.authlib.properties.Property) ConfigHandler(me.RockinChaos.itemjoin.handlers.ConfigHandler) Color(org.bukkit.Color) Attribute(org.bukkit.attribute.Attribute) Type(org.bukkit.FireworkEffect.Type) PlayerHandler(me.RockinChaos.itemjoin.handlers.PlayerHandler) LegacyAPI(me.RockinChaos.itemjoin.utils.api.LegacyAPI) DecimalFormat(java.text.DecimalFormat) Field(java.lang.reflect.Field) File(java.io.File) PotionEffect(org.bukkit.potion.PotionEffect) CommandSequence(me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ItemCommand(me.RockinChaos.itemjoin.item.ItemCommand) ChatColor(org.bukkit.ChatColor) DyeColor(org.bukkit.DyeColor) Button(me.RockinChaos.itemjoin.utils.interfaces.Button) List(java.util.List) ArrayList(java.util.ArrayList) Interface(me.RockinChaos.itemjoin.utils.interfaces.Interface)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)108 Property (com.mojang.authlib.properties.Property)108 File (java.io.File)108 Field (java.lang.reflect.Field)108 DecimalFormat (java.text.DecimalFormat)108 ArrayList (java.util.ArrayList)108 HashMap (java.util.HashMap)108 List (java.util.List)108 Map (java.util.Map)108 UUID (java.util.UUID)108 ItemJoin (me.RockinChaos.itemjoin.ItemJoin)108 ConfigHandler (me.RockinChaos.itemjoin.handlers.ConfigHandler)108 ItemHandler (me.RockinChaos.itemjoin.handlers.ItemHandler)108 PlayerHandler (me.RockinChaos.itemjoin.handlers.PlayerHandler)108 ItemCommand (me.RockinChaos.itemjoin.item.ItemCommand)108 Action (me.RockinChaos.itemjoin.item.ItemCommand.Action)108 CommandSequence (me.RockinChaos.itemjoin.item.ItemCommand.CommandSequence)108 ItemMap (me.RockinChaos.itemjoin.item.ItemMap)108 ItemUtilities (me.RockinChaos.itemjoin.item.ItemUtilities)108 SchedulerUtils (me.RockinChaos.itemjoin.utils.SchedulerUtils)108