Wheeerp
This commit is contained in:
@ -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
|
||||
// -------------------------------------------- //
|
||||
|
Reference in New Issue
Block a user