Skip to content

Commit

Permalink
Formatting v2
Browse files Browse the repository at this point in the history
Also item rollbacks are 100x better. Not perfect, just better.
  • Loading branch information
ezeiger92 committed Jul 24, 2018
1 parent 02030cb commit 3902e9d
Show file tree
Hide file tree
Showing 100 changed files with 1,956 additions and 1,448 deletions.
9 changes: 6 additions & 3 deletions src/main/java/me/botsko/prism/ConfigBase.java
Expand Up @@ -84,7 +84,8 @@ protected FileConfiguration loadConfig(String default_folder, String filename) {
final File file = getFilename(filename);
if (file.exists()) {
return YamlConfiguration.loadConfiguration(file);
} else {
}
else {
// Look for defaults in the jar
final InputStream defConfigStream = plugin.getResource(default_folder + filename + ".yml");
if (defConfigStream != null) {
Expand All @@ -102,7 +103,8 @@ protected void saveConfig(String filename, FileConfiguration config) {
final File file = getFilename(filename);
try {
config.save(file);
} catch (final IOException e) {
}
catch (final IOException e) {
// Prism.log("Could not save the configuration file to "+file);
// Throw exception
}
Expand All @@ -117,7 +119,8 @@ protected void write(String filename, FileConfiguration config) {
saveConfig(filename, config);
bw.flush();
bw.close();
} catch (final IOException ignored) {
}
catch (final IOException ignored) {

}
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/me/botsko/prism/Language.java
Expand Up @@ -30,10 +30,12 @@ public String getString(String key) {
final String msg = lang.getString(key);
if (msg != null) {
return colorize(msg);
} else {
}
else {
// Prism.log("No language support found for " + key);
}
} else {
}
else {
// Prism.log("Language file configuration was not loaded correctly.");
}
return "";
Expand Down
99 changes: 66 additions & 33 deletions src/main/java/me/botsko/prism/Prism.java
Expand Up @@ -139,7 +139,8 @@ public void onEnable() {
try {
final Metrics metrics = new Metrics(this);
metrics.start();
} catch (final IOException e) {
}
catch (final IOException e) {
log("MCStats submission failed.");
}
}
Expand All @@ -158,7 +159,8 @@ public void onEnable() {
if (test_conn != null) {
try {
test_conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
handleDatabaseException(e);
}
}
Expand Down Expand Up @@ -296,7 +298,8 @@ public void loadConfig() {
illegalEntities = getConfig().getStringList("prism.appliers.never-spawn-entity").stream().map(s -> {
try {
return EntityType.valueOf(s.toUpperCase());
} catch (Exception e) {
}
catch (Exception e) {
}

return null;
Expand Down Expand Up @@ -374,7 +377,8 @@ public static Connection dbc() {
Connection con = null;
try {
con = pool.getConnection();
} catch (final SQLException e) {
}
catch (final SQLException e) {
log("Database connection failed. " + e.getMessage());
if (!e.getMessage().contains("Pool empty")) {
e.printStackTrace();
Expand Down Expand Up @@ -412,7 +416,8 @@ public void handleDatabaseException(SQLException e) {
if (attemptToRescueConnection(e)) {
return;
}
} catch (final SQLException e1) {
}
catch (final SQLException e1) {
}
log("Database connection error: " + e.getMessage());
if (e.getMessage().contains("marked as crashed")) {
Expand Down Expand Up @@ -513,19 +518,23 @@ protected void setupDatabase() {
+ "`block_subid` mediumint(5) NOT NULL DEFAULT 0," + "PRIMARY KEY (`material`, `state`),"
+ "UNIQUE KEY (`block_id`, `block_subid`)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
st.executeUpdate(query);
} catch (final SQLException e) {
}
catch (final SQLException e) {
log("Database connection error: " + e.getMessage());
e.printStackTrace();
} finally {
}
finally {
if (st != null)
try {
st.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (conn != null)
try {
conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
}
}
Expand All @@ -552,23 +561,28 @@ protected void cacheActionPrimaryKeys() {

debug("Loaded " + prismActions.size() + " actions into the cache.");

} catch (final SQLException e) {
}
catch (final SQLException e) {
handleDatabaseException(e);
} finally {
}
finally {
if (rs != null)
try {
rs.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (s != null)
try {
s.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (conn != null)
try {
conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
}
}
Expand Down Expand Up @@ -597,26 +611,32 @@ public static void addActionName(String actionName) {
if (rs.next()) {
Prism.log("Registering new action type to the database/cache: " + actionName + " " + rs.getInt(1));
prismActions.put(actionName, rs.getInt(1));
} else {
}
else {
throw new SQLException("Insert statement failed - no generated key obtained.");
}
} catch (final SQLException e) {
}
catch (final SQLException e) {

} finally {
}
finally {
if (rs != null)
try {
rs.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (s != null)
try {
s.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (conn != null)
try {
conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
}
}
Expand All @@ -640,23 +660,28 @@ protected void cacheWorldPrimaryKeys() {
prismWorlds.put(rs.getString(2), rs.getInt(1));
}
debug("Loaded " + prismWorlds.size() + " worlds into the cache.");
} catch (final SQLException e) {
}
catch (final SQLException e) {
handleDatabaseException(e);
} finally {
}
finally {
if (rs != null)
try {
rs.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (s != null)
try {
s.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (conn != null)
try {
conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
}
}
Expand Down Expand Up @@ -685,26 +710,32 @@ public static void addWorldName(String worldName) {
if (rs.next()) {
Prism.log("Registering new world to the database/cache: " + worldName + " " + rs.getInt(1));
prismWorlds.put(worldName, rs.getInt(1));
} else {
}
else {
throw new SQLException("Insert statement failed - no generated key obtained.");
}
} catch (final SQLException e) {
}
catch (final SQLException e) {

} finally {
}
finally {
if (rs != null)
try {
rs.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (s != null)
try {
s.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
if (conn != null)
try {
conn.close();
} catch (final SQLException e) {
}
catch (final SQLException e) {
}
}
}
Expand All @@ -731,11 +762,13 @@ public void checkPluginDependancies() {
try {
WorldEdit.getInstance().getEventBus().register(new PrismBlockEditHandler());
log("WorldEdit found. Associated features enabled.");
} catch (Throwable error) {
}
catch (Throwable error) {
log("Required WorldEdit version is 6.0.0 or greater! Certain optional features of Prism disabled.");
}

} else {
}
else {
log("WorldEdit not found. Certain optional features of Prism disabled.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/botsko/prism/PrismConfig.java
Expand Up @@ -129,7 +129,7 @@ public FileConfiguration getConfig() {
final List<String> illegalBlocks = new ArrayList<String>();
illegalBlocks.add("water");
illegalBlocks.add("lava");

config.addDefault("prism.appliers.never-place-block", illegalBlocks);

// Tracking
Expand Down

0 comments on commit 3902e9d

Please sign in to comment.