Add in some ASCII-art and make sure the adapters have premade instances.

This commit is contained in:
Olof Larsson 2013-04-17 15:49:29 +02:00
parent f4d799e978
commit 003afbf108
7 changed files with 58 additions and 17 deletions

View File

@ -10,6 +10,10 @@ package com.massivecraft.factions;
*/ */
public enum FFlag public enum FFlag
{ {
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //
// Faction flags // Faction flags
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false), PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false),
PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false), PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false),
@ -24,14 +28,27 @@ public enum FFlag
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true), MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true),
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true), EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true),
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true), FIRESPREAD("firespread", "<i>Can fire spread in territory?", true),
//LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true), Possible to add later.
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false), ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false),
// END OF LIST
; ;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final String nicename; private final String nicename;
public String getNicename() { return this.nicename; }
private final String desc; private final String desc;
public String getDescription() { return this.desc; }
public final boolean defaultDefaultValue; public final boolean defaultDefaultValue;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue) private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue)
{ {
this.nicename = nicename; this.nicename = nicename;
@ -39,15 +56,10 @@ public enum FFlag
this.defaultDefaultValue = defaultDefaultValue; this.defaultDefaultValue = defaultDefaultValue;
} }
public String getNicename() // -------------------------------------------- //
{ // FRODOODODFOFL
return this.nicename; // -------------------------------------------- //
}
public String getDescription()
{
return this.desc;
}
/** /**
* The state for newly created factions. * The state for newly created factions.
@ -71,7 +83,6 @@ public enum FFlag
if (str.startsWith("m")) return MONSTERS; if (str.startsWith("m")) return MONSTERS;
if (str.startsWith("ex")) return EXPLOSIONS; if (str.startsWith("ex")) return EXPLOSIONS;
if (str.startsWith("fi")) return FIRESPREAD; if (str.startsWith("fi")) return FIRESPREAD;
//if (str.startsWith("l")) return LIGHTNING;
if (str.startsWith("en")) return ENDERGRIEF; if (str.startsWith("en")) return ENDERGRIEF;
return null; return null;
} }

View File

@ -371,7 +371,7 @@ public class FPlayer extends SenderEntity<FPlayer> implements EconomyParticipato
public String getName() public String getName()
{ {
return getId(); return this.getFixedId();
} }
public String getTag() public String getTag()

View File

@ -238,7 +238,6 @@ public class FactionColl extends Coll<Faction>
faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.MONSTERS, true);
faction.setFlag(FFlag.EXPLOSIONS, true); faction.setFlag(FFlag.EXPLOSIONS, true);
faction.setFlag(FFlag.FIRESPREAD, true); faction.setFlag(FFlag.FIRESPREAD, true);
//faction.setFlag(FFlag.LIGHTNING, true);
faction.setFlag(FFlag.ENDERGRIEF, 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); 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>
faction.setFlag(FFlag.MONSTERS, false); faction.setFlag(FFlag.MONSTERS, false);
faction.setFlag(FFlag.EXPLOSIONS, false); faction.setFlag(FFlag.EXPLOSIONS, false);
faction.setFlag(FFlag.FIRESPREAD, false); faction.setFlag(FFlag.FIRESPREAD, false);
//faction.setFlag(FFlag.LIGHTNING, false);
faction.setFlag(FFlag.ENDERGRIEF, 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); 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>
faction.setFlag(FFlag.MONSTERS, true); faction.setFlag(FFlag.MONSTERS, true);
faction.setFlag(FFlag.EXPLOSIONS, true); faction.setFlag(FFlag.EXPLOSIONS, true);
faction.setFlag(FFlag.FIRESPREAD, true); faction.setFlag(FFlag.FIRESPREAD, true);
//faction.setFlag(FFlag.LIGHTNING, true);
faction.setFlag(FFlag.ENDERGRIEF, 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); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY);

View File

@ -118,9 +118,9 @@ public class Factions extends MPlugin
.registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get()) .registerTypeAdapter(TerritoryAccess.class, TerritoryAccessAdapter.get())
.registerTypeAdapter(Board.class, BoardAdapter.get()) .registerTypeAdapter(Board.class, BoardAdapter.get())
.registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get()) .registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get())
.registerTypeAdapter(Rel.class, new RelAdapter()) .registerTypeAdapter(Rel.class, RelAdapter.get())
.registerTypeAdapter(FPerm.class, new FPermAdapter()) .registerTypeAdapter(FPerm.class, FPermAdapter.get())
.registerTypeAdapter(FFlag.class, new FFlagAdapter()) .registerTypeAdapter(FFlag.class, FFlagAdapter.get())
; ;
} }

View File

@ -10,6 +10,17 @@ import com.massivecraft.mcore.xlib.gson.JsonParseException;
public class FFlagAdapter implements JsonDeserializer<FFlag> public class FFlagAdapter implements JsonDeserializer<FFlag>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FFlagAdapter i = new FFlagAdapter();
public static FFlagAdapter get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public FFlag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException public FFlag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{ {

View File

@ -11,6 +11,17 @@ import com.massivecraft.factions.FPerm;
public class FPermAdapter implements JsonDeserializer<FPerm> public class FPermAdapter implements JsonDeserializer<FPerm>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FPermAdapter i = new FPermAdapter();
public static FPermAdapter get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public FPerm deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException public FPerm deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{ {

View File

@ -11,6 +11,17 @@ import com.massivecraft.factions.Rel;
public class RelAdapter implements JsonDeserializer<Rel> public class RelAdapter implements JsonDeserializer<Rel>
{ {
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static RelAdapter i = new RelAdapter();
public static RelAdapter get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override @Override
public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException public Rel deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
{ {