From 4391ea5f1073b20beaf1c4bdb99a8685cab7e549 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 14 Feb 2015 18:23:12 +1100 Subject: [PATCH] more redundancy + fixed greeting/farewell prefix --- .../plot/database/PlotMeConverter.java | 46 +++++++++++++++---- .../plot/listeners/PlotPlusListener.java | 4 +- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java index c75d8b1a3..74034f0e4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/PlotMeConverter.java @@ -42,6 +42,7 @@ import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.UUIDHandler; @@ -196,7 +197,10 @@ public class PlotMeConverter { final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId"); PlotMain.config.set("worlds." + world + ".road.block", road); - final Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + if (height == null) { + height = 64; + } PlotMain.config.set("worlds." + world + ".road.height", height); } catch (final Exception e) { sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually"); @@ -209,26 +213,52 @@ public class PlotMeConverter { try { for (final String world : plots.keySet()) { String plotMeWorldName = world.toLowerCase(); - final Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); // + Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); // + if (pathwidth == null) { + pathwidth = 7; + } PlotMain.config.set("worlds." + world + ".road.width", pathwidth); - final Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // + Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); // + if (plotsize == null) { + plotsize = 32; + } PlotMain.config.set("worlds." + world + ".plot.size", plotsize); - final String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // + String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); // + if (wallblock == null) { + wallblock = "44"; + } PlotMain.config.set("worlds." + world + ".wall.block", wallblock); - final String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // + String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); // + if (floor == null) { + floor = "2"; + } PlotMain.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor)); - final String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // + String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); // + if (filling == null) { + filling = "3"; + } PlotMain.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling)); - final String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); + String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock"); + if (road == null) { + road = "5"; + } PlotMain.config.set("worlds." + world + ".road.block", road); - final Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); // + if (height == null || height == 0) { + height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); // + if (height == null || height == 0) { + height = 64; + } + } PlotMain.config.set("worlds." + world + ".road.height", height); + PlotMain.config.set("worlds." + world + ".plot.height", height); + PlotMain.config.set("worlds." + world + ".wall.height", height); } } catch (final Exception e) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 5d60164a8..e37288c65 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -173,7 +173,7 @@ import java.util.*; public void onPlotEnter(final PlayerEnterPlotEvent event) { final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "greeting") != null) { - event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s() + FlagManager.getPlotFlag(plot, "greeting").getValueString())); + event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString())); } if (booleanFlag(plot, "notify-enter", false)) { if (plot.hasOwner()) { @@ -210,7 +210,7 @@ import java.util.*; event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.RECORD_PLAY, 0); final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "farewell") != null) { - event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s() + FlagManager.getPlotFlag(plot, "farewell").getValueString())); + event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); } if (feedRunnable.containsKey(event.getPlayer().getName())) { feedRunnable.remove(event.getPlayer().getName());