From fd3c9da9ffc8a50c168e7ec499c236fa2a00ae1c Mon Sep 17 00:00:00 2001 From: Jascha Starke Date: Sat, 28 Sep 2013 17:25:06 +0200 Subject: [PATCH] 2 NPE fix --- .../minecraft/limitedcreative/blockstate/DBQueries.java | 7 ++++++- .../limitedcreative/blockstate/SyncronizedModel.java | 2 +- src/main/resources/lang/messages.properties | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DBQueries.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DBQueries.java index 322faa6..7a70e01 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DBQueries.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/DBQueries.java @@ -219,8 +219,13 @@ public class DBQueries { try { switch (db.getType()) { case SQLite: - return GameMode.getByValue(rs.getInt("gm")); + int gm = rs.getInt("gm"); + if (rs.wasNull()) + return null; + return GameMode.getByValue(gm); case MySQL: + if (rs.getString("gm") == null) + return null; return GameMode.valueOf(rs.getString("gm")); default: throw new RuntimeException("Unsupported Database-Type."); diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/SyncronizedModel.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/SyncronizedModel.java index 16de438..3d3a498 100644 --- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/SyncronizedModel.java +++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/SyncronizedModel.java @@ -115,7 +115,7 @@ public class SyncronizedModel extends AbstractModel implements DBModel { @Override public boolean isRestricted(Block block) { BlockState state = getState(block); - return state != null ? state.isRestricted() : null; + return state != null ? state.isRestricted() : false; } public BlockState getState(Block block) { diff --git a/src/main/resources/lang/messages.properties b/src/main/resources/lang/messages.properties index 8d508dc..2b8d7d9 100644 --- a/src/main/resources/lang/messages.properties +++ b/src/main/resources/lang/messages.properties @@ -36,7 +36,7 @@ command.blockstate.migration_finished: Database migration of {0} records success command.blockstate.migration_finished_restart: A Server-Restart is required! command.blockstate.migration_error: Migration failed with error: {0} command.blockstate.migrate_useronline_error: There are players on the Server. The migration shouldn't be run with active players. -command.blockstate.migrate_confirm: Are you sure you want to start the Migration? It may take a very long time and much CPU. To confirm execution run the command with the following added: {0} +command.blockstate.migrate_confirm: Are you sure you want to start the migration? It may take a very long time and much CPU. To confirm execution run the command with the following added: {0} cmdblock.blocked: This command is blocked while in creative mode. cmdblock.blocked.requires_worldedit: WorlEdit is required to use this command