From 0a5707c4d8841da76be2a0cf787fab43470917db Mon Sep 17 00:00:00 2001 From: Acrobot Date: Sat, 25 Aug 2012 12:50:16 +0200 Subject: [PATCH] Small fixes --- com/Acrobot/Breeze/Utils/NumberUtil.java | 9 +++------ com/Acrobot/ChestShop/DB/Generator.java | 6 +++++- com/Acrobot/ChestShop/Signs/ChestShopSign.java | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/com/Acrobot/Breeze/Utils/NumberUtil.java b/com/Acrobot/Breeze/Utils/NumberUtil.java index 94b3f26..48630f9 100644 --- a/com/Acrobot/Breeze/Utils/NumberUtil.java +++ b/com/Acrobot/Breeze/Utils/NumberUtil.java @@ -73,9 +73,10 @@ public class NumberUtil { public static double roundUp(double number) { return Math.ceil(number * 100) / 100; } + /** * Rounds the number down to two decimal points - * + * * @param number Number to round * @return Rounded number */ @@ -101,16 +102,12 @@ public class NumberUtil { } /** - * Converts a number to roman + * Converts a number to roman (only 1-9, because of the enchantment decorations) * * @param number number to convert * @return Converted number */ public static String toRoman(int number) { - if (number < 1 || number > 9) { - throw new IllegalArgumentException("The number must be in range 1-9 (This is only for enchantment level decoration)"); - } - switch (number) { case 1: return "I"; diff --git a/com/Acrobot/ChestShop/DB/Generator.java b/com/Acrobot/ChestShop/DB/Generator.java index 841a9db..5644428 100644 --- a/com/Acrobot/ChestShop/DB/Generator.java +++ b/com/Acrobot/ChestShop/DB/Generator.java @@ -5,6 +5,7 @@ import com.Acrobot.ChestShop.ChestShop; import com.avaje.ebean.ExpressionList; import org.bukkit.Material; +import javax.persistence.PersistenceException; import java.io.*; import java.util.List; @@ -162,7 +163,10 @@ public class Generator implements Runnable { fileEnd(generationTime); } catch (Exception e) { ChestShop.getBukkitLogger().severe("Couldn't generate statistics page!"); - e.printStackTrace(); + + if (!(e instanceof PersistenceException)) { + e.printStackTrace(); + } } } } diff --git a/com/Acrobot/ChestShop/Signs/ChestShopSign.java b/com/Acrobot/ChestShop/Signs/ChestShopSign.java index bdf35da..0d3e84d 100644 --- a/com/Acrobot/ChestShop/Signs/ChestShopSign.java +++ b/com/Acrobot/ChestShop/Signs/ChestShopSign.java @@ -21,14 +21,14 @@ public class ChestShopSign { public static final byte ITEM_LINE = 3; public static final Pattern[] SHOP_SIGN_PATTERN = { - Pattern.compile("^$|^\\w.+$"), + Pattern.compile("^[\\w ]*$"), Pattern.compile("[0-9]+"), - Pattern.compile(".+"), + Pattern.compile("^[\\dbs(free) :]+$"), Pattern.compile("[\\w : -]+") }; public static boolean isAdminShop(String owner) { - return owner.toLowerCase().replace(" ", "").equals(Config.getString(ADMIN_SHOP_NAME).toLowerCase().replace(" ", "")); + return owner.replace(" ", "").equalsIgnoreCase(Config.getString(ADMIN_SHOP_NAME).replace(" ", "")); } public static boolean isAdminShop(Sign sign) {