mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-07-13 15:15:00 +02:00
Replaced raw stack trace dumps with helpful error messages.
This commit is contained in:
parent
aac17990bc
commit
bb404380f5
|
@ -60,9 +60,8 @@ public class IslandCreateCommand extends CompositeCommand {
|
||||||
.reason(Reason.CREATE)
|
.reason(Reason.CREATE)
|
||||||
.build();
|
.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getPlugin().getLogger().severe("Could not create island for player.");
|
getPlugin().getLogger().severe("Could not create island for player. " + e.getMessage());
|
||||||
user.sendMessage("commands.island.create.unable-create-island");
|
user.sendMessage("commands.island.create.unable-create-island");
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,8 @@ public class IslandResetCommand extends CompositeCommand {
|
||||||
.oldIsland(oldIsland)
|
.oldIsland(oldIsland)
|
||||||
.build();
|
.build();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
getPlugin().getLogger().severe("Could not create island for player.");
|
getPlugin().getLogger().severe("Could not create island for player. " + e.getMessage());
|
||||||
user.sendMessage("commands.island.create.unable-create-island");
|
user.sendMessage("commands.island.create.unable-create-island");
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter {
|
||||||
config = new YamlConfiguration();
|
config = new YamlConfiguration();
|
||||||
config.load(yamlFile);
|
config.load(yamlFile);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().severe("Could not load yaml file from database " + tableName + " " + fileName + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Create the missing file
|
// Create the missing file
|
||||||
|
@ -93,7 +94,7 @@ public class FlatFileDatabaseConnecter implements DatabaseConnecter {
|
||||||
try {
|
try {
|
||||||
yamlConfig.save(file);
|
yamlConfig.save(file);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
Bukkit.getLogger().severe("Could not save yaml file to database " + tableName + " " + fileName + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -369,11 +369,10 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
plugin.getLogger().info("DEBUG: there is an adapter");
|
plugin.getLogger().info("DEBUG: there is an adapter");
|
||||||
// A conversion adapter has been defined
|
// A conversion adapter has been defined
|
||||||
// A conversion adapter has been defined
|
|
||||||
try {
|
try {
|
||||||
config.set(storageLocation, ((AdapterInterface<?,?>)adapterNotation.value().newInstance()).deserialize(value));
|
config.set(storageLocation, ((AdapterInterface<?,?>)adapterNotation.value().newInstance()).deserialize(value));
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not instatiate adapter " + adapterNotation.value().getName() + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
// We are done here
|
// We are done here
|
||||||
continue fields;
|
continue fields;
|
||||||
|
@ -503,7 +502,7 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Maybe this value does not exist?
|
// Maybe this value does not exist?
|
||||||
// TODO return something?
|
// TODO return something?
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not deserialize enum: " + clazz.getCanonicalName() + " " + value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -522,7 +521,9 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
File tableFolder = new File(dataFolder, dataObject.getSimpleName());
|
File tableFolder = new File(dataFolder, dataObject.getSimpleName());
|
||||||
if (tableFolder.exists()) {
|
if (tableFolder.exists()) {
|
||||||
File file = new File(tableFolder, fileName);
|
File file = new File(tableFolder, fileName);
|
||||||
file.delete();
|
if (!file.delete()) {
|
||||||
|
plugin.getLogger().severe("Could not delete yaml database object! " + file.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@ public class PlayersManager{
|
||||||
|
|
||||||
private HashMap<UUID, Players> playerCache;
|
private HashMap<UUID, Players> playerCache;
|
||||||
private Set<UUID> inTeleport;
|
private Set<UUID> inTeleport;
|
||||||
private HashMap<String, UUID> nameCache;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a memory cache of online player information
|
* Provides a memory cache of online player information
|
||||||
|
@ -62,7 +61,7 @@ public class PlayersManager{
|
||||||
playerCache.put(player.getPlayerUUID(), player);
|
playerCache.put(player.getPlayerUUID(), player);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not load players from the database!" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ public class PlayersManager{
|
||||||
try {
|
try {
|
||||||
handler.saveObject(player);
|
handler.saveObject(player);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not save player " + player.getPlayerName() + " "+ player.getUniqueId() + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -94,7 +93,7 @@ public class PlayersManager{
|
||||||
try {
|
try {
|
||||||
handler.saveObject(player);
|
handler.saveObject(player);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not save player " + player.getPlayerName() + " "+ player.getUniqueId() + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,7 +136,7 @@ public class PlayersManager{
|
||||||
try {
|
try {
|
||||||
player = handler.loadObject(playerUUID.toString());
|
player = handler.loadObject(playerUUID.toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not load player " + playerUUID + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
|
@ -160,26 +159,16 @@ public class PlayersManager{
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void removeOnlinePlayer(final UUID player) {
|
public void removeOnlinePlayer(final UUID player) {
|
||||||
// plugin.getLogger().info("Removing player from cache: " + player);
|
save(player);
|
||||||
if (playerCache.containsKey(player)) {
|
|
||||||
try {
|
|
||||||
handler.saveObject(playerCache.get(player));
|
|
||||||
playerCache.remove(player);
|
playerCache.remove(player);
|
||||||
} catch (IllegalAccessException | IllegalArgumentException
|
|
||||||
| InvocationTargetException | SecurityException
|
|
||||||
| InstantiationException | NoSuchMethodException
|
|
||||||
| IntrospectionException | SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all players on the server now from cache and saves their info
|
* Saves all players on the server and clears the cache
|
||||||
*/
|
*/
|
||||||
public void removeAllPlayers() {
|
public void removeAllPlayers() {
|
||||||
for (UUID pl : playerCache.keySet()) {
|
for (UUID pl : playerCache.keySet()) {
|
||||||
removeOnlinePlayer(pl);
|
save(pl);
|
||||||
}
|
}
|
||||||
playerCache.clear();
|
playerCache.clear();
|
||||||
}
|
}
|
||||||
|
@ -597,7 +586,7 @@ public class PlayersManager{
|
||||||
| InvocationTargetException | SecurityException
|
| InvocationTargetException | SecurityException
|
||||||
| InstantiationException | NoSuchMethodException
|
| InstantiationException | NoSuchMethodException
|
||||||
| IntrospectionException | SQLException e) {
|
| IntrospectionException | SQLException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not save player to database: " + playerUUID + " " + e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class IslandsManager {
|
||||||
try {
|
try {
|
||||||
handler.deleteObject(island);
|
handler.deleteObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not delete island from database! " + e.getMessage());
|
||||||
}
|
}
|
||||||
// Remove blocks from world
|
// Remove blocks from world
|
||||||
new DeleteIslandChunks(plugin, island);
|
new DeleteIslandChunks(plugin, island);
|
||||||
|
@ -716,7 +716,7 @@ public class IslandsManager {
|
||||||
islandCache.addIsland(island);
|
islandCache.addIsland(island);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not load islands to cache! " + e.getMessage());
|
||||||
}
|
}
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
plugin.getLogger().info("DEBUG: islands loaded");
|
plugin.getLogger().info("DEBUG: islands loaded");
|
||||||
|
@ -930,7 +930,7 @@ public class IslandsManager {
|
||||||
try {
|
try {
|
||||||
handler.saveObject(island);
|
handler.saveObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not save island to datavase when running async! " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -943,7 +943,7 @@ public class IslandsManager {
|
||||||
try {
|
try {
|
||||||
handler.saveObject(island);
|
handler.saveObject(island);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not save island to datavase when running sync! " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
import us.tastybento.bskyblock.database.DatabaseConnecter;
|
||||||
|
@ -24,8 +25,7 @@ public class MySQLDatabaseConnecter implements DatabaseConnecter {
|
||||||
try {
|
try {
|
||||||
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
Class.forName("com.mysql.jdbc.Driver").newInstance();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
Bukkit.getLogger().severe("Could not instantiate JDBC driver! " + e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
// jdbc:mysql://localhost:3306/Peoples?autoReconnect=true&useSSL=false
|
// jdbc:mysql://localhost:3306/Peoples?autoReconnect=true&useSSL=false
|
||||||
connectionUrl = "jdbc:mysql://" + dbSettings.getHost() + "/" + dbSettings.getDatabaseName() + "?autoReconnect=true&useSSL=false&allowMultiQueries=true";
|
connectionUrl = "jdbc:mysql://" + dbSettings.getHost() + "/" + dbSettings.getDatabaseName() + "?autoReconnect=true&useSSL=false&allowMultiQueries=true";
|
||||||
|
|
|
@ -113,10 +113,8 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
// Check if the table exists in the database and if not, create it
|
// Check if the table exists in the database and if not, create it
|
||||||
try {
|
try {
|
||||||
createSchema();
|
createSchema();
|
||||||
} catch (IntrospectionException e) {
|
} catch (IntrospectionException | SQLException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not create database schema! " + e.getMessage());
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +186,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
plugin.getLogger().info("DEBUG: pstmt = " + pstmt.toString());
|
plugin.getLogger().info("DEBUG: pstmt = " + pstmt.toString());
|
||||||
pstmt.executeUpdate();
|
pstmt.executeUpdate();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not create database schema! " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
// Close the database properly
|
// Close the database properly
|
||||||
MySQLDatabaseResourceCloser.close(pstmt);
|
MySQLDatabaseResourceCloser.close(pstmt);
|
||||||
|
@ -858,9 +856,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
Class<Enum> enumClass = (Class<Enum>)clazz;
|
Class<Enum> enumClass = (Class<Enum>)clazz;
|
||||||
value = Enum.valueOf(enumClass, (String)value);
|
value = Enum.valueOf(enumClass, (String)value);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Maybe this value does not exist?
|
plugin.getLogger().severe("Could not deserialize enum! " + e.getMessage());
|
||||||
// TODO return something?
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -952,7 +948,7 @@ public class MySQLDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||||
return resultSet.getBoolean(1);
|
return resultSet.getBoolean(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
plugin.getLogger().severe("Could not check if key exists in database! " + key + " " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
MySQLDatabaseResourceCloser.close(resultSet);
|
MySQLDatabaseResourceCloser.close(resultSet);
|
||||||
MySQLDatabaseResourceCloser.close(preparedStatement);
|
MySQLDatabaseResourceCloser.close(preparedStatement);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user