use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method overwritePane.
/**
* Opens the Pane for the Player.
*
* @param player - The Player to have the Pane opened.
*/
private static void overwritePane(final Player player) {
Interface overwritePane = new Interface(true, 6, GUIName, player);
SchedulerUtils.runAsync(() -> {
overwritePane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the configuration menu."), event -> itemSettings(player)));
List<String> enabledWorlds = new ArrayList<String>();
String[] enabledParts = ConfigHandler.getConfig().getFile("items.yml").getString("items-Overwrite").replace(" , ", ",").replace(" , ", ",").replace(", ", ",").replace(", ", ",").split(",");
for (String enabledWorld : enabledParts) {
if (enabledWorld.equalsIgnoreCase("ALL") || enabledWorld.equalsIgnoreCase("GLOBAL")) {
enabledWorlds.add("ALL");
} else {
for (World world : Bukkit.getServer().getWorlds()) {
if (enabledWorld.equalsIgnoreCase(world.getName())) {
enabledWorlds.add(world.getName());
}
}
}
}
if (enabledWorlds.isEmpty() && ConfigHandler.getConfig().getFile("items.yml").getBoolean("items-Overwrite")) {
enabledWorlds.add("ALL");
}
overwritePane.addButton(new Button(ItemHandler.getItem("OBSIDIAN", 1, StringUtils.containsValue(enabledWorlds, "ALL"), "&a&l&nGLOBAL", "&7", "&7*Click to enable item", "&7overwriting in &lALL WORLDS.", "&9&lENABLED: &a" + (StringUtils.containsValue(enabledWorlds, "ALL") + "").toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "items.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
if (StringUtils.containsValue(enabledWorlds, "ALL")) {
dataFile.set("items-Overwrite", false);
} else {
dataFile.set("items-Overwrite", true);
}
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "items.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> overwritePane(player));
}));
for (World world : Bukkit.getServer().getWorlds()) {
String worldMaterial = (ServerUtils.hasSpecificUpdate("1_13") ? "GRASS_BLOCK" : "2");
if (world.getEnvironment().equals(Environment.NETHER)) {
worldMaterial = "NETHERRACK";
} else if (world.getEnvironment().equals(Environment.THE_END)) {
worldMaterial = (ServerUtils.hasSpecificUpdate("1_13") ? "END_STONE" : "121");
}
overwritePane.addButton(new Button(ItemHandler.getItem(worldMaterial, 1, StringUtils.containsValue(enabledWorlds, world.getName()), "&f&l" + world.getName(), "&7", "&7*Click to enable item", "&7overwriting in this world.", "&9&lENABLED: &a" + (StringUtils.containsValue(enabledWorlds, world.getName()) + "").toUpperCase()), event -> {
if (StringUtils.containsValue(enabledWorlds, world.getName())) {
enabledWorlds.remove(world.getName());
} else {
enabledWorlds.add(world.getName());
}
if (!enabledWorlds.isEmpty() && enabledWorlds.size() > 1) {
if (StringUtils.containsValue(enabledWorlds, "ALL")) {
enabledWorlds.remove("ALL");
} else if (StringUtils.containsValue(enabledWorlds, "GLOBAL")) {
enabledWorlds.remove("GLOBAL");
}
}
String worldList = "";
for (String worldName : enabledWorlds) {
worldList += worldName + ", ";
}
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "items.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
if (enabledWorlds.isEmpty()) {
dataFile.set("items-Overwrite", false);
} else {
dataFile.set("items-Overwrite", worldList.substring(0, worldList.length() - 2));
}
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "items.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> overwritePane(player));
}));
}
});
overwritePane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method addConditionPane.
/**
* Opens the Pane for the Player.
* This Pane is for adding the item condition.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
* @param condition - The condition currently being modified.
*/
private static void addConditionPane(final Player player, final ItemMap itemMap, final Action commandAction, final String condition1, final String value1) {
Interface conditionsPane = new Interface(false, 2, GUIName, player);
SchedulerUtils.runAsync(() -> {
conditionsPane.addButton(new Button(fillerPaneBItem));
conditionsPane.addButton(new Button(ItemHandler.getItem("MINECART", 1, false, "&b&lEQUAL", "&7", "&7*The first value must be", "&7EQUAL to the second value", "&7for the condition to be met."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "SECOND VALUE";
placeHolders[15] = "400";
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] = "SECOND VALUE";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
conditions.add(value1 + ":" + "EQUAL" + ":" + ChatColor.stripColor(event.getMessage()));
if (condition1.equalsIgnoreCase("disposable-conditions")) {
itemMap.setDisposableConditions(conditions);
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
itemMap.setTriggerConditions(conditions);
triggerCPane(player, itemMap);
} else {
Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
conditions2.put(condition1.replace("-conditions", ""), conditions);
itemMap.setCommandConditions(conditions2);
commandCPane(player, itemMap, commandAction);
}
}));
conditionsPane.addButton(new Button(fillerPaneBItem));
conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_FENCE" : "85"), 1, false, "&b&lNOTEQUAL", "&7", "&7*The first value must be", "&7NOTEQUAL to the second value", "&7for the condition to be met."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "SECOND VALUE";
placeHolders[15] = "400";
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] = "SECOND VALUE";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
conditions.add(value1 + ":" + "NOTEQUAL" + ":" + ChatColor.stripColor(event.getMessage()));
if (condition1.equalsIgnoreCase("disposable-conditions")) {
itemMap.setDisposableConditions(conditions);
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
itemMap.setTriggerConditions(conditions);
triggerCPane(player, itemMap);
} else {
Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
conditions2.put(condition1.replace("-conditions", ""), conditions);
itemMap.setCommandConditions(conditions2);
commandCPane(player, itemMap, commandAction);
}
}));
conditionsPane.addButton(new Button(fillerPaneBItem));
conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_STAIRS" : "53"), 1, false, "&b&lOVER", "&7", "&7*The first value must be", "&7OVER the second value", "&7for the condition to be met.", "&7", "&c&l&nNOTE:&7 This only works if both", "&7values referenced are integers."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "SECOND VALUE";
placeHolders[15] = "400";
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] = "SECOND VALUE";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
conditions.add(value1 + ":" + "OVER" + ":" + ChatColor.stripColor(event.getMessage()));
if (condition1.equalsIgnoreCase("disposable-conditions")) {
itemMap.setDisposableConditions(conditions);
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
itemMap.setTriggerConditions(conditions);
triggerCPane(player, itemMap);
} else {
Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
conditions2.put(condition1.replace("-conditions", ""), conditions);
itemMap.setCommandConditions(conditions2);
commandCPane(player, itemMap, commandAction);
}
}));
conditionsPane.addButton(new Button(fillerPaneBItem));
conditionsPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "OAK_BOAT" : "333"), 1, false, "&b&lUNDER", "&7", "&7*The first value must be", "&7UNDER to the second value", "&7for the condition to be met.", "&7", "&c&l&nNOTE:&7 This only works if both", "&7values referenced are integers."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "SECOND VALUE";
placeHolders[15] = "400";
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] = "SECOND VALUE";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
List<String> conditions = (condition1.equalsIgnoreCase("disposable-conditions") ? itemMap.getDisposableConditions() : condition1.equalsIgnoreCase("trigger-conditions") ? itemMap.getTriggerConditions() : itemMap.getCommandConditions().get(condition1) != null ? itemMap.getCommandConditions().get(condition1) : new ArrayList<String>());
conditions.add(value1 + ":" + "UNDER" + ":" + ChatColor.stripColor(event.getMessage()));
if (condition1.equalsIgnoreCase("disposable-conditions")) {
itemMap.setDisposableConditions(conditions);
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
itemMap.setTriggerConditions(conditions);
triggerCPane(player, itemMap);
} else {
Map<String, List<String>> conditions2 = itemMap.getCommandConditions();
conditions2.put(condition1.replace("-conditions", ""), conditions);
itemMap.setCommandConditions(conditions2);
commandCPane(player, itemMap, commandAction);
}
}));
conditionsPane.addButton(new Button(fillerPaneBItem));
conditionsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the " + condition1.replace("-", " ").replace(".", "") + " condition menu."), event -> {
if (condition1.equalsIgnoreCase("disposable-conditions")) {
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
triggerCPane(player, itemMap);
} else {
commandCPane(player, itemMap, commandAction);
}
}));
conditionsPane.addButton(new Button(fillerPaneBItem), 7);
conditionsPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the " + condition1.replace("-", " ").replace(".", "") + " condition menu."), event -> {
if (condition1.equalsIgnoreCase("disposable-conditions")) {
disposableCPane(player, itemMap);
} else if (condition1.equalsIgnoreCase("trigger-conditions")) {
triggerCPane(player, itemMap);
} else {
commandCPane(player, itemMap, commandAction);
}
}));
});
conditionsPane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method setButton.
// ===================================================================================================================================================================================================================
// ============================================== //
// Menu Utilities //
// ============================================== //
/**
* Adds a button to the PagedPane.
*
* @param player - The Player.
* @param itemMap - The ItemMap currently being modified.
* @param pagedPane - The PagedPane.
*/
private static void setButton(final Player player, final ItemMap itemMap, final Interface modifyPane, final ItemMap contents, final ItemMap refMap, final int k) {
final ItemStack item = itemMap.getTempItem().clone();
if (item.getType() == Material.AIR) {
item.setType(fillerPaneItem.getType());
}
if (itemMap.isAnimated() || itemMap.isDynamic()) {
setModifyMenu(true, player);
itemMap.getAnimationHandler().get(player).setMenu(true, 0);
}
String lore = (contents == null && refMap == null ? "&7*Click to modify this custom item." : refMap != null ? "&7*Click to set this custom item as an ingredient." : "&7*Click to add into the contents of " + contents.getConfigName() + ".");
String space = (contents == null ? "&6---------------------------" : "&6----------------------------------");
modifyPane.addButton(new Button(ItemHandler.addLore(item, "&7", space, lore, "&9&lNode: &a" + itemMap.getConfigName(), "&7", (contents != null ? "&9&lENABLED: " + (contents.getContents().contains(itemMap.getConfigName()) ? "&aYES" : "&aNO") : "")), event -> {
if (refMap != null) {
setIngredients(player, refMap, itemMap.getConfigName(), k);
} else if (contents == null) {
choicePane(player, itemMap, item);
} else {
List<String> contentList = contents.getContents();
if (contents.getContents().contains(itemMap.getConfigName())) {
contentList.remove(itemMap.getConfigName());
} else {
contentList.add(itemMap.getConfigName());
}
contents.setContents(contentList);
Interface contentsPane = new Interface(true, 6, GUIName, player);
SchedulerUtils.runAsync(() -> {
setPage(player, contentsPane, ItemUtilities.getUtilities().copyItems(), contents, refMap, k);
});
contentsPane.open(player);
}
}));
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method lifePane.
/**
* Opens the Pane for the Player.
* This Pane is for setting the life time of the commands firework particle.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
*/
private static void lifePane(final Player player, final ItemMap itemMap, final String particle, final int stage) {
Interface lifePane = new Interface(true, 6, GUIName, player);
SchedulerUtils.runAsync(() -> {
lifePane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the particle menu."), event -> {
particlePane(player, itemMap, 3);
}));
lifePane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom LifeTime", "&7", "&7*Click to set a lifetime (duration)", "&7value for particle effect."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "PARTICLE LIFETIME";
placeHolders[15] = "170";
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()))) {
if (stage == 0) {
itemMap.setCommandParticle(particle + ":" + ChatColor.stripColor(event.getMessage()));
} else {
explosionPane(player, itemMap, particle, Integer.parseInt(ChatColor.stripColor(event.getMessage())));
}
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "PARTICLE LIFETIME";
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);
particlePane(event.getPlayer(), itemMap, 3);
}
}));
for (int i = 1; i <= 64; i++) {
final int k = i;
lifePane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "CYAN_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:9"), k, false, "&9&lLifeTime: &a&l" + k + " Tick(s)", "&7", "&7*Click to set the lifetime", "&7(duration) of the particle effect."), event -> {
if (stage == 0) {
itemMap.setCommandParticle(particle + ":" + k);
commandPane(player, itemMap);
} else {
explosionPane(player, itemMap, particle, k);
}
}));
}
});
lifePane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method startMenu.
// ============================================== //
// Selection Menus //
// ============================================== //
/**
* Opens the MAIN CREATOR PANE for the Player.
*
* @param sender - The Sender to have the Pane opened.
*/
public static void startMenu(final CommandSender sender) {
final Player player = (Player) sender;
Interface pagedPane = new Interface(false, 1, GUIName, player);
SchedulerUtils.runAsync(() -> {
pagedPane.addButton(new Button(exitItem, event -> player.closeInventory()));
pagedPane.addButton(new Button(ItemHandler.getItem("ENDER_CHEST", 1, false, "&b&l&nConfig Settings", "&7", "&7*Change the GLOBAL plugin", "&7configuration settings."), event -> configSettings(player)));
pagedPane.addButton(new Button(fillerPaneBItem));
pagedPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "WRITABLE_BOOK" : "386"), 1, false, "&a&l&nCreate", "&7", "&7*Create a new item from scratch."), event -> materialPane(player, new ItemMap("item_" + StringUtils.getPath(1), "ARBITRARY"), 0, 0)));
pagedPane.addButton(new Button(ItemHandler.getItem("HOPPER", 1, false, "&e&l&nSave", "&7", "&7*Save an existing item as a custom item."), event -> startHopper(player)));
pagedPane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, false, "&c&l&nModify", "&7", "&7*Modify an existing custom item"), event -> startModify(player, null, 0)));
pagedPane.addButton(new Button(fillerPaneBItem));
pagedPane.addButton(new Button(ItemHandler.getItem("CHEST", 1, false, "&b&l&nItem Settings", "&7", "&7*Change the GLOBAL custom items", "&7configuration settings."), event -> itemSettings(player)));
pagedPane.addButton(new Button(exitItem, event -> player.closeInventory()));
});
pagedPane.open(player);
}
Aggregations