mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-27 11:07:49 +01:00
Wheeerp
This commit is contained in:
parent
842844969b
commit
98c5230655
@ -26,7 +26,6 @@ permissions:
|
||||
factions.kit.halfmod: true
|
||||
factions.disband.any: true
|
||||
factions.setpermanent: true
|
||||
factions.setpermanentpower: true
|
||||
factions.setpeaceful: true
|
||||
factions.sethome.any: true
|
||||
factions.money.*: true
|
||||
@ -37,6 +36,7 @@ permissions:
|
||||
factions.managesafezone: true
|
||||
factions.managewarzone: true
|
||||
factions.bypass: true
|
||||
factions.flag.any: true
|
||||
factions.kick.any: true
|
||||
factions.ownershipbypass: true
|
||||
factions.kit.fullplayer:
|
||||
@ -55,6 +55,7 @@ permissions:
|
||||
factions.deinvite: true
|
||||
factions.description: true
|
||||
factions.disband: true
|
||||
factions.flag: true
|
||||
factions.help: true
|
||||
factions.home: true
|
||||
factions.invite: true
|
||||
@ -101,6 +102,10 @@ permissions:
|
||||
description: disband a faction
|
||||
factions.disband.any:
|
||||
description: disband an other faction
|
||||
factions.flag:
|
||||
description: change faction flags
|
||||
factions.flag.any:
|
||||
description: change all flags for all factions
|
||||
factions.help:
|
||||
description: display a help page
|
||||
factions.home:
|
||||
@ -176,8 +181,6 @@ permissions:
|
||||
description: designate a faction as peaceful
|
||||
factions.setpermanent:
|
||||
description: designate a faction as permanent
|
||||
factions.setpermanentpower:
|
||||
description: set permanent power for a faction
|
||||
factions.power:
|
||||
description: show player power info
|
||||
factions.power.any:
|
||||
|
@ -5,6 +5,8 @@ import java.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
|
||||
public class Conf
|
||||
{
|
||||
public static List<String> baseCommandAliases = new ArrayList<String>();
|
||||
@ -20,6 +22,16 @@ public class Conf
|
||||
public static ChatColor colorWar = ChatColor.DARK_RED;
|
||||
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
||||
|
||||
|
||||
// REFACTOR ASJDKJASDKFJKASDF
|
||||
public static Map<FactionFlag, Boolean> factionFlagDefaults;
|
||||
public static Map<FactionFlag, Boolean> factionFlagIsChangeable;
|
||||
|
||||
// REFACTOR ASJDKJASDKFJKASDF EEEEEENNNNDD
|
||||
|
||||
|
||||
|
||||
|
||||
// Power
|
||||
public static double powerPlayerMax = 10.0;
|
||||
public static double powerPlayerMin = -10.0;
|
||||
@ -245,6 +257,32 @@ public class Conf
|
||||
{
|
||||
baseCommandAliases.add("f");
|
||||
|
||||
factionFlagDefaults = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
factionFlagDefaults.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultValue);
|
||||
factionFlagDefaults.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultValue);
|
||||
|
||||
factionFlagIsChangeable = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
factionFlagIsChangeable.put(FactionFlag.PERMANENT, FactionFlag.PERMANENT.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.PEACEFUL, FactionFlag.PEACEFUL.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.INFPOWER, FactionFlag.INFPOWER.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.POWERLOSS, FactionFlag.POWERLOSS.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.PVP, FactionFlag.PVP.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.FRIENDLYFIRE, FactionFlag.FRIENDLYFIRE.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.MONSTERS, FactionFlag.MONSTERS.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.EXPLOSIONS, FactionFlag.EXPLOSIONS.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.FIRESPREAD, FactionFlag.FIRESPREAD.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.LIGHTNING, FactionFlag.LIGHTNING.defaultDefaultChangeable);
|
||||
factionFlagIsChangeable.put(FactionFlag.ENDERGRIEF, FactionFlag.ENDERGRIEF.defaultDefaultChangeable);
|
||||
|
||||
territoryEnemyDenyCommands.add("home");
|
||||
territoryEnemyDenyCommands.add("sethome");
|
||||
territoryEnemyDenyCommands.add("spawn");
|
||||
|
@ -14,6 +14,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
@ -574,7 +575,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public void leave(boolean makePay)
|
||||
{
|
||||
Faction myFaction = this.getFaction();
|
||||
boolean perm = myFaction.isPermanent();
|
||||
boolean perm = myFaction.getFlag(FactionFlag.PERMANENT);
|
||||
|
||||
if (!perm && this.getRole() == Rel.LEADER && myFaction.getFPlayers().size() > 1)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.*;
|
||||
@ -53,9 +54,9 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
// FIELD: permanent
|
||||
// "permanent" status can only be set by server admins/moderators/ops, and allows the faction to remain even with 0 members
|
||||
private boolean permanent;
|
||||
public boolean isPermanent() { return permanent; }
|
||||
public void setPermanent(boolean isPermanent) { permanent = isPermanent; }
|
||||
//private boolean permanent;
|
||||
//public boolean isPermanent() { return permanent; }
|
||||
//public void setPermanent(boolean isPermanent) { permanent = isPermanent; }
|
||||
|
||||
// FIELD: tag
|
||||
private String tag;
|
||||
@ -128,11 +129,27 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
return Econ.getMethod().getAccount(aid);
|
||||
}
|
||||
|
||||
// FIELD: permanentPower
|
||||
private Integer permanentPower;
|
||||
public Integer getPermanentPower() { return this.permanentPower; }
|
||||
public void setPermanentPower(Integer permanentPower) { this.permanentPower = permanentPower; }
|
||||
public boolean hasPermanentPower() { return this.permanentPower != null; }
|
||||
// FIELDS: Flag management
|
||||
// TODO: This will save... defaults if they where changed to...
|
||||
private Map<FactionFlag, Boolean> flagOverrides; // Contains the modifications to the default values
|
||||
public boolean getFlag(FactionFlag flag)
|
||||
{
|
||||
Boolean ret = this.flagOverrides.get(flag);
|
||||
if (ret == null) ret = flag.getDefault();
|
||||
return ret;
|
||||
}
|
||||
public void setFlag(FactionFlag flag, boolean value)
|
||||
{
|
||||
if (Conf.factionFlagDefaults.get(flag) == value)
|
||||
{
|
||||
this.flagOverrides.remove(flag);
|
||||
return;
|
||||
}
|
||||
this.flagOverrides.put(flag, value);
|
||||
}
|
||||
|
||||
// FIELDS: Permission <-> Groups management
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Construct
|
||||
@ -148,8 +165,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
this.lastPlayerLoggedOffTime = 0;
|
||||
this.peaceful = false;
|
||||
this.peacefulExplosionsEnabled = false;
|
||||
this.permanent = false;
|
||||
this.money = 0.0;
|
||||
this.flagOverrides = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -166,6 +183,8 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
// Understand the types
|
||||
// -------------------------------
|
||||
|
||||
// TODO: These should be gone after the refactoring...
|
||||
|
||||
public boolean isNormal()
|
||||
{
|
||||
return ! (this.isNone() || this.isSafeZone() || this.isWarZone());
|
||||
@ -252,9 +271,9 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
//----------------------------------------------//
|
||||
public double getPower()
|
||||
{
|
||||
if (this.hasPermanentPower())
|
||||
if (this.getFlag(FactionFlag.INFPOWER))
|
||||
{
|
||||
return this.getPermanentPower();
|
||||
return 999999;
|
||||
}
|
||||
|
||||
double ret = 0;
|
||||
@ -271,9 +290,9 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
public double getPowerMax()
|
||||
{
|
||||
if (this.hasPermanentPower())
|
||||
if (this.getFlag(FactionFlag.INFPOWER))
|
||||
{
|
||||
return this.getPermanentPower();
|
||||
return 999999;
|
||||
}
|
||||
|
||||
double ret = 0;
|
||||
|
@ -151,7 +151,7 @@ public class P extends MPlugin
|
||||
.excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.VOLATILE)
|
||||
.registerTypeAdapter(Location.class, new MyLocationTypeAdapter())
|
||||
.registerTypeAdapter(mapFLocToStringSetType, new MapFLocToStringSetTypeAdapter())
|
||||
.registerTypeAdapter(Rel.class, new MyRelTypeAdapter());
|
||||
.registerTypeAdapter(Rel.class, new MyRelTypeAdapter()); // This one is for users upgrading from 1.6 to 1.7... should be removed some time in the future.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -49,7 +50,7 @@ public class CmdDisband extends FCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (faction.isPermanent())
|
||||
if (faction.getFlag(FactionFlag.PERMANENT))
|
||||
{
|
||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||
return;
|
||||
|
88
src/com/massivecraft/factions/cmd/CmdFlag.java
Normal file
88
src/com/massivecraft/factions/cmd/CmdFlag.java
Normal file
@ -0,0 +1,88 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdFlag extends FCommand
|
||||
{
|
||||
|
||||
public CmdFlag()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("flag");
|
||||
|
||||
//this.requiredArgs.add("");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
this.optionalArgs.put("flag", "all");
|
||||
this.optionalArgs.put("on/off", "read");
|
||||
|
||||
this.permission = Permission.FLAG.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Faction faction = myFaction;
|
||||
if (this.argIsSet(0))
|
||||
{
|
||||
faction = this.argAsFaction(0);
|
||||
}
|
||||
if (faction == null) return;
|
||||
|
||||
msg(p.txt.titleize("Flag(s) for " + faction.describeTo(fme)));
|
||||
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
for (FactionFlag flag : FactionFlag.values())
|
||||
{
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FactionFlag flag = this.argAsFactionFlag(1);
|
||||
if (flag == null) return;
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
return;
|
||||
}
|
||||
|
||||
Boolean targetValue = this.argAsBool(2);
|
||||
if (targetValue == null) return;
|
||||
|
||||
// Do the sender have the right to change flags for this faction?
|
||||
if (Permission.FLAG_ANY.has(sender))
|
||||
{
|
||||
// This sender may modify any flag for anyone
|
||||
}
|
||||
else if ( ! flag.isChangeable())
|
||||
{
|
||||
msg("<b>Only server operators can change this flag.");
|
||||
return;
|
||||
}
|
||||
else if (faction != myFaction)
|
||||
{
|
||||
msg("<b>You are not a member in that faction.");
|
||||
return;
|
||||
}
|
||||
else if (fme.getRole().isLessThan(Rel.OFFICER))
|
||||
{
|
||||
msg("<b>You must be faction leader or officer to change your faction flags.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Do the change
|
||||
faction.setFlag(flag, targetValue);
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
}
|
||||
|
||||
}
|
@ -168,8 +168,6 @@ public class CmdHelp extends FCommand
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
|
||||
pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) );
|
||||
pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) );
|
||||
pageLines.add( p.cmdBase.cmdPermanentPower.getUseageTemplate(true) );
|
||||
pageLines.add(p.txt.parse("<i>Peaceful factions are protected from PvP and land capture."));
|
||||
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
|
||||
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );
|
||||
|
@ -4,6 +4,7 @@ import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdKick extends FCommand
|
||||
@ -77,7 +78,7 @@ public class CmdKick extends FCommand
|
||||
yourFaction.deinvite(you);
|
||||
you.resetFactionData();
|
||||
|
||||
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.isPermanent())
|
||||
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.getFlag(FactionFlag.PERMANENT))
|
||||
{
|
||||
// Remove this faction
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
|
@ -1,59 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
|
||||
public class CmdPermanent extends FCommand
|
||||
{
|
||||
public CmdPermanent()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("permanent");
|
||||
|
||||
this.requiredArgs.add("faction tag");
|
||||
//this.optionalArgs.put("", "");
|
||||
|
||||
this.permission = Permission.SET_PERMANENT.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
|
||||
String change;
|
||||
if(faction.isPermanent())
|
||||
{
|
||||
change = "removed permanent status from";
|
||||
faction.setPermanent(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
change = "added permanent status to";
|
||||
faction.setPermanent(true);
|
||||
}
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
{
|
||||
if (fplayer.getFaction() == faction)
|
||||
{
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" your faction.");
|
||||
}
|
||||
else
|
||||
{
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdPermanentPower extends FCommand
|
||||
{
|
||||
public CmdPermanentPower()
|
||||
{
|
||||
super();
|
||||
this.aliases.add("permanentpower");
|
||||
|
||||
this.requiredArgs.add("faction");
|
||||
this.optionalArgs.put("power", "reset");
|
||||
|
||||
this.permission = Permission.SET_PERMANENTPOWER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Faction targetFaction = this.argAsFaction(0);
|
||||
if (targetFaction == null) return;
|
||||
|
||||
Integer targetPower = this.argAsInt(1);
|
||||
|
||||
targetFaction.setPermanentPower(targetPower);
|
||||
|
||||
String change = "removed permanentpower status from";
|
||||
if(targetFaction.hasPermanentPower())
|
||||
{
|
||||
change = "added permanentpower status to";
|
||||
}
|
||||
|
||||
msg("<i>You %s <h>%s<i>.", change, targetFaction.describeTo(fme));
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true))
|
||||
{
|
||||
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> "+change+" your faction.");
|
||||
}
|
||||
}
|
||||
}
|
12
src/com/massivecraft/factions/cmd/CmdRelationTruce.java
Normal file
12
src/com/massivecraft/factions/cmd/CmdRelationTruce.java
Normal file
@ -0,0 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
public class CmdRelationTruce extends FRelationCommand
|
||||
{
|
||||
public CmdRelationTruce()
|
||||
{
|
||||
aliases.add("neutral");
|
||||
targetRelation = Rel.NEUTRAL;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -63,7 +64,7 @@ public class CmdShow extends FCommand
|
||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
|
||||
|
||||
if (faction.isPermanent())
|
||||
if (faction.getFlag(FactionFlag.PERMANENT))
|
||||
{
|
||||
msg("<a>This faction is permanent, remaining even with no members.");
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ public class FCmdRoot extends FCommand
|
||||
public CmdDeinvite cmdDeinvite = new CmdDeinvite();
|
||||
public CmdDescription cmdDescription = new CmdDescription();
|
||||
public CmdDisband cmdDisband = new CmdDisband();
|
||||
public CmdFlag cmdFlag = new CmdFlag();
|
||||
public CmdHelp cmdHelp = new CmdHelp();
|
||||
public CmdHome cmdHome = new CmdHome();
|
||||
public CmdInvite cmdInvite = new CmdInvite();
|
||||
@ -32,8 +33,6 @@ public class FCmdRoot extends FCommand
|
||||
public CmdOwner cmdOwner = new CmdOwner();
|
||||
public CmdOwnerList cmdOwnerList = new CmdOwnerList();
|
||||
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
|
||||
public CmdPermanent cmdPermanent = new CmdPermanent();
|
||||
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
|
||||
public CmdPower cmdPower = new CmdPower();
|
||||
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
||||
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
|
||||
@ -83,6 +82,7 @@ public class FCmdRoot extends FCommand
|
||||
this.addSubCommand(this.cmdDeinvite);
|
||||
this.addSubCommand(this.cmdDescription);
|
||||
this.addSubCommand(this.cmdDisband);
|
||||
this.addSubCommand(this.cmdFlag);
|
||||
this.addSubCommand(this.cmdHelp);
|
||||
this.addSubCommand(this.cmdHome);
|
||||
this.addSubCommand(this.cmdInvite);
|
||||
@ -98,8 +98,6 @@ public class FCmdRoot extends FCommand
|
||||
this.addSubCommand(this.cmdOwner);
|
||||
this.addSubCommand(this.cmdOwnerList);
|
||||
this.addSubCommand(this.cmdPeaceful);
|
||||
this.addSubCommand(this.cmdPermanent);
|
||||
this.addSubCommand(this.cmdPermanentPower);
|
||||
this.addSubCommand(this.cmdPower);
|
||||
this.addSubCommand(this.cmdRelationAlly);
|
||||
this.addSubCommand(this.cmdRelationEnemy);
|
||||
|
@ -12,6 +12,7 @@ import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.MCommand;
|
||||
|
||||
@ -273,6 +274,41 @@ public abstract class FCommand extends MCommand<P>
|
||||
return this.argAsFaction(idx, null);
|
||||
}
|
||||
|
||||
// FACTION FLAG ======================
|
||||
public FactionFlag strAsFactionFlag(String name, FactionFlag def, boolean msg)
|
||||
{
|
||||
FactionFlag ret = def;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
FactionFlag flag = FactionFlag.parse(name);
|
||||
if (flag != null)
|
||||
{
|
||||
ret = flag;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg && ret == null)
|
||||
{
|
||||
this.msg("<b>The faction-flag \"<p>%s<b>\" could not be found.", name);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx, FactionFlag def, boolean msg)
|
||||
{
|
||||
return this.strAsFactionFlag(this.argAsString(idx), def, msg);
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx, FactionFlag def)
|
||||
{
|
||||
return this.argAsFactionFlag(idx, def, true);
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx)
|
||||
{
|
||||
return this.argAsFactionFlag(idx, null);
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Commonly used logic
|
||||
// -------------------------------------------- //
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
@ -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"),
|
||||
|
@ -15,6 +15,11 @@ public class RelationUtil
|
||||
{
|
||||
String ret = "";
|
||||
|
||||
if (that == null)
|
||||
{
|
||||
return "A server admin";
|
||||
}
|
||||
|
||||
Faction thatFaction = getFaction(that);
|
||||
if (thatFaction == null) return "ERROR"; // ERROR
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user