/** * Get the plot from a string. * * @param player Provides a context for what world to search in. Prefixing the term with * 'world_name;' will override this context. * @param arg The search term * @param message If a message should be sent to the player if a plot cannot be found * @return The plot if only 1 result is found, or null */ public static Plot getPlotFromString(PlotPlayer player, String arg, boolean message) { if (arg == null) { if (player == null) { if (message) { PS.log(C.NOT_VALID_PLOT_WORLD); } return null; } return player.getCurrentPlot(); } PlotArea area; if (player != null) { area = PS.get().getPlotAreaByString(arg); if (area == null) { area = player.getApplicablePlotArea(); } } else { area = ConsolePlayer.getConsole().getApplicablePlotArea(); } String[] split = arg.split(";|,"); PlotId id; if (split.length == 4) { area = PS.get().getPlotAreaByString(split[0] + ';' + split[1]); id = PlotId.fromString(split[2] + ';' + split[3]); } else if (split.length == 3) { area = PS.get().getPlotAreaByString(split[0]); id = PlotId.fromString(split[1] + ';' + split[2]); } else if (split.length == 2) { id = PlotId.fromString(arg); } else { Collection<Plot> plots = area == null ? PS.get().getPlots() : area.getPlots(); for (Plot p : plots) { String name = p.getAlias(); if (!name.isEmpty() && StringMan.isEqualIgnoreCase(name, arg)) { return p; } } if (message) { sendMessage(player, C.NOT_VALID_PLOT_ID); } return null; } if (id == null) { if (message) { sendMessage(player, C.NOT_VALID_PLOT_ID); } return null; } if (area == null) { if (message) { sendMessage(player, C.NOT_VALID_PLOT_WORLD); } return null; } return area.getPlotAbs(id); }
/** * Resets the biome if it was modified * * @param area * @param pos1 * @param pos2 * @return true if any changes were made */ public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) { String biome = area.PLOT_BIOME; if (!StringMan.isEqual( WorldUtil.IMP.getBiome( area.worldname, (pos1.getX() + pos2.getX()) / 2, (pos1.getZ() + pos2.getZ()) / 2), biome)) { setBiome(area.worldname, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), biome); return true; } return false; }