diff --git a/src/main/java/com/Acrobot/Breeze/Configuration/FieldParser.java b/src/main/java/com/Acrobot/Breeze/Configuration/FieldParser.java index 4cce652..d51dd57 100644 --- a/src/main/java/com/Acrobot/Breeze/Configuration/FieldParser.java +++ b/src/main/java/com/Acrobot/Breeze/Configuration/FieldParser.java @@ -1,9 +1,10 @@ package com.Acrobot.Breeze.Configuration; import com.Acrobot.Breeze.Configuration.Annotations.ConfigurationComment; -import com.Acrobot.Breeze.Configuration.Annotations.Parser; import java.lang.reflect.Field; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @author Acrobot @@ -29,7 +30,7 @@ public class FieldParser { try { builder.append(field.getName()).append(": ").append(parser.parseToYAML(field.get(null))); } catch (IllegalAccessException e) { - e.printStackTrace(); + Logger.getLogger("FieldParser").log(Level.SEVERE, "Error while parsing field", e); return ""; } diff --git a/src/main/java/com/Acrobot/Breeze/Database/Database.java b/src/main/java/com/Acrobot/Breeze/Database/Database.java index 026ea69..83af262 100644 --- a/src/main/java/com/Acrobot/Breeze/Database/Database.java +++ b/src/main/java/com/Acrobot/Breeze/Database/Database.java @@ -1,8 +1,12 @@ package com.Acrobot.Breeze.Database; +import com.Acrobot.ChestShop.ChestShop; + import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.persistence.Entity; @@ -60,7 +64,7 @@ public class Database { try { table.create(fields); } catch (SQLException e) { - e.printStackTrace(); + Logger.getLogger("Database").log(Level.SEVERE, "Error while creating database from " + clazz.getName() + " (" + fields + ")", e); return false; } diff --git a/src/main/java/com/Acrobot/Breeze/Database/Row.java b/src/main/java/com/Acrobot/Breeze/Database/Row.java index 788be85..8834654 100644 --- a/src/main/java/com/Acrobot/Breeze/Database/Row.java +++ b/src/main/java/com/Acrobot/Breeze/Database/Row.java @@ -1,6 +1,8 @@ package com.Acrobot.Breeze.Database; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; /** * A class representing a Row in SQL query @@ -85,21 +87,16 @@ public class Row { try { object = clazz.newInstance(); - } catch (InstantiationException e) { - e.printStackTrace(); - return null; - } catch (IllegalAccessException e) { - e.printStackTrace(); + } catch (InstantiationException | IllegalAccessException e) { + Logger.getLogger("Row").log(Level.SEVERE, "Error while creating new instance of class " + clazz.getName() + " for row", e); return null; } for (Map.Entry value : values.entrySet()) { try { clazz.getDeclaredField(value.getKey()).set(object, value.getValue()); - } catch (NoSuchFieldException ex) { - ex.printStackTrace(); - } catch (IllegalAccessException ex) { - ex.printStackTrace(); + } catch (NoSuchFieldException | IllegalAccessException ex) { + Logger.getLogger("Row").log(Level.SEVERE, "Error while setting field " + value.getKey() + " to " + value.getValue() + " of class " + clazz.getName(), ex); } } diff --git a/src/main/java/com/Acrobot/ChestShop/Database/Migrations.java b/src/main/java/com/Acrobot/ChestShop/Database/Migrations.java index 7e918cd..f5a2a2c 100644 --- a/src/main/java/com/Acrobot/ChestShop/Database/Migrations.java +++ b/src/main/java/com/Acrobot/ChestShop/Database/Migrations.java @@ -137,7 +137,7 @@ public class Migrations { try { items.executeRawNoArgs("INSERT INTO `items` (id, code) SELECT id, code uuid FROM `items-old`"); } catch (SQLException e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while inserting items into new database while migrating to v4", e); } ChestShop.getBukkitLogger().log(Level.INFO, "Migration of items table finished in " + (System.currentTimeMillis() - start) / 1000.0 + "s!"); diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/DiscountModule.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/DiscountModule.java index 811ccba..94d72ba 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/DiscountModule.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/DiscountModule.java @@ -17,6 +17,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.util.HashSet; import java.util.Set; +import java.util.logging.Level; import static com.Acrobot.ChestShop.Events.TransactionEvent.TransactionType.BUY; @@ -44,7 +45,7 @@ public class DiscountModule implements Listener { try { config.save(ChestShop.loadFile("discounts.yml")); } catch (IOException e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while loading discounts config", e); } groupList = config.getKeys(false); diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/ItemAliasModule.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/ItemAliasModule.java index ef894b4..e039ab5 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/ItemAliasModule.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Modules/ItemAliasModule.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.IOException; import java.util.Locale; import java.util.Map; +import java.util.logging.Level; import static com.Acrobot.Breeze.Utils.StringUtil.getMinecraftStringWidth; @@ -51,7 +52,7 @@ public class ItemAliasModule implements Listener { configuration.options().copyDefaults(true); configuration.save(ChestShop.loadFile("itemAliases.yml")); } catch (IOException e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while saving item aliases config", e); } } diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java b/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java index ccf6c48..3065d6d 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/PreShopCreation/NameChecker.java @@ -11,6 +11,8 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; +import java.util.logging.Level; + import static com.Acrobot.ChestShop.Permission.OTHER_NAME_CREATE; import static com.Acrobot.ChestShop.Signs.ChestShopSign.NAME_LINE; import static com.Acrobot.ChestShop.Events.PreShopCreationEvent.CreationOutcome.UNKNOWN_PLAYER; @@ -58,7 +60,7 @@ public class NameChecker implements Listener { } } } catch (Exception e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while trying to check account for name " + name + " with player " + player.getName(), e); } } event.setOwnerAccount(account); diff --git a/src/main/java/com/Acrobot/ChestShop/Metadata/ItemDatabase.java b/src/main/java/com/Acrobot/ChestShop/Metadata/ItemDatabase.java index 9a22ad2..5ea0878 100644 --- a/src/main/java/com/Acrobot/ChestShop/Metadata/ItemDatabase.java +++ b/src/main/java/com/Acrobot/ChestShop/Metadata/ItemDatabase.java @@ -43,7 +43,7 @@ public class ItemDatabase { itemDao = DaoCreator.getDaoAndCreateTable(Item.class); handleMetadataUpdate(); } catch (SQLException e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while loading items database", e); } } @@ -59,7 +59,7 @@ public class ItemDatabase { try { versionConfig.save(configFile); } catch (IOException e) { - e.printStackTrace(); + ChestShop.getBukkitLogger().log(Level.SEVERE, "Error while updating metadata-version from " + previousVersion + " to " + newVersion, e); } } else { ChestShop.getBukkitLogger().log(Level.WARNING, "Error while updating Item Metadata database! While the plugin will still run it will work less efficiently.");