Java Code Examples for org.bukkit.configuration.InvalidConfigurationException#printStackTrace()
The following examples show how to use
org.bukkit.configuration.InvalidConfigurationException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScoreboardLayout.java From UhcCore with GNU General Public License v3.0 | 6 votes |
public void loadFile(){ YamlFile cfg; try{ cfg = FileUtils.saveResourceIfNotAvailable("scoreboard.yml"); }catch (InvalidConfigurationException ex){ ex.printStackTrace(); // Set default values. waiting = new ArrayList<>(); playing = new ArrayList<>(); deathmatch = new ArrayList<>(); spectating = new ArrayList<>(); title = ChatColor.RED + "Error"; return; } waiting = getOpsideDownLines(cfg.getStringList("waiting")); playing = getOpsideDownLines(cfg.getStringList("playing")); deathmatch = getOpsideDownLines(cfg.getStringList("deathmatch")); spectating = getOpsideDownLines(cfg.getStringList("spectating")); title = ChatColor.translateAlternateColorCodes('&', cfg.getString("title", "")); }
Example 2
Source File: ShopLoader.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
private @Nullable ItemStack deserializeItem(@NotNull String itemConfig) { try { return Util.deserialize(itemConfig); } catch (InvalidConfigurationException e) { e.printStackTrace(); plugin .getLogger() .warning( "Failed load shop data, because target config can't deserialize the ItemStack."); Util.debugLog("Failed to load data to the ItemStack: " + itemConfig); return null; } }
Example 3
Source File: ItemService.java From Transport-Pipes with MIT License | 5 votes |
public ItemStack deserializeItemStack(String string) { try { tempConf.loadFromString(string); } catch (InvalidConfigurationException e) { e.printStackTrace(); } ItemStack itemStack = tempConf.getItemStack("itemStack"); tempConf.set("itemStack", null); return itemStack; }
Example 4
Source File: CraftsManager.java From UhcCore with GNU General Public License v3.0 | 4 votes |
public static void loadCrafts(){ Bukkit.getLogger().info("[UhcCore] Loading custom crafts"); YamlFile cfg; try{ cfg = FileUtils.saveResourceIfNotAvailable("crafts.yml"); }catch (InvalidConfigurationException ex){ ex.printStackTrace(); return; } crafts.clear(); ConfigurationSection customCraftSection = cfg.getConfigurationSection("custom-crafts"); if (customCraftSection == null){ Bukkit.getLogger().info("[UhcCore] Done loading custom crafts"); return; } Set<String> craftsKeys = customCraftSection.getKeys(false); for(String name : craftsKeys){ ConfigurationSection section = cfg.getConfigurationSection("custom-crafts."+name); if (section == null){ Bukkit.getLogger().severe("[UhcCore] custom-crafts."+name + " section does not exist!"); continue; } List<ItemStack> recipe = new ArrayList<>(); ItemStack craftItem; int limit; boolean defaultName, reviveItem, reviveWithInventory; try{ Bukkit.getLogger().info("[UhcCore] Loading custom craft "+name); // Recipe String[] lines = new String[3]; lines[0] = section.getString("1", ""); lines[1] = section.getString("2", ""); lines[2] = section.getString("3", ""); for(int i=0 ; i<3; i++){ String[] itemsInLine = lines[i].split(" "); if(itemsInLine.length != 3) throw new IllegalArgumentException("Each line should be formatted like {item} {item} {item}"); for(int j=0 ; j<3 ;j++){ if (itemsInLine[j].startsWith("{") && itemsInLine[j].endsWith("}")){ recipe.add(JsonItemUtils.getItemFromJson(itemsInLine[j])); }else{ throw new IllegalArgumentException("The craft result must be formatted according to the json item format (Use /iteminfo)."); } } } // Craft String craftString = section.getString("craft",""); if (craftString.startsWith("{") && craftString.endsWith("}")){ craftItem = JsonItemUtils.getItemFromJson(craftString); }else { throw new IllegalArgumentException("The craft result must be formatted according to the json item format (Use /iteminfo)."); } // Limit limit = section.getInt("limit",-1); defaultName = section.getBoolean("default-name", false); reviveItem = section.getBoolean("revive-item", false); reviveWithInventory = section.getBoolean("revive-with-inventory", true); Craft craft = new Craft(name, recipe, craftItem, limit, defaultName, reviveItem, reviveWithInventory); crafts.add(craft); }catch(IllegalArgumentException | ParseException e){ //ignore craft if bad formatting Bukkit.getLogger().warning("[UhcCore] Failed to register "+name+" custom craft : syntax error"); Bukkit.getLogger().warning(e.getMessage()); } } }