2013-04-09 13:24:55 +02:00
|
|
|
package com.massivecraft.factions;
|
2011-10-23 17:30:41 +02:00
|
|
|
|
2013-04-22 10:37:04 +02:00
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2013-04-22 16:58:22 +02:00
|
|
|
import com.massivecraft.factions.entity.UConf;
|
|
|
|
|
2011-10-23 20:50:49 +02:00
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
/**
|
|
|
|
* Flags that describe the nature of a faction and it's territory.
|
|
|
|
* Can monsters spawn there? May fire spread etc? Is the faction permanent?
|
|
|
|
* These flags have nothing to do with player-permission.
|
|
|
|
*
|
|
|
|
* The flags are either true or false.
|
|
|
|
*/
|
2011-10-24 02:33:30 +02:00
|
|
|
public enum FFlag
|
2011-10-23 17:30:41 +02:00
|
|
|
{
|
2013-04-17 15:49:29 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// ENUM
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
// Faction flags
|
2011-10-25 21:18:08 +02:00
|
|
|
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false),
|
|
|
|
PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false),
|
|
|
|
INFPOWER("infpower", "<i>This flag gives the faction infinite power.", false),
|
2011-10-23 20:50:49 +02:00
|
|
|
// This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level
|
2011-10-23 17:30:41 +02:00
|
|
|
|
|
|
|
// (Faction) Territory flags
|
2011-10-24 03:02:25 +02:00
|
|
|
// If a faction later could have many different territories this would probably be in another enum
|
2011-10-25 21:18:08 +02:00
|
|
|
POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true),
|
|
|
|
PVP("pvp", "<i>Can you PVP in territory?", true),
|
|
|
|
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false),
|
|
|
|
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true),
|
|
|
|
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true),
|
|
|
|
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true),
|
|
|
|
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false),
|
2013-04-17 15:49:29 +02:00
|
|
|
|
|
|
|
// END OF LIST
|
2011-10-23 17:30:41 +02:00
|
|
|
;
|
|
|
|
|
2013-04-17 15:49:29 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// FIELDS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-10-23 20:50:49 +02:00
|
|
|
private final String nicename;
|
2013-04-17 15:49:29 +02:00
|
|
|
public String getNicename() { return this.nicename; }
|
|
|
|
|
2011-10-23 20:50:49 +02:00
|
|
|
private final String desc;
|
2013-04-17 15:49:29 +02:00
|
|
|
public String getDescription() { return this.desc; }
|
|
|
|
|
2013-04-22 10:37:04 +02:00
|
|
|
public final boolean defaultDefault;
|
|
|
|
public boolean getDefaultDefault() { return this.defaultDefault; }
|
2011-10-23 20:50:49 +02:00
|
|
|
|
2013-04-17 15:49:29 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2013-04-22 10:37:04 +02:00
|
|
|
private FFlag(String nicename, final String desc, boolean defaultDefault)
|
2011-10-23 20:50:49 +02:00
|
|
|
{
|
|
|
|
this.nicename = nicename;
|
|
|
|
this.desc = desc;
|
2013-04-22 10:37:04 +02:00
|
|
|
this.defaultDefault = defaultDefault;
|
2011-10-23 20:50:49 +02:00
|
|
|
}
|
|
|
|
|
2013-04-17 15:49:29 +02:00
|
|
|
// -------------------------------------------- //
|
2013-04-22 10:37:04 +02:00
|
|
|
// DEFAULTS
|
2013-04-17 15:49:29 +02:00
|
|
|
// -------------------------------------------- //
|
2011-10-23 20:50:49 +02:00
|
|
|
|
2013-04-22 16:58:22 +02:00
|
|
|
public boolean getDefault(Object o)
|
2011-10-23 17:30:41 +02:00
|
|
|
{
|
2013-04-23 14:00:18 +02:00
|
|
|
Boolean ret = UConf.get(o).defaultFactionFlags.get(this);
|
2013-04-22 10:37:04 +02:00
|
|
|
if (ret == null) return this.getDefaultDefault();
|
2011-10-23 22:08:57 +02:00
|
|
|
return ret;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
|
|
|
|
2013-04-22 10:37:04 +02:00
|
|
|
public static Map<FFlag, Boolean> getDefaultDefaults()
|
|
|
|
{
|
|
|
|
Map<FFlag, Boolean> ret = new LinkedHashMap<FFlag, Boolean>();
|
|
|
|
for (FFlag flag : values())
|
|
|
|
{
|
|
|
|
ret.put(flag, flag.getDefaultDefault());
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// FRODOODODFOFL
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2011-10-24 02:33:30 +02:00
|
|
|
public static FFlag parse(String str)
|
2011-10-23 20:50:49 +02:00
|
|
|
{
|
|
|
|
str = str.toLowerCase();
|
|
|
|
if (str.startsWith("per")) return PERMANENT;
|
|
|
|
if (str.startsWith("pea")) return PEACEFUL;
|
|
|
|
if (str.startsWith("i")) return INFPOWER;
|
|
|
|
if (str.startsWith("pow")) return POWERLOSS;
|
|
|
|
if (str.startsWith("pvp")) return PVP;
|
|
|
|
if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE;
|
|
|
|
if (str.startsWith("m")) return MONSTERS;
|
2011-10-25 21:18:08 +02:00
|
|
|
if (str.startsWith("ex")) return EXPLOSIONS;
|
2011-10-23 20:50:49 +02:00
|
|
|
if (str.startsWith("fi")) return FIRESPREAD;
|
2011-10-25 21:18:08 +02:00
|
|
|
if (str.startsWith("en")) return ENDERGRIEF;
|
2011-10-23 20:50:49 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getStateInfo(boolean value, boolean withDesc)
|
|
|
|
{
|
2011-10-24 13:02:48 +02:00
|
|
|
String ret = (value ? "<g>YES" : "<b>NOO") + "<c> " + this.getNicename();
|
2011-10-23 20:50:49 +02:00
|
|
|
if (withDesc)
|
|
|
|
{
|
|
|
|
ret += " " + this.getDescription();
|
|
|
|
}
|
|
|
|
return ret;
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|
2013-04-22 10:37:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2011-10-23 17:30:41 +02:00
|
|
|
}
|