From 003afbf108c03a45b743f21f6dabdb4d3e8210f7 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 17 Apr 2013 15:49:29 +0200 Subject: [PATCH] Add in some ASCII-art and make sure the adapters have premade instances. --- src/com/massivecraft/factions/FFlag.java | 31 +++++++++++++------ src/com/massivecraft/factions/FPlayer.java | 2 +- .../massivecraft/factions/FactionColl.java | 3 -- src/com/massivecraft/factions/Factions.java | 6 ++-- .../factions/adapters/FFlagAdapter.java | 11 +++++++ .../factions/adapters/FPermAdapter.java | 11 +++++++ .../factions/adapters/RelAdapter.java | 11 +++++++ 7 files changed, 58 insertions(+), 17 deletions(-) diff --git a/src/com/massivecraft/factions/FFlag.java b/src/com/massivecraft/factions/FFlag.java index e0bae841..9c73a340 100644 --- a/src/com/massivecraft/factions/FFlag.java +++ b/src/com/massivecraft/factions/FFlag.java @@ -10,6 +10,10 @@ package com.massivecraft.factions; */ public enum FFlag { + // -------------------------------------------- // + // ENUM + // -------------------------------------------- // + // Faction flags PERMANENT("permanent", "A permanent faction will never be deleted.", false), PEACEFUL("peaceful", "Allways in truce with other factions.", false), @@ -24,14 +28,27 @@ public enum FFlag MONSTERS("monsters", "Can monsters spawn in this territory?", true), EXPLOSIONS("explosions", "Can explosions occur in this territory?", true), FIRESPREAD("firespread", "Can fire spread in territory?", true), - //LIGHTNING("lightning", "Can lightning strike in this territory?", true), Possible to add later. ENDERGRIEF("endergrief", "Can endermen grief in this territory?", false), + + // END OF LIST ; + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + private final String nicename; + public String getNicename() { return this.nicename; } + private final String desc; + public String getDescription() { return this.desc; } + public final boolean defaultDefaultValue; + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue) { this.nicename = nicename; @@ -39,15 +56,10 @@ public enum FFlag this.defaultDefaultValue = defaultDefaultValue; } - public String getNicename() - { - return this.nicename; - } + // -------------------------------------------- // + // FRODOODODFOFL + // -------------------------------------------- // - public String getDescription() - { - return this.desc; - } /** * The state for newly created factions. @@ -71,7 +83,6 @@ public enum FFlag if (str.startsWith("m")) return MONSTERS; if (str.startsWith("ex")) return EXPLOSIONS; if (str.startsWith("fi")) return FIRESPREAD; - //if (str.startsWith("l")) return LIGHTNING; if (str.startsWith("en")) return ENDERGRIEF; return null; } diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 9103a74b..eb633f90 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -371,7 +371,7 @@ public class FPlayer extends SenderEntity implements EconomyParticipato public String getName() { - return getId(); + return this.getFixedId(); } public String getTag() diff --git a/src/com/massivecraft/factions/FactionColl.java b/src/com/massivecraft/factions/FactionColl.java index 72328be3..a8ec6095 100644 --- a/src/com/massivecraft/factions/FactionColl.java +++ b/src/com/massivecraft/factions/FactionColl.java @@ -238,7 +238,6 @@ public class FactionColl extends Coll faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.EXPLOSIONS, true); faction.setFlag(FFlag.FIRESPREAD, true); - //faction.setFlag(FFlag.LIGHTNING, true); faction.setFlag(FFlag.ENDERGRIEF, true); faction.setPermittedRelations(FPerm.BUILD, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); @@ -267,7 +266,6 @@ public class FactionColl extends Coll faction.setFlag(FFlag.MONSTERS, false); faction.setFlag(FFlag.EXPLOSIONS, false); faction.setFlag(FFlag.FIRESPREAD, false); - //faction.setFlag(FFlag.LIGHTNING, false); faction.setFlag(FFlag.ENDERGRIEF, false); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); @@ -296,7 +294,6 @@ public class FactionColl extends Coll faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.EXPLOSIONS, true); faction.setFlag(FFlag.FIRESPREAD, true); - //faction.setFlag(FFlag.LIGHTNING, true); faction.setFlag(FFlag.ENDERGRIEF, true); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index c08c4bd8..a518849b 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -118,9 +118,9 @@ public class Factions extends MPlugin .registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get()) .registerTypeAdapter(Board.class, BoardAdapter.get()) .registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get()) - .registerTypeAdapter(Rel.class, new RelAdapter()) - .registerTypeAdapter(FPerm.class, new FPermAdapter()) - .registerTypeAdapter(FFlag.class, new FFlagAdapter()) + .registerTypeAdapter(Rel.class, RelAdapter.get()) + .registerTypeAdapter(FPerm.class, FPermAdapter.get()) + .registerTypeAdapter(FFlag.class, FFlagAdapter.get()) ; } diff --git a/src/com/massivecraft/factions/adapters/FFlagAdapter.java b/src/com/massivecraft/factions/adapters/FFlagAdapter.java index 20884aa2..bf8b6a62 100644 --- a/src/com/massivecraft/factions/adapters/FFlagAdapter.java +++ b/src/com/massivecraft/factions/adapters/FFlagAdapter.java @@ -10,6 +10,17 @@ import com.massivecraft.mcore.xlib.gson.JsonParseException; public class FFlagAdapter implements JsonDeserializer { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static FFlagAdapter i = new FFlagAdapter(); + public static FFlagAdapter get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public FFlag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { diff --git a/src/com/massivecraft/factions/adapters/FPermAdapter.java b/src/com/massivecraft/factions/adapters/FPermAdapter.java index f619ee19..bb4b22f4 100644 --- a/src/com/massivecraft/factions/adapters/FPermAdapter.java +++ b/src/com/massivecraft/factions/adapters/FPermAdapter.java @@ -11,6 +11,17 @@ import com.massivecraft.factions.FPerm; public class FPermAdapter implements JsonDeserializer { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static FPermAdapter i = new FPermAdapter(); + public static FPermAdapter get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public FPerm deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { diff --git a/src/com/massivecraft/factions/adapters/RelAdapter.java b/src/com/massivecraft/factions/adapters/RelAdapter.java index 621132d8..5025be5e 100644 --- a/src/com/massivecraft/factions/adapters/RelAdapter.java +++ b/src/com/massivecraft/factions/adapters/RelAdapter.java @@ -11,6 +11,17 @@ import com.massivecraft.factions.Rel; public class RelAdapter implements JsonDeserializer { + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static RelAdapter i = new RelAdapter(); + public static RelAdapter get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + @Override public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {