use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method worldPane.
/**
* Opens the Pane for the Player.
*
* @param player - The Player to have the Pane opened.
* @param section - The world section type.
*/
private static void worldPane(final Player player, final String section) {
Interface preventPane = new Interface(true, 6, GUIName, player);
SchedulerUtils.runAsync(() -> {
preventPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the prevent menu."), event -> {
if (section.contains("Prevent")) {
preventPane(player);
} else {
clearPane(player);
}
}));
List<String> enabledWorlds = new ArrayList<String>();
String[] enabledParts = ConfigHandler.getConfig().getFile("config.yml").getString(section).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("config.yml").getBoolean(section)) {
enabledWorlds.add("ALL");
}
preventPane.addButton(new Button(ItemHandler.getItem("OBSIDIAN", 1, StringUtils.containsValue(enabledWorlds, "ALL"), "&a&l&nGLOBAL", "&7", "&7*Click to enable &lALL WORLDS.", "&9&lENABLED: &a" + (StringUtils.containsValue(enabledWorlds, "ALL") + "").toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
if (StringUtils.containsValue(enabledWorlds, "ALL")) {
dataFile.set(section, false);
} else {
dataFile.set(section, true);
}
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> worldPane(player, section));
}));
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");
}
preventPane.addButton(new Button(ItemHandler.getItem(worldMaterial, 1, StringUtils.containsValue(enabledWorlds, world.getName()), "&f&l" + world.getName(), "&7", "&7*Click to enable 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(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
if (enabledWorlds.isEmpty()) {
dataFile.set(section, false);
} else {
dataFile.set(section, worldList.substring(0, worldList.length() - 2));
}
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> worldPane(player, section));
}));
}
});
preventPane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method levelPane.
/**
* Opens the Pane for the Player.
* This Pane is for setting the Potion Level.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
*/
private static void levelPane(final Player player, final ItemMap itemMap, final PotionEffectType potion, final int stage) {
Interface levelPane = new Interface(true, 6, GUIName, player);
SchedulerUtils.runAsync(() -> {
levelPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the potion effect menu."), event -> potionPane(player, itemMap, stage)));
levelPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "YELLOW_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:4"), 1, false, "&e&lCustom Level", "&7", "&7*Click to set a custom level (strength)", "&7value for the potion effect.", "&7", "&c&lNote: &7Any duration LONGER than", "&71800 seconds (30 minutes) will", "&7result in an infinite duration."), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "EFFECT LEVEL";
placeHolders[15] = "16";
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()))) {
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "EFFECT LEVEL";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
durationPane(event.getPlayer(), itemMap, potion, Integer.parseInt(ChatColor.stripColor(event.getMessage())), stage);
} else {
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = ChatColor.stripColor(event.getMessage());
LanguageAPI.getLang(false).sendLangMessage("commands.menu.noInteger", player, placeHolders);
levelPane(event.getPlayer(), itemMap, potion, stage);
}
}));
for (int i = 1; i <= 64; i++) {
final int k = i;
levelPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "PINK_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:6"), k, false, "&d&lLevel: &a&l" + k + "", "&7", "&7*Click to set the", "&7level (strength) of the potion effect."), event -> {
itemMap.setInteractCooldown(k);
durationPane(player, itemMap, potion, k, stage);
}));
}
});
levelPane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method configSettings.
/**
* Opens the CONFIG SETTINGS PANE for the Player.
*
* @param player - The Player to have the Pane opened.
*/
private static void configSettings(final Player player) {
Interface configPane = new Interface(false, 3, GUIName, player);
SchedulerUtils.runAsync(() -> {
configPane.addButton(new Button(fillerPaneBItem), 3);
configPane.addButton(new Button(ItemHandler.getItem("PAPER", 1, false, "&6Language", "&7", "&7*The selected lang.yml language.", "&7This is for messages sent", "&7from the plugin to the player.", "&9&lLANG: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getString("Language")).toUpperCase()), event -> languagePane(player)));
configPane.addButton(new Button(fillerPaneBItem));
configPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "COMMAND_BLOCK" : "137"), 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("Database.MySQL"), "&bMySQL Database", "&7", "&7*If the plugin should use", "&7a MySQL Database instead", "&7of the locale SQLite Database.", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("Database.MySQL")).toUpperCase()), event -> databasePane(player)));
configPane.addButton(new Button(fillerPaneBItem), 4);
configPane.addButton(new Button(ItemHandler.getItem("BUCKET", 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.CheckforUpdates"), "&bCheck for Updates", "&7", "&7*If the plugin should check", "&7for updates at start-up.", "&7This includes the use of the", "&7/itemjoin updates/upgrade command(s).", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.CheckforUpdates")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("General.CheckforUpdates", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.CheckforUpdates"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(ItemHandler.getItem("COMPASS", 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Metrics-Logging"), "&bMetrics Logging", "&7", "&7*If the plugin is allowed", "&7to log plugin data such as", "&7the server(s) Java version.", "&7It is recommended to keep this", "&7set to true as it improves", "&7the quality of plugin updates.", "&7", "&7You can view the logged data", "&7Here: https://bstats.org/plugin/bukkit/ItemJoin", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Metrics-Logging")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("General.Metrics-Logging", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Metrics-Logging"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(ItemHandler.getItem("STICK", 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Debugging"), "&bDebugging", "&7", "&7*Allows for more detailed", "&7CONSOLE messages from the plugin.", "&7Typically only used by the", "&7plugin developer to determine", "&7issues or bugs with the plugin.", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Debugging")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("General.Debugging", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("General.Debugging"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "GRASS_BLOCK" : "2"), 1, ((ConfigHandler.getConfig().getFile("config.yml").getStringList("Active-Commands.commands").size() != 0 && !StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Active-Commands.enabled-worlds"), "DISABLED"))), "&bActive Commands", "&7", "&7*Specify a list of commands", "&7to be executed upon performing a trigger.", "&7These commands are not related to", "&7custom items, rather the server itself.", "&9&lENABLED: &a" + ((ConfigHandler.getConfig().getFile("config.yml").getStringList("Active-Commands.commands").size() != 0 && !StringUtils.containsIgnoreCase(ConfigHandler.getConfig().getFile("config.yml").getString("Active-Commands.enabled-worlds"), "DISABLED")) ? "YES" : "NO")), event -> activeCommands(player)));
configPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "GOLDEN_APPLE" : "322"), 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-OP"), "&bPlugin Commands &c&l[OP PLAYERS]", "&7", "&7*If the plugin should check", "&7if the OP player has the", "&7proper permissions set to", "&7use the plugin commands.", "&7OP Players will no longer get", "&7access to all plugin commands", "&7by default.", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-OP")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("Permissions.Commands-OP", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-OP"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(ItemHandler.getItem("BOOK", 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-Get"), "&bGet Commands", "&7", "&7*If the get and getAll", "&7commands should check for item", "&c&lpermissions &7before giving the item.", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-Get")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("Permissions.Commands-Get", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Commands-Get"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(ItemHandler.getItem("BEDROCK", 1, ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Movement-Bypass"), "&bMovement Bypass", "&7", "&7*Enables the use of the", "&aitemjoin.bypass.inventorymodify", "&7permission-node, used to ignore", "&7the global itemMovement prevention", "&7or a custom items itemflag.", "&9&lENABLED: &a" + String.valueOf(ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Movement-Bypass")).toUpperCase()), event -> {
File fileFolder = new File(ItemJoin.getInstance().getDataFolder(), "config.yml");
FileConfiguration dataFile = YamlConfiguration.loadConfiguration(fileFolder);
dataFile.set("Permissions.Movement-Bypass", !ConfigHandler.getConfig().getFile("config.yml").getBoolean("Permissions.Movement-Bypass"));
ConfigHandler.getConfig().saveFile(dataFile, fileFolder, "config.yml");
ConfigHandler.getConfig().softReload();
SchedulerUtils.runLater(2L, () -> configSettings(player));
}));
configPane.addButton(new Button(fillerPaneBItem));
configPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the main menu."), event -> startMenu(player)));
configPane.addButton(new Button(fillerPaneBItem), 7);
configPane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the main menu."), event -> startMenu(player)));
});
configPane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method modifyPagesPane.
/**
* Opens the Pane for the Player.
* This Pane is for modifying book pages.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
*/
private static void modifyPagesPane(final Player player, final ItemMap itemMap, final int line, final int page) {
Interface linePane = new Interface(false, 2, GUIName, player);
SchedulerUtils.runAsync(() -> {
List<List<String>> pages = itemMap.getListPages();
List<String> selectPage = pages.get(page);
linePane.addButton(new Button(fillerPaneGItem), 3);
linePane.addButton(new Button(ItemHandler.getItem("NAME_TAG", 1, false, "&c&l&nModify", "&7", "&7*Modify this line in the page.", "&7", "&9&lLine: &a" + (line + 1) + " &9&lPage: &a" + (page + 1)), event -> {
player.closeInventory();
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "PAGE LINE";
placeHolders[15] = "&eWelcome to the Server!";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputType", player, placeHolders);
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputExample", player, placeHolders);
}, event -> {
selectPage.set(line, ChatColor.stripColor(event.getMessage()));
pages.set(page, selectPage);
itemMap.setListPages(pages);
String[] placeHolders = LanguageAPI.getLang(false).newString();
placeHolders[16] = "PAGE LINE";
LanguageAPI.getLang(false).sendLangMessage("commands.menu.inputSet", player, placeHolders);
linePane(event.getPlayer(), itemMap, false, page);
}));
linePane.addButton(new Button(fillerPaneGItem));
linePane.addButton(new Button(ItemHandler.getItem("REDSTONE", 1, false, "&c&l&nDelete", "&7", "&7*Delete this line in the page.", "&7", "&9&lLine: &a" + (line + 1) + " &9&lPage: &a" + (page + 1)), event -> {
selectPage.remove(selectPage.get(line));
pages.set(page, selectPage);
itemMap.setListPages(pages);
linePane(player, itemMap, false, page);
}));
linePane.addButton(new Button(fillerPaneGItem), 3);
linePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the book lines menu."), event -> linePane(player, itemMap, false, page)));
linePane.addButton(new Button(fillerPaneBItem), 7);
linePane.addButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the book lines menu."), event -> linePane(player, itemMap, false, page)));
});
linePane.open(player);
}
use of me.RockinChaos.itemjoin.utils.interfaces.Button in project ItemJoin by RockinChaos.
the class Menu method commandListPane.
/**
* Opens the Pane for the Player.
* This Pane is for modifying an items list of commands.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
* @param action - The action to be matched.
*/
private static void commandListPane(final Player player, final ItemMap itemMap, final Action action) {
Interface commandListPane = new Interface(true, 2, GUIName, player);
SchedulerUtils.runAsync(() -> {
commandListPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the click type menu."), event -> {
actionPane(player, itemMap);
}));
commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, true, "&e&lNew Line", "&7", "&7*Add a new command to be executed", "&7by &9&l" + action.name()), event -> {
executorPane(player, itemMap, action);
}));
ItemCommand[] commandList = itemMap.getCommands();
int l = 1;
for (ItemCommand command : commandList) {
if (command.matchAction(action)) {
final int k = l;
commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, false, "&f" + command.getRawCommand(), "&7", "&7*Click to &lmodify &7this command.", "&9&lOrder Number: &a" + k), event -> {
modifyCommandsPane(player, itemMap, action, command, k);
}));
l++;
}
}
});
commandListPane.open(player);
}
Aggregations