diff --git a/src/org/mcteam/ancientgates/util/FloodUtil.java b/src/org/mcteam/ancientgates/util/FloodUtil.java index 92523b2..c8c10e2 100644 --- a/src/org/mcteam/ancientgates/util/FloodUtil.java +++ b/src/org/mcteam/ancientgates/util/FloodUtil.java @@ -7,14 +7,17 @@ import java.util.logging.Level; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.mcteam.ancientgates.Conf; import org.mcteam.ancientgates.Plugin; -public class FloodUtil { +public class FloodUtil +{ + private final static int frameBlockSearchLimit = 20; + private static final Set exp1 = new HashSet(); private static final Set exp2 = new HashSet(); - static { + static + { exp1.add(BlockFace.UP); exp1.add(BlockFace.DOWN); exp1.add(BlockFace.EAST); @@ -28,9 +31,10 @@ public class FloodUtil { // For the same frame and location this set of blocks is deterministic - public static Set getGateFrameBlocks(Block block) { - Set blocks1 = getAirFloodBlocks(block, new HashSet(), exp1, Conf.getGateMaxArea()); - Set blocks2 = getAirFloodBlocks(block, new HashSet(), exp2, Conf.getGateMaxArea()); + public static Set getGateFrameBlocks(Block block) + { + Set blocks1 = getAirFloodBlocks(block, new HashSet(), exp1, frameBlockSearchLimit); + Set blocks2 = getAirFloodBlocks(block, new HashSet(), exp2, frameBlockSearchLimit); if (blocks1 == null && blocks2 == null) { return null; @@ -51,6 +55,7 @@ public class FloodUtil { return blocks1; } + public static Set getAirFloodBlocks(Block startBlock, Set foundBlocks, Set expandFaces, int limit) { if (foundBlocks == null) diff --git a/src/org/mcteam/ancientgates/util/TextUtil.java b/src/org/mcteam/ancientgates/util/TextUtil.java index 2ae7c66..371bd0f 100644 --- a/src/org/mcteam/ancientgates/util/TextUtil.java +++ b/src/org/mcteam/ancientgates/util/TextUtil.java @@ -1,52 +1,67 @@ package org.mcteam.ancientgates.util; - - -import java.util.ArrayList; -import java.util.Arrays; import java.util.List; +import org.bukkit.ChatColor; import org.bukkit.Material; -import org.mcteam.ancientgates.Conf; -public class TextUtil { - public static String titleize(String str) { - String line = Conf.colorChrome+repeat("_", 60); - String center = ".[ " + Conf.colorSystem + str + Conf.colorChrome + " ]."; +public class TextUtil +{ + public static String titleize(String str) + { + String line = ChatColor.GOLD + repeat("_", 60); + String center = ".[ " + ChatColor.YELLOW + str + ChatColor.GOLD + " ]."; int pivot = line.length() / 2; int eatLeft = center.length() / 2; int eatRight = center.length() - eatLeft; + return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight); } - public static String repeat(String s, int times) { - if (times <= 0) return ""; - else return s + repeat(s, times-1); + + public static String repeat(String s, int times) + { + if (times <= 0) + return ""; + + return s + repeat(s, times-1); } - public static ArrayList split(String str) { - return new ArrayList(Arrays.asList(str.trim().split("\\s+"))); - } - public static String implode(List list, String glue) { - String ret = ""; - for (int i=0; i list, String glue) + { + if (list.size() == 0) { + return ""; } + + String ret = list.get(0); + + for (int i=1; i list) { - return implode(list, " "); + return implode(list, ""); } - public static String getMaterialName(Material material) { + + + public static String getMaterialName(Material material) + { String ret = material.toString(); ret = ret.replace('_', ' '); ret = ret.toLowerCase(); - return ret.substring(0, 1).toUpperCase()+ret.substring(1); + + return ret.substring(0, 1).toUpperCase() + ret.substring(1); } }