From b118d4d18ce4b83c30eb68cbec37d9b5f2cbc17c Mon Sep 17 00:00:00 2001 From: Techcable Date: Sat, 25 Jun 2016 15:23:14 -0700 Subject: [PATCH] Make P.gson final Before it could be null, triggering weird issues. --- .../com/massivecraft/factions/zcore/MPlugin.java | 6 +----- .../factions/zcore/persist/MemoryFactions.java | 2 +- .../factions/zcore/persist/json/JSONFactions.java | 12 ++---------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index 47812cc1..cf402e49 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -33,7 +33,7 @@ public abstract class MPlugin extends JavaPlugin { public PermUtil perm; // Persist related - public Gson gson; + public final Gson gson = this.getGsonBuilder().create(); private Integer saveTask = null; private boolean autoSave = true; protected boolean loadSuccessful = false; @@ -80,10 +80,6 @@ public abstract class MPlugin extends JavaPlugin { this.perm = new PermUtil(this); this.persist = new Persist(this); - // GSON 2.1 is now embedded in CraftBukkit, used by the auto-updater: https://github.com/Bukkit/CraftBukkit/commit/0ed1d1fdbb1e0bc09a70bc7bfdf40c1de8411665 -// if ( ! lib.require("gson.jar", "http://search.maven.org/remotecontent?filepath=com/google/code/gson/gson/2.1/gson-2.1.jar")) return false; - this.gson = this.getGsonBuilder().create(); - this.txt = new TextUtil(); initTXT(); diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java index 8bb3f17f..f9f884c1 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFactions.java @@ -13,7 +13,7 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public abstract class MemoryFactions extends Factions { - public Map factions = new ConcurrentHashMap(); + public final Map factions = new ConcurrentHashMap(); public int nextId = 1; public void load() { diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java index 6abbd789..ecd33c4f 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/json/JSONFactions.java @@ -22,26 +22,18 @@ import java.util.logging.Level; public class JSONFactions extends MemoryFactions { // Info on how to persist - private Gson gson; + private final Gson gson; public Gson getGson() { return gson; } - public void setGson(Gson gson) { - this.gson = gson; - } - - private File file; + private final File file; public File getFile() { return file; } - public void setFile(File file) { - this.file = file; - } - // -------------------------------------------- // // CONSTRUCTORS // -------------------------------------------- //