From 20a4dec7feb4c71ad33eeed2e5d142582344fb9f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 2 Feb 2015 19:50:49 +1100 Subject: [PATCH] fix some invalid flags / improved regenallroads command --- .../plot/commands/RegenAllRoads.java | 4 +++- .../plot/flag/AbstractFlag.java | 7 ++++++- .../plot/flag/FlagValue.java | 16 +++++++++++++--- .../plot/generator/HybridPlotManager.java | 11 +++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index 1229f1893..d751e9f56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.object.PlotManager; public class RegenAllRoads extends SubCommand { public RegenAllRoads() { - super(Command.REGENALLROADS, "Regenerate all roads in the map", "regenallroads", CommandCategory.DEBUG, false); + super(Command.REGENALLROADS, "Regenerate all roads in the map using the set road schematic", "regenallroads", CommandCategory.DEBUG, false); } @Override @@ -65,6 +65,8 @@ public class RegenAllRoads extends SubCommand { World world = Bukkit.getWorld(name); ArrayList chunks = hpm.getChunkChunks(world); + PlotMain.sendConsoleSenderMessage("&cIf no schematic is set, the following will not do anything"); + PlotMain.sendConsoleSenderMessage("&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic"); PlotMain.sendConsoleSenderMessage("&6Potential chunks to update: &7"+ (chunks.size() * 256)); PlotMain.sendConsoleSenderMessage("&6Estimated time: &7"+ (chunks.size()) + " seconds"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java index 93f44ee08..3bf3dd4e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/AbstractFlag.java @@ -62,7 +62,12 @@ public class AbstractFlag { } public Object parseValueRaw(final String value) { - return this.value.parse(value); + try { + return this.value.parse(value); + } + catch (Exception e) { + return null; + } } public String toString(final Object t) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 614390820..aaf3c246c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -333,13 +333,23 @@ public abstract class FlagValue { @Override public void add(Object t, String value) { - ((HashSet)t).addAll(parse(value)); + try { + ((HashSet)t).addAll(parse(value)); + } + catch (Exception e) { + + } } @Override public void remove(Object t, String value) { - for (PlotBlock item : parse(value)) { - ((HashSet)t).remove(item); + try { + for (PlotBlock item : parse(value)) { + ((HashSet)t).remove(item); + } + } + catch (Exception e) { + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 2af0e8c2f..41799e5cd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -24,6 +24,7 @@ package com.intellectualcrafters.plot.generator; import java.io.File; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -204,6 +205,16 @@ import com.intellectualcrafters.plot.util.SendChunk; int sx = loc.x << 4; int sz = loc.z << 4; + HashSet chunks = new HashSet(); + + for (int x = sx; x < sx + 16; x++) { + for (int z = sz; z < sz + 16; z++) { + Chunk chunk = world.getChunkAt(x, z); + chunk.load(false); + chunks.add(chunk); + } + } + for (int x = sx; x < sx + 16; x++) { for (int z = sz; z < sz + 16; z++) { Chunk chunk = world.getChunkAt(x, z);