This commit is contained in:
Olof Larsson
2011-10-23 20:50:49 +02:00
parent 842844969b
commit 98c5230655
19 changed files with 297 additions and 155 deletions

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions.struct;
import com.massivecraft.factions.Conf;
/**
* Flags that describe the nature of a faction and it's territory.
* Can monsters spawn there? May fire spread etc? Is the faction permanent?
@ -10,27 +12,51 @@ package com.massivecraft.factions.struct;
public enum FactionFlag
{
// Faction flags
PERMANENT,
PEACEFUL, // This faction is friends with everyone
INFPOWER, // This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false, false),
PEACEFUL("peaceful", "<i>Allways in truce with other factions.", false, false),
INFPOWER("infpower", "<i>This flag gives the faction infinite power.", false, false),
// This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level
// (Faction) Territory flags
POWERLOSS, // Regardless of death-reason players loose power on death IF powerloss is true in this territory
PVP,
FRIENDLYFIRE, // Can members/allies/friends damage eachother in this territory?
MONSTERS,
EXPLOSIONS,
FIRESPREAD,
LIGHTNING,
POWERLOSS("powerloss", "<i>Is power lost on death in this territory?", true, false),
PVP("pvp", "<i>Can you PVP in territory?", true, false),
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false, false),
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true, false),
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true, false),
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true, false),
LIGHTNING("lightning", "<i>Can lightning strike in this territory?", true, false),
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false, true),
;
private final String nicename;
private final String desc;
public final boolean defaultDefaultValue;
public final boolean defaultDefaultChangeable;
private FactionFlag(final String nicename, final String desc, final boolean defaultDefaultValue, final boolean defaultDefaultChangeable)
{
this.nicename = nicename;
this.desc = desc;
this.defaultDefaultValue = defaultDefaultValue;
this.defaultDefaultChangeable = defaultDefaultChangeable;
}
public String getNicename()
{
return this.nicename;
}
public String getDescription()
{
return this.desc;
}
/**
* The state for newly created factions.
*/
public boolean getDefault()
{
// Use config file for this later.
return true;
return Conf.factionFlagDefaults.get(this);
}
/**
@ -40,7 +66,32 @@ public enum FactionFlag
*/
public boolean isChangeable()
{
// TODO: Use config file
return true;
return Conf.factionFlagIsChangeable.get(this);
}
public static FactionFlag parse(String str)
{
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;
if (str.startsWith("e")) return EXPLOSIONS;
if (str.startsWith("fi")) return FIRESPREAD;
if (str.startsWith("l")) return LIGHTNING;
return null;
}
public String getStateInfo(boolean value, boolean withDesc)
{
String ret = (value ? "<g>YES" : "<b>NOT") + "<h> " + this.getNicename();
if (withDesc)
{
ret += " " + this.getDescription();
}
return ret;
}
}

View File

@ -2,10 +2,9 @@ package com.massivecraft.factions.struct;
/**
* Permissions that you (a player) may or may not have in the territory of a certain faction.
*
* You need a certain rel to be able
* Each faction have many Rel's assigned to each one of these Perms.
*/
public enum FactionPlayerPerm
public enum FactionPerm
{
BUILD, // This player can build in the faction
PAINBUILD, // This player can build in the faction BUT will take damage each time. This is overridden by BUILD if player has both

View File

@ -20,6 +20,8 @@ public enum Permission
DESCRIPTION("description"),
DISBAND("disband"),
DISBAND_ANY("disband.any"),
FLAG("flag"),
FLAG_ANY("flag.any"),
HELP("help"),
HOME("home"),
INVITE("invite"),
@ -44,8 +46,6 @@ public enum Permission
OWNER("owner"),
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
POWER("power"),
POWER_ANY("power.any"),
RELATION("relation"),