/** Saves the warp lists to file */ public void saveWarpList() { if (warpList == null || welcomeWarps == null) { return; } // plugin.getLogger().info("Saving warps..."); final HashMap<String, Object> warps = new HashMap<String, Object>(); for (UUID p : warpList.keySet()) { warps.put(p.toString(), Util.getStringLocation(warpList.get(p))); } welcomeWarps.set("warps", warps); Util.saveYamlFile(welcomeWarps, "warps.yml"); // Update the warp panel - needs to be done 1 tick later so that the sign // text will be updated. /* if (reloadPanel) { // This is not done on shutdown if (Settings.useWarpPanel && plugin.getWarpPanel() != null) { plugin.getServer().getScheduler().runTask(plugin, new Runnable() { @Override public void run() { plugin.getWarpPanel().; }}); } }*/ // plugin.getLogger().info("End of saving warps"); }
/** Creates the warp list if it does not exist */ public void loadWarpList() { plugin.getLogger().info("Loading warps..."); // warpList.clear(); welcomeWarps = Util.loadYamlFile("warps.yml"); if (welcomeWarps.getConfigurationSection("warps") == null) { welcomeWarps.createSection("warps"); // This is only used to create // the warp.yml file so forgive // this code } HashMap<String, Object> temp = (HashMap<String, Object>) welcomeWarps.getConfigurationSection("warps").getValues(true); for (String s : temp.keySet()) { try { UUID playerUUID = UUID.fromString(s); Location l = Util.getLocationString((String) temp.get(s)); // plugin.getLogger().info("DEBUG: Loading warp at " + l); Block b = l.getBlock(); // Check that a warp sign is still there if (b.getType().equals(Material.SIGN_POST) || b.getType().equals(Material.WALL_SIGN)) { warpList.put(playerUUID, l); } else { plugin .getLogger() .warning("Warp at location " + temp.get(s) + " has no sign - removing."); // Test code /* warpList.put(playerUUID, l); b.getRelative(BlockFace.DOWN).setType(Material.DIRT); b.setType(Material.SIGN_POST); Sign sign = (Sign)b.getState(); sign.setLine(0, ChatColor.GREEN + plugin.myLocale().warpswelcomeLine); sign.setLine(1, "test"); sign.setLine(2, "Test 2"); sign.update(); */ } } catch (Exception e) { plugin .getLogger() .severe("Problem loading warp at location " + temp.get(s) + " - removing."); e.printStackTrace(); } } }