Maven Attempt 1

This commit is contained in:
Olof Larsson
2014-09-13 00:50:33 +02:00
parent 3debf17f27
commit 13a4afdfb4
170 changed files with 151 additions and 49 deletions

View File

@@ -1,114 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.List;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.cmd.HelpCommand;
import com.massivecraft.massivecore.cmd.VersionCommand;
public class CmdFactions extends FCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsList cmdFactionsList = new CmdFactionsList();
public CmdFactionsFaction cmdFactionsFaction = new CmdFactionsFaction();
public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer();
public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin();
public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
public CmdFactionsHome cmdFactionsHome = new CmdFactionsHome();
public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
public CmdFactionsName cmdFactionsName = new CmdFactionsName();
public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen();
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
public CmdFactionsPromote cmdFactionsPromote = new CmdFactionsPromote();
public CmdFactionsDemote cmdFactionsDemote = new CmdFactionsDemote();
public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer();
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim();
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
public CmdFactionsUnclaimall cmdFactionsUnclaimall = new CmdFactionsUnclaimall();
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly();
public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce();
public CmdFactionsRelationNeutral cmdFactionsRelationNeutral = new CmdFactionsRelationNeutral();
public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy();
public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version");
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactions()
{
// Add SubCommands
this.addSubCommand(HelpCommand.get());
this.addSubCommand(this.cmdFactionsList);
this.addSubCommand(this.cmdFactionsFaction);
this.addSubCommand(this.cmdFactionsPlayer);
this.addSubCommand(this.cmdFactionsJoin);
this.addSubCommand(this.cmdFactionsLeave);
this.addSubCommand(this.cmdFactionsHome);
this.addSubCommand(this.cmdFactionsMap);
this.addSubCommand(this.cmdFactionsCreate);
this.addSubCommand(this.cmdFactionsName);
this.addSubCommand(this.cmdFactionsDescription);
this.addSubCommand(this.cmdFactionsSethome);
this.addSubCommand(this.cmdFactionsOpen);
this.addSubCommand(this.cmdFactionsInvite);
this.addSubCommand(this.cmdFactionsKick);
this.addSubCommand(this.cmdFactionsTitle);
this.addSubCommand(this.cmdFactionsPromote);
this.addSubCommand(this.cmdFactionsDemote);
this.addSubCommand(this.cmdFactionsOfficer);
this.addSubCommand(this.cmdFactionsLeader);
this.addSubCommand(this.cmdFactionsMoney);
this.addSubCommand(this.cmdFactionsSeeChunk);
this.addSubCommand(this.cmdFactionsClaim);
this.addSubCommand(this.cmdFactionsAutoClaim);
this.addSubCommand(this.cmdFactionsUnclaim);
this.addSubCommand(this.cmdFactionsUnclaimall);
this.addSubCommand(this.cmdFactionsAccess);
this.addSubCommand(this.cmdFactionsRelationAlly);
this.addSubCommand(this.cmdFactionsRelationTruce);
this.addSubCommand(this.cmdFactionsRelationNeutral);
this.addSubCommand(this.cmdFactionsRelationEnemy);
this.addSubCommand(this.cmdFactionsPerm);
this.addSubCommand(this.cmdFactionsFlag);
this.addSubCommand(this.cmdFactionsDisband);
this.addSubCommand(this.cmdFactionsAdmin);
this.addSubCommand(this.cmdFactionsPowerBoost);
this.addSubCommand(this.cmdFactionsVersion);
// Misc
this.setDesc("The faction base command");
this.setHelp("This command contains all faction stuff.");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<String> getAliases()
{
return MConf.get().aliasesF;
}
}

View File

@@ -1,51 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.massivecore.cmd.HelpCommand;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
public class CmdFactionsAccess extends FCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsAccessView cmdFactionsAccessView = new CmdFactionsAccessView();
public CmdFactionsAccessPlayer cmdFactionsAccessPlayer = new CmdFactionsAccessPlayer();
public CmdFactionsAccessFaction cmdFactionsAccessFaction = new CmdFactionsAccessFaction();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccess()
{
// Add SubCommands
this.addSubCommand(this.cmdFactionsAccessView);
this.addSubCommand(this.cmdFactionsAccessPlayer);
this.addSubCommand(this.cmdFactionsAccessFaction);
// Aliases
this.addAliases("access");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
this.getCommandChain().add(this);
HelpCommand.get().execute(this.sender, this.args, this.commandChain);
}
}

View File

@@ -1,75 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.massivecraft.factions.RelationParticipator;
import com.massivecraft.factions.TerritoryAccess;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
import com.massivecraft.massivecore.util.Txt;
public abstract class CmdFactionsAccessAbstract extends FCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public PS chunk;
public TerritoryAccess ta;
public Faction hostFaction;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessAbstract()
{
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
chunk = PS.valueOf(me).getChunk(true);
ta = BoardColls.get().getTerritoryAccessAt(chunk);
hostFaction = ta.getHostFaction(usender);
this.innerPerform();
}
public abstract void innerPerform();
public void sendAccessInfo()
{
sendMessage(Txt.titleize("Access at " + chunk.toString(PSFormatHumanSpace.get())));
msg("<k>Host Faction: %s", hostFaction.describeTo(usender, true));
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedUPlayers(usender), usender));
msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(usender), usender));
}
public static String describeRelationParticipators(Collection<? extends RelationParticipator> relationParticipators, RelationParticipator observer)
{
if (relationParticipators.size() == 0) return Txt.parse("<silver><em>none");
List<String> descriptions = new ArrayList<String>();
for (RelationParticipator relationParticipator : relationParticipators)
{
descriptions.add(relationParticipator.describeTo(observer));
}
return Txt.implodeCommaAnd(descriptions, Txt.parse("<i>, "), Txt.parse(" <i>and "));
}
}

View File

@@ -1,55 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessFaction()
{
// Aliases
this.addAliases("f", "faction");
// Args
this.addRequiredArg("faction");
this.addOptionalArg("yes/no", "toggle");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_FACTION.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(usender));
if (faction == null) return;
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
if (newValue == null) return;
// FPerm
if (!FPerm.ACCESS.has(usender, hostFaction, true)) return;
// Apply
ta = ta.withFactionId(faction.getId(), newValue);
BoardColls.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
}

View File

@@ -1,55 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessPlayer()
{
// Aliases
this.addAliases("p", "player");
// Args
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_PLAYER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform()
{
// Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(usender));
if (uplayer == null) return;
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(uplayer.getId()));
if (newValue == null) return;
// FPerm
if (!FPerm.ACCESS.has(usender, hostFaction, true)) return;
// Apply
ta = ta.withPlayerId(uplayer.getId(), newValue);
BoardColls.get().setTerritoryAccessAt(chunk, ta);
// Inform
this.sendAccessInfo();
}
}

View File

@@ -1,31 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAccessView extends CmdFactionsAccessAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAccessView()
{
// Aliases
this.addAliases("v", "view");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.ACCESS_VIEW.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void innerPerform()
{
this.sendAccessInfo();
}
}

View File

@@ -1,51 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsAdmin extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAdmin()
{
// Aliases
this.addAliases("admin");
// Args
this.addOptionalArg("on/off", "flip");
// Requirements
// this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode());
if (target == null) return;
msender.setUsingAdminMode(target);
if (msender.isUsingAdminMode())
{
msender.msg("<i>You have enabled admin bypass mode.");
Factions.get().log(msender.getId() + " has ENABLED admin bypass mode.");
}
else
{
msender.msg("<i>You have disabled admin bypass mode.");
Factions.get().log(msender.getId() + " DISABLED admin bypass mode.");
}
}
}

View File

@@ -1,62 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsAutoClaim extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsAutoClaim()
{
// Aliases
this.addAliases("autoclaim");
// Args
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node));
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Check disabled
if (UConf.isDisabled(sender, sender)) return;
// Args
Faction forFaction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
if (forFaction == null || forFaction == usender.getAutoClaimFaction())
{
usender.setAutoClaimFaction(null);
msg("<i>Auto-claiming of land disabled.");
return;
}
// FPerm
if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return;
usender.setAutoClaimFaction(forFaction);
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(usender));
usender.tryClaim(forFaction, PS.valueOf(me), true, true);
}
}

View File

@@ -1,112 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.task.SpiralTask;
import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsClaim extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsClaim()
{
// Aliases
this.addAliases("claim");
// Args
this.addOptionalArg("radius", "1");
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Integer radius = this.arg(0, ARInteger.get(), 1);
if (radius == null) return;
final Faction forFaction = this.arg(1, ARFaction.get(me), usenderFaction);
if (forFaction == null) return;
// FPerm
if (forFaction.isNormal() && !FPerm.TERRITORY.has(usender, forFaction, true)) return;
// Validate
if (radius < 1)
{
msg("<b>If you specify a radius, it must be at least 1.");
return;
}
if (radius > MConf.get().radiusClaimRadiusLimit && !usender.isUsingAdminMode())
{
msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().radiusClaimRadiusLimit);
return;
}
// Apply
// single chunk
if (radius < 2)
{
usender.tryClaim(forFaction, PS.valueOf(me), true, true);
return;
}
// radius claim
if (!Perm.CLAIM_RADIUS.has(sender, false))
{
msg("<b>You do not have permission to claim in a radius.");
return;
}
// TODO: There must be a better way than using a spiral task.
// TODO: Do some research to allow for claming sets of chunks in a batch with atomicity.
// This will probably result in an alteration to the owner change event.
// It would possibly contain a set of chunks instead of a single chunk.
new SpiralTask(PS.valueOf(me), radius)
{
private int failCount = 0;
private final int limit = MConf.get().radiusClaimFailureLimit - 1;
@Override
public boolean work()
{
boolean success = usender.tryClaim(forFaction, PS.valueOf(this.currentLocation()), true, true);
if (success)
{
this.failCount = 0;
}
else if (this.failCount++ >= this.limit)
{
this.stop();
return false;
}
return true;
}
};
}
}

View File

@@ -1,101 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasntFaction;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsCreate;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.store.MStore;
public class CmdFactionsCreate extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsCreate()
{
// Aliases
this.addAliases("create");
// Args
this.addRequiredArg("name");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasntFaction.get());
this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
String newName = this.arg(0);
// Verify
FactionColl coll = FactionColls.get().get(usender);
if (coll.isNameTaken(newName))
{
msg("<b>That name is already in use.");
return;
}
ArrayList<String> nameValidationErrors = coll.validateName(newName);
if (nameValidationErrors.size() > 0)
{
sendMessage(nameValidationErrors);
return;
}
// Pre-Generate Id
String factionId = MStore.createId();
// Event
EventFactionsCreate createEvent = new EventFactionsCreate(sender, coll.getUniverse(), factionId, newName);
createEvent.run();
if (createEvent.isCancelled()) return;
// Apply
Faction faction = coll.create(factionId);
faction.setName(newName);
usender.setRole(Rel.LEADER);
usender.setFaction(faction);
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.CREATE);
joinEvent.run();
// NOTE: join event cannot be cancelled or you'll have an empty faction
// Inform
for (UPlayer follower : UPlayerColls.get().get(usender).getAllOnline())
{
follower.msg("%s<i> created a new faction %s", usender.describeTo(follower, true), faction.getName(follower));
}
msg("<i>You should now: %s", Factions.get().getOuterCmdFactions().cmdFactionsDescription.getUseageTemplate());
if (MConf.get().logFactionCreate)
{
Factions.get().log(usender.getName()+" created a new faction: "+newName);
}
}
}

View File

@@ -1,77 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsDemote extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDemote()
{
// Aliases
this.addAliases("demote");
// Args
this.addRequiredArg("player");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node));
//To demote someone from member -> recruit you must be an officer.
//To demote someone from officer -> member you must be a leader.
//We'll handle this internally
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
UPlayer you = this.arg(0, ARUPlayer.getAny(usender));
if (you == null) return;
if (you.getFaction() != usenderFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
return;
}
if (you == usender)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.MEMBER)
{
if (!usender.getRole().isAtLeast(Rel.OFFICER))
{
msg("<b>You must be an officer to demote a member to recruit.");
return;
}
you.setRole(Rel.RECRUIT);
usenderFaction.msg("%s<i> was demoted to being a recruit in your faction.", you.describeTo(usenderFaction, true));
}
else if (you.getRole() == Rel.OFFICER)
{
if (!usender.getRole().isAtLeast(Rel.LEADER))
{
msg("<b>You must be the leader to demote an officer to member.");
return;
}
you.setRole(Rel.MEMBER);
usenderFaction.msg("%s<i> was demoted to being a member in your faction.", you.describeTo(usenderFaction, true));
}
}
}

View File

@@ -1,61 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin;
public class CmdFactionsDescription extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDescription()
{
// Aliases
this.addAliases("desc");
// Args
this.addRequiredArg("desc");
this.setErrorOnToManyArgs(false);
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
String newDescription = this.argConcatFrom(0);
// Event
EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, usenderFaction, newDescription);
event.run();
if (event.isCancelled()) return;
newDescription = event.getNewDescription();
// Apply
usenderFaction.setDescription(newDescription);
// Inform
for (UPlayer follower : usenderFaction.getUPlayers())
{
follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription());
}
}
}

View File

@@ -1,97 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsDisband;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsDisband extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDisband()
{
// Aliases
this.addAliases("disband");
// Args
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(usender), usenderFaction);
if (faction == null) return;
// FPerm
if ( ! FPerm.DISBAND.has(usender, faction, true)) return;
// Verify
if (faction.getFlag(FFlag.PERMANENT))
{
msg("<i>This faction is designated as permanent, so you cannot disband it.");
return;
}
// Event
EventFactionsDisband event = new EventFactionsDisband(me, faction);
event.run();
if (event.isCancelled()) return;
// Merged Apply and Inform
// Run event for each player in the faction
for (UPlayer uplayer : faction.getUPlayers())
{
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND);
membershipChangeEvent.run();
}
// Inform all players
for (UPlayer uplayer : UPlayerColls.get().get(usender).getAllOnline())
{
String who = usender.describeTo(uplayer);
if (uplayer.getFaction() == faction)
{
uplayer.msg("<h>%s<i> disbanded your faction.", who);
}
else
{
uplayer.msg("<h>%s<i> disbanded the faction %s.", who, faction.getName(uplayer));
}
}
if (MConf.get().logFactionDisband)
{
Factions.get().log(Txt.parse("<i>The faction <h>%s <i>(<h>%s<i>) was disbanded by <h>%s<i>.", faction.getName(), faction.getId(), usender.getDisplayName(IdUtil.getConsole())));
}
faction.detach();
}
}

View File

@@ -1,175 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.PlayerRoleComparator;
import com.massivecraft.factions.Rel;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.TimeDiffUtil;
import com.massivecraft.massivecore.util.TimeUnit;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsFaction extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsFaction()
{
// Aliases
this.addAliases("f", "faction");
// Args
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
if (faction == null) return;
// Data precalculation
UConf uconf = UConf.get(faction);
//boolean none = faction.isNone();
boolean normal = faction.isNormal();
// INFO: Title
msg(Txt.titleize(Txt.upperCaseFirst(faction.getUniverse()) + " Faction " + faction.getName(usender)));
// INFO: Description
msg("<a>Description: <i>%s", faction.getDescription());
if (normal)
{
// INFO: Age
long ageMillis = faction.getCreatedAtMillis() - System.currentTimeMillis();
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
String ageString = TimeDiffUtil.formatedVerboose(ageUnitcounts, "<i>");
msg("<a>Age: <i>%s", ageString);
// INFO: Open
msg("<a>Open: <i>"+(faction.isOpen() ? "<lime>Yes<i>, anyone can join" : "<rose>No<i>, only invited people can join"));
// INFO: Power
double powerBoost = faction.getPowerBoost();
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
// show the land value
if (Econ.isEnabled(faction))
{
long landCount = faction.getLandCount();
for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values())
{
Double money = uconf.econChunkCost.get(type);
if (money == null) continue;
if (money == 0D) continue;
money *= landCount;
String word = null;
if (money > 0)
{
word = "cost";
}
else
{
word = "reward";
money *= -1;
}
msg("<a>Total land %s %s: <i>%s", type.toString().toLowerCase(), word, Money.format(money));
}
// Show bank contents
if (UConf.get(faction).bankEnabled)
{
msg("<a>Bank contains: <i>"+Money.format(Money.get(faction)));
}
}
// Display important flags
// TODO: Find the non default flags, and display them instead.
if (faction.getFlag(FFlag.PERMANENT))
{
msg("<a>This faction is permanent - remaining even with no followers.");
}
if (faction.getFlag(FFlag.PEACEFUL))
{
msg("<a>This faction is peaceful - in truce with everyone.");
}
}
String sepparator = Txt.parse("<i>")+", ";
// List the relations to other factions
Map<Rel, List<String>> relationNames = faction.getFactionNamesPerRelation(usender, true);
if (faction.getFlag(FFlag.PEACEFUL))
{
sendMessage(Txt.parse("<a>In Truce with:<i> *everyone*"));
}
else
{
sendMessage(Txt.parse("<a>In Truce with: ") + Txt.implode(relationNames.get(Rel.TRUCE), sepparator));
}
sendMessage(Txt.parse("<a>Allies: ") + Txt.implode(relationNames.get(Rel.ALLY), sepparator));
sendMessage(Txt.parse("<a>Enemies: ") + Txt.implode(relationNames.get(Rel.ENEMY), sepparator));
// List the followers...
List<String> followerNamesOnline = new ArrayList<String>();
List<String> followerNamesOffline = new ArrayList<String>();
List<UPlayer> followers = faction.getUPlayers();
Collections.sort(followers, PlayerRoleComparator.get());
for (UPlayer follower : followers)
{
if (follower.isOnline() && Mixin.canSee(sender, follower.getId()))
{
followerNamesOnline.add(follower.getNameAndTitle(usender));
}
else if (normal)
{
// For the non-faction we skip the offline members since they are far to many (infinate almost)
followerNamesOffline.add(follower.getNameAndTitle(usender));
}
}
sendMessage(Txt.parse("<a>Followers online (%s): ", followerNamesOnline.size()) + Txt.implode(followerNamesOnline, sepparator));
if (normal)
{
sendMessage(Txt.parse("<a>Followers offline (%s): ", followerNamesOffline.size()) + Txt.implode(followerNamesOffline, sepparator));
}
}
}

View File

@@ -1,76 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFFlag;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsFlag extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsFlag()
{
// Aliases
this.addAliases("flag");
// Args
this.addOptionalArg("faction", "you");
this.addOptionalArg("flag", "all");
this.addOptionalArg("yes/no", "read");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))
{
msg(Txt.titleize("Flags for " + faction.describeTo(usender, true)));
for (FFlag flag : FFlag.values())
{
msg(flag.getStateInfo(faction.getFlag(flag), true));
}
return;
}
FFlag flag = this.arg(1, ARFFlag.get());
if (flag == null) return;
if ( ! this.argIsSet(2))
{
msg(Txt.titleize("Flag for " + faction.describeTo(usender, true)));
msg(flag.getStateInfo(faction.getFlag(flag), true));
return;
}
Boolean targetValue = this.arg(2, ARBoolean.get());
if (targetValue == null) return;
// Do the sender have the right to change flags?
if ( ! Perm.FLAG_SET.has(sender, true)) return;
// Do the change
msg(Txt.titleize("Flag for " + faction.describeTo(usender, true)));
faction.setFlag(flag, targetValue);
msg(flag.getStateInfo(faction.getFlag(flag), true));
}
}

View File

@@ -1,151 +0,0 @@
package com.massivecraft.factions.cmd;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsHomeTeleport;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.mixin.TeleporterException;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsHome extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsHome()
{
// Aliases
this.addAliases("home");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
UConf uconf = UConf.get(sender);
// TODO: Hide this command on help also.
if ( ! uconf.homesEnabled)
{
usender.msg("<b>Sorry, Faction homes are disabled on this server.");
return;
}
if ( ! uconf.homesTeleportCommandEnabled)
{
usender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
return;
}
if ( ! usenderFaction.hasHome())
{
usender.msg("<b>Your faction does not have a home. " + (usender.getRole().isLessThan(Rel.OFFICER) ? "<i> Ask your leader to:" : "<i>You should:"));
usender.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getUseageTemplate());
return;
}
if ( ! uconf.homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory())
{
usender.msg("<b>You cannot teleport to your faction home while in the territory of an enemy faction.");
return;
}
if (!uconf.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld()))
{
usender.msg("<b>You cannot teleport to your faction home while in a different world.");
return;
}
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(me));
Location loc = me.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if
(
uconf.homesTeleportAllowedEnemyDistance > 0
&&
faction.getFlag(FFlag.PVP)
&&
(
! usender.isInOwnTerritory()
||
(
usender.isInOwnTerritory()
&&
! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory
)
)
)
{
World w = loc.getWorld();
double x = loc.getX();
double y = loc.getY();
double z = loc.getZ();
for (Player p : me.getServer().getOnlinePlayers())
{
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
continue;
UPlayer fp = UPlayer.get(p);
if (usender.getRelationTo(fp) != Rel.ENEMY)
continue;
Location l = p.getLocation();
double dx = Math.abs(x - l.getX());
double dy = Math.abs(y - l.getY());
double dz = Math.abs(z - l.getZ());
double max = uconf.homesTeleportAllowedEnemyDistance;
// box-shaped distance check
if (dx > max || dy > max || dz > max)
continue;
usender.msg("<b>You cannot teleport to your faction home while an enemy is within " + uconf.homesTeleportAllowedEnemyDistance + " blocks of you.");
return;
}
}
// Event
EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender);
event.run();
if (event.isCancelled()) return;
// Apply
try
{
Mixin.teleport(me, usenderFaction.getHome(), "your faction home", sender);
}
catch (TeleporterException e)
{
me.sendMessage(e.getMessage());
}
}
}

View File

@@ -1,84 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.EventFactionsInvitedChange;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
public class CmdFactionsInvite extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsInvite()
{
// Aliases
this.addAliases("inv", "invite");
// Args
this.addRequiredArg("player");
this.addOptionalArg("yes/no", "toggle");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender));
if (uplayer == null) return;
Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer));
if (newInvited == null) return;
// Allready member?
if (uplayer.getFaction() == usenderFaction)
{
msg("%s<i> is already a member of %s", uplayer.getName(), usenderFaction.getName());
msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
return;
}
// FPerm
if ( ! FPerm.INVITE.has(usender, usenderFaction, true)) return;
// Event
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, uplayer, usenderFaction, newInvited);
event.run();
if (event.isCancelled()) return;
newInvited = event.isNewInvited();
// Apply
usenderFaction.setInvited(uplayer, newInvited);
// Inform
if (newInvited)
{
uplayer.msg("%s<i> invited you to %s", usender.describeTo(uplayer, true), usenderFaction.describeTo(uplayer));
usenderFaction.msg("%s<i> invited %s<i> to your faction.", usender.describeTo(usenderFaction, true), uplayer.describeTo(usenderFaction));
}
else
{
uplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", usender.describeTo(uplayer), usenderFaction.describeTo(uplayer));
usenderFaction.msg("%s<i> revoked %s's<i> invitation.", usender.describeTo(usenderFaction), uplayer.describeTo(usenderFaction));
}
}
}

View File

@@ -1,128 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsJoin extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsJoin()
{
// Aliases
this.addAliases("join");
// Args
this.addRequiredArg("faction");
this.addOptionalArg("player", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(sender));
if (faction == null) return;
UPlayer uplayer = this.arg(1, ARUPlayer.getAny(sender), usender);
if (uplayer == null) return;
Faction uplayerFaction = uplayer.getFaction();
boolean samePlayer = uplayer == usender;
// Validate
if (!samePlayer && ! Perm.JOIN_OTHERS.has(sender, false))
{
msg("<b>You do not have permission to move other players into a faction.");
return;
}
if (faction == uplayerFaction)
{
msg("<i>%s <i>%s already a member of %s<i>.", uplayer.describeTo(usender, true), (samePlayer ? "are" : "is"), faction.getName(usender));
return;
}
if (UConf.get(faction).factionMemberLimit > 0 && faction.getUPlayers().size() >= UConf.get(faction).factionMemberLimit)
{
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), UConf.get(faction).factionMemberLimit, uplayer.describeTo(usender, false));
return;
}
if (uplayerFaction.isNormal())
{
msg("<b>%s must leave %s current faction first.", uplayer.describeTo(usender, true), (samePlayer ? "your" : "their"));
return;
}
if (!UConf.get(faction).canLeaveWithNegativePower && uplayer.getPower() < 0)
{
msg("<b>%s cannot join a faction with a negative power level.", uplayer.describeTo(usender, true));
return;
}
if( ! (faction.isOpen() || faction.isInvited(uplayer) || usender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false)))
{
msg("<i>This faction requires invitation.");
if (samePlayer)
{
faction.msg("%s<i> tried to join your faction.", uplayer.describeTo(faction, true));
}
return;
}
// Event
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, usender, faction, MembershipChangeReason.JOIN);
membershipChangeEvent.run();
if (membershipChangeEvent.isCancelled()) return;
// Inform
if (!samePlayer)
{
uplayer.msg("<i>%s <i>moved you into the faction %s<i>.", usender.describeTo(uplayer, true), faction.getName(uplayer));
}
faction.msg("<i>%s <i>joined <lime>your faction<i>.", uplayer.describeTo(faction, true));
usender.msg("<i>%s <i>successfully joined %s<i>.", uplayer.describeTo(usender, true), faction.getName(usender));
// Apply
uplayer.resetFactionData();
uplayer.setFaction(faction);
faction.setInvited(uplayer, false);
// Derplog
if (MConf.get().logFactionJoin)
{
if (samePlayer)
{
Factions.get().log(Txt.parse("%s joined the faction %s.", uplayer.getName(), faction.getName()));
}
else
{
Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", usender.getName(), uplayer.getName(), faction.getName()));
}
}
}
}

View File

@@ -1,100 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.IdUtil;
public class CmdFactionsKick extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsKick()
{
// Aliases
this.addAliases("kick");
// Args
this.addRequiredArg("player");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Arg
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender));
if (uplayer == null) return;
// Validate
if (usender == uplayer)
{
msg("<b>You cannot kick yourself.");
msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false));
return;
}
if (uplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || usender.isUsingAdminMode()))
{
msg("<b>The leader can not be kicked.");
return;
}
if ( ! UConf.get(uplayer).canLeaveWithNegativePower && uplayer.getPower() < 0)
{
msg("<b>You cannot kick that member until their power is positive.");
return;
}
// FPerm
Faction uplayerFaction = uplayer.getFaction();
if (!FPerm.KICK.has(usender, uplayerFaction, true)) return;
// Event
EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK);
event.run();
if (event.isCancelled()) return;
// Inform
uplayerFaction.msg("%s<i> kicked %s<i> from the faction! :O", usender.describeTo(uplayerFaction, true), uplayer.describeTo(uplayerFaction, true));
uplayer.msg("%s<i> kicked you from %s<i>! :O", usender.describeTo(uplayer, true), uplayerFaction.describeTo(uplayer));
if (uplayerFaction != usenderFaction)
{
usender.msg("<i>You kicked %s<i> from the faction %s<i>!", uplayer.describeTo(usender), uplayerFaction.describeTo(usender));
}
if (MConf.get().logFactionKick)
{
Factions.get().log(usender.getDisplayName(IdUtil.getConsole()) + " kicked " + uplayer.getName() + " from the faction " + uplayerFaction.getName());
}
// Apply
if (uplayer.getRole() == Rel.LEADER)
{
uplayerFaction.promoteNewLeader();
}
uplayerFaction.setInvited(uplayer, false);
uplayer.resetFactionData();
}
}

View File

@@ -1,111 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.event.EventFactionsMembershipChange;
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsLeader extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsLeader()
{
// Aliases
this.addAliases("leader");
// Args
this.addRequiredArg("player");
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEADER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
UPlayer newLeader = this.arg(0, ARUPlayer.getAny(sender));
if (newLeader == null) return;
Faction targetFaction = this.arg(1, ARFaction.get(sender), usenderFaction);
if (targetFaction == null) return;
UPlayer targetFactionCurrentLeader = targetFaction.getLeader();
// We now have uplayer and the target faction
if (this.senderIsConsole || usender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false))
{
// Do whatever you wish
}
else
{
// Follow the standard rules
if (usender.getRole() != Rel.LEADER || targetFaction != usenderFaction)
{
sender.sendMessage(Txt.parse("<b>You must be leader of the faction to %s.", this.getDesc()));
return;
}
if (newLeader.getFaction() != usenderFaction)
{
msg("%s<i> is not a member in the faction.", newLeader.describeTo(usender, true));
return;
}
if (newLeader == usender)
{
msg("<b>The target player musn't be yourself.");
return;
}
}
// only run event when newLeader isn't actually in the faction
if (newLeader.getFaction() != targetFaction)
{
EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, newLeader, targetFaction, MembershipChangeReason.LEADER);
event.run();
if (event.isCancelled()) return;
}
// if target player is currently leader, demote and replace him
if (targetFactionCurrentLeader == newLeader)
{
targetFaction.promoteNewLeader();
msg("<i>You have demoted %s<i> from the position of faction leader.", newLeader.describeTo(usender, true));
newLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", usender.describeTo(newLeader, true));
return;
}
// Perform the switching
if (targetFactionCurrentLeader != null)
{
targetFactionCurrentLeader.setRole(Rel.OFFICER);
}
newLeader.setFaction(targetFaction);
newLeader.setRole(Rel.LEADER);
msg("<i>You have promoted %s<i> to the position of faction leader.", newLeader.describeTo(usender, true));
// Inform all players
for (UPlayer uplayer : UPlayerColls.get().get(sender).getAllOnline())
{
uplayer.msg("%s<i> gave %s<i> the leadership of %s<i>.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, uplayer, true), newLeader.describeTo(uplayer), targetFaction.describeTo(uplayer));
}
}
}

View File

@@ -1,35 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsLeave extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsLeave()
{
// Aliases
this.addAliases("leave");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
this.addRequirements(ReqHasFaction.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
usender.leave();
}
}

View File

@@ -1,84 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import java.util.List;
import com.massivecraft.factions.FactionListComparator;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.massivecore.cmd.arg.ARInteger;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsList extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsList()
{
// Aliases
this.addAliases("l", "list");
// Args
this.addOptionalArg("page", "1");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
if (pageHumanBased == null) return;
// Create Messages
List<String> lines = new ArrayList<String>();
ArrayList<Faction> factionList = new ArrayList<Faction>(FactionColls.get().get(sender).getAll(null, FactionListComparator.get()));
final int pageheight = 9;
int pagecount = (factionList.size() / pageheight) + 1;
if (pageHumanBased > pagecount)
pageHumanBased = pagecount;
else if (pageHumanBased < 1)
pageHumanBased = 1;
int start = (pageHumanBased - 1) * pageheight;
int end = start + pageheight;
if (end > factionList.size())
end = factionList.size();
lines.add(Txt.titleize("Faction List "+pageHumanBased+"/"+pagecount));
for (Faction faction : factionList.subList(start, end))
{
if (faction.isNone())
{
lines.add(Txt.parse("<i>Factionless<i> %d online", FactionColls.get().get(sender).getNone().getUPlayersWhereOnline(true).size()));
continue;
}
lines.add(Txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getName(usender),
faction.getUPlayersWhereOnline(true).size(),
faction.getUPlayers().size(),
faction.getLandCount(),
faction.getPowerRounded(),
faction.getPowerMaxRounded())
);
}
sendMessage(lines);
}
}

View File

@@ -1,66 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsMap extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMap()
{
// Aliases
this.addAliases("map");
// Args
this.addOptionalArg("on/off", "once");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
if (!this.argIsSet(0))
{
showMap();
return;
}
if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating()))
{
// And show the map once
showMap();
// Turn on
msender.setMapAutoUpdating(true);
msg("<i>Map auto update <green>ENABLED.");
}
else
{
// Turn off
msender.setMapAutoUpdating(false);
msg("<i>Map auto update <red>DISABLED.");
}
}
public void showMap()
{
sendMessage(BoardColls.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw()));
}
}

View File

@@ -1,44 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsMoney extends FCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsMoneyBalance cmdMoneyBalance = new CmdFactionsMoneyBalance();
public CmdFactionsMoneyDeposit cmdMoneyDeposit = new CmdFactionsMoneyDeposit();
public CmdFactionsMoneyWithdraw cmdMoneyWithdraw = new CmdFactionsMoneyWithdraw();
public CmdFactionsMoneyTransferFf cmdMoneyTransferFf = new CmdFactionsMoneyTransferFf();
public CmdFactionsMoneyTransferFp cmdMoneyTransferFp = new CmdFactionsMoneyTransferFp();
public CmdFactionsMoneyTransferPf cmdMoneyTransferPf = new CmdFactionsMoneyTransferPf();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoney()
{
// Add SubCommands
this.addSubCommand(this.cmdMoneyBalance);
this.addSubCommand(this.cmdMoneyDeposit);
this.addSubCommand(this.cmdMoneyWithdraw);
this.addSubCommand(this.cmdMoneyTransferFf);
this.addSubCommand(this.cmdMoneyTransferFp);
this.addSubCommand(this.cmdMoneyTransferPf);
// Aliases
this.addAliases("money");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqBankCommandsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY.node));
}
}

View File

@@ -1,46 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsMoneyBalance extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyBalance()
{
// Aliases
this.addAliases("b", "balance");
// Args
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction);
if (faction == null) return;
if (faction != usenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;
Econ.sendBalanceInfo(usender, faction);
}
}

View File

@@ -1,60 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
public class CmdFactionsMoneyDeposit extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyDeposit()
{
// Aliases
this.addAliases("d", "deposit");
// Args
this.addRequiredArg("amount");
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction faction = this.arg(1, ARFaction.get(sender), usenderFaction);
if (faction == null) return;
boolean success = Econ.transferMoney(usender, usender, faction, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", usender.getName(), Money.format(amount), faction.describeTo(null))));
}
}
}

View File

@@ -1,65 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
public class CmdFactionsMoneyTransferFf extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyTransferFf()
{
// Aliases
this.addAliases("ff");
// Args
this.addRequiredArg("amount");
this.addRequiredArg("faction");
this.addRequiredArg("faction");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender));
if (from == null) return;
Faction to = this.arg(2, ARFaction.get(sender));
if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -1,67 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
public class CmdFactionsMoneyTransferFp extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyTransferFp()
{
// Aliases
this.addAliases("fp");
// Args
this.addRequiredArg("amount");
this.addRequiredArg("faction");
this.addRequiredArg("player");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender));
if (from == null) return;
UPlayer to = this.arg(2, ARUPlayer.getAny(sender));
if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the faction \"%s\" to the player \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -1,67 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
public class CmdFactionsMoneyTransferPf extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyTransferPf()
{
// Aliases
this.addAliases("pf");
// Args
this.addRequiredArg("amount");
this.addRequiredArg("player");
this.addRequiredArg("faction");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
UPlayer from = this.arg(1, ARUPlayer.getAny(sender));
if (from == null) return;
Faction to = this.arg(2, ARFaction.get(sender));
if (to == null) return;
boolean success = Econ.transferMoney(usender, from, to, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s transferred %s from the player \"%s\" to the faction \"%s\"", usender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
}
}
}

View File

@@ -1,64 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.money.Money;
import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
public class CmdFactionsMoneyWithdraw extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsMoneyWithdraw()
{
// Aliases
this.addAliases("w", "withdraw");
// Args
this.addRequiredArg("amount");
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node));
this.addRequirements(ReqBankCommandsEnabled.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Double amount = this.arg(0, ARDouble.get());
if (amount == null) return;
Faction from = this.arg(1, ARFaction.get(sender), usenderFaction);
if (from == null) return;
UPlayer to = usender;
boolean success = Econ.transferMoney(usender, from, to, amount);
if (success && MConf.get().logMoneyTransactions)
{
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", usender.getName(), Money.format(amount), from.describeTo(null))));
}
}
}

View File

@@ -1,90 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.ArrayList;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsNameChange;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsName extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsName()
{
// Aliases
this.addAliases("name");
// Args
this.addRequiredArg("new name");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Arg
String newName = this.arg(0);
// TODO does not first test cover selfcase?
FactionColl factionColl = FactionColls.get().get(usenderFaction);
if (factionColl.isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName()))
{
msg("<b>That name is already taken");
return;
}
ArrayList<String> errors = new ArrayList<String>();
errors.addAll(factionColl.validateName(newName));
if (errors.size() > 0)
{
sendMessage(errors);
return;
}
// Event
EventFactionsNameChange event = new EventFactionsNameChange(sender, usenderFaction, newName);
event.run();
if (event.isCancelled()) return;
newName = event.getNewName();
// Apply
String oldName = usenderFaction.getName();
usenderFaction.setName(newName);
// Inform
usenderFaction.msg("%s<i> changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction));
if (!UConf.get(usender).broadcastNameChange) return;
for (Faction faction : FactionColls.get().get(usenderFaction).getAll())
{
if (faction == usenderFaction)
{
continue;
}
faction.msg("<i>The player %s<i> changed their faction name from %s<i> to %s<i>.", usender.describeTo(faction, true), usender.getColorTo(faction)+oldName, usenderFaction.getName(faction));
}
}
}

View File

@@ -1,83 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsOfficer extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsOfficer()
{
// Aliases
this.addAliases("officer");
// Args
this.addRequiredArg("player");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
UPlayer you = this.arg(0, ARUPlayer.getAny(sender));
if (you == null) return;
boolean permAny = Perm.OFFICER_ANY.has(sender, false);
Faction targetFaction = you.getFaction();
if (targetFaction != usenderFaction && !permAny)
{
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
return;
}
if (usender != null && usender.getRole() != Rel.LEADER && !permAny)
{
msg("<b>You are not the faction leader.");
return;
}
if (you == usender && !permAny)
{
msg("<b>The target player musn't be yourself.");
return;
}
if (you.getRole() == Rel.LEADER)
{
msg("<b>The target player is a faction leader. Demote them first.");
return;
}
if (you.getRole() == Rel.OFFICER)
{
// Revoke
you.setRole(Rel.MEMBER);
targetFaction.msg("%s<i> is no longer officer in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have removed officer status from %s<i>.", you.describeTo(usender, true));
}
else
{
// Give
you.setRole(Rel.OFFICER);
targetFaction.msg("%s<i> was promoted to officer in your faction.", you.describeTo(targetFaction, true));
msg("<i>You have promoted %s<i> to officer.", you.describeTo(usender, true));
}
}
}

View File

@@ -1,58 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.event.EventFactionsOpenChange;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsOpen extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsOpen()
{
// Aliases
this.addAliases("open");
// Args
this.addOptionalArg("yes/no", "toggle");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.OPEN.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Boolean newOpen = this.arg(0, ARBoolean.get(), !usenderFaction.isOpen());
if (newOpen == null) return;
// Event
EventFactionsOpenChange event = new EventFactionsOpenChange(sender, usenderFaction, newOpen);
event.run();
if (event.isCancelled()) return;
newOpen = event.isNewOpen();
// Apply
usenderFaction.setOpen(newOpen);
// Inform
String descTarget = usenderFaction.isOpen() ? "open" : "closed";
usenderFaction.msg("%s<i> changed the faction to <h>%s<i>.", usender.describeTo(usenderFaction, true), descTarget);
}
}

View File

@@ -1,101 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFPerm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.arg.ARRel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsPerm extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsPerm()
{
// Aliases
this.addAliases("perm");
// Args
this.addOptionalArg("faction", "you");
this.addOptionalArg("perm", "all");
this.addOptionalArg("relation", "read");
this.addOptionalArg("yes/no", "read");
this.setErrorOnToManyArgs(false);
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PERM.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
if (faction == null) return;
if ( ! this.argIsSet(1))
{
msg(Txt.titleize("Perms for " + faction.describeTo(usender, true)));
msg(FPerm.getStateHeaders());
for (FPerm perm : FPerm.values())
{
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
}
return;
}
FPerm perm = this.arg(1, ARFPerm.get());
if (perm == null) return;
//System.out.println("perm = "+perm);
if ( ! this.argIsSet(2))
{
msg(Txt.titleize("Perm for " + faction.describeTo(usender, true)));
msg(FPerm.getStateHeaders());
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
return;
}
// Do the sender have the right to change perms for this faction?
if ( ! FPerm.PERMS.has(usender, faction, true)) return;
Rel rel = this.arg(2, ARRel.get());
if (rel == null) return;
if (!this.argIsSet(3))
{
msg("<b>Should <h>%s <b>have the <h>%s <b>permission or not?\nYou must <h>add \"yes\" or \"no\" <b>at the end.", Txt.getNicedEnum(rel), Txt.getNicedEnum(perm));
return;
}
Boolean val = this.arg(3, ARBoolean.get(), null);
if (val == null) return;
// Do the change
//System.out.println("setRelationPermitted perm "+perm+", rel "+rel+", val "+val);
faction.setRelationPermitted(perm, rel, val);
// The following is to make sure the leader always has the right to change perms if that is our goal.
if (perm == FPerm.PERMS && FPerm.PERMS.getDefault(faction).contains(Rel.LEADER))
{
faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true);
}
msg(Txt.titleize("Perm for " + faction.describeTo(usender, true)));
msg(FPerm.getStateHeaders());
msg(perm.getStateInfo(faction.getPermittedRelations(perm), true));
}
}

View File

@@ -1,85 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.LinkedHashMap;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.Progressbar;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.TimeDiffUtil;
import com.massivecraft.massivecore.util.TimeUnit;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsPlayer extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsPlayer()
{
// Aliases
this.addAliases("p", "player");
// Args
this.addOptionalArg("player", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender), usender);
if (uplayer == null) return;
// INFO: Title
msg(Txt.titleize(Txt.upperCaseFirst(uplayer.getUniverse()) + " Player " + uplayer.describeTo(usender)));
// INFO: Power (as progress bar)
double progressbarQuota = uplayer.getPower() / uplayer.getPowerMax();
int progressbarWidth = (int) Math.round(uplayer.getPowerMax() / uplayer.getPowerMaxUniversal() * 100);
msg("<k>Power: <v>%s", Progressbar.HEALTHBAR_CLASSIC.withQuota(progressbarQuota).withWidth(progressbarWidth).render());
// INFO: Power (as digits)
msg("<k>Power: <v>%.2f / %.2f", uplayer.getPower(), uplayer.getPowerMax());
// INFO: Power Boost
if (uplayer.hasPowerBoost())
{
double powerBoost = uplayer.getPowerBoost();
String powerBoostType = (powerBoost > 0 ? "bonus" : "penalty");
msg("<k>Power Boost: <v>%f <i>(a manually granted %s)", powerBoost, powerBoostType);
}
// INFO: Power per Hour
// If the player is not at maximum we wan't to display how much time left.
String stringTillMax = "";
double powerTillMax = uplayer.getPowerMax() - uplayer.getPower();
if (powerTillMax > 0)
{
long millisTillMax = (long) (powerTillMax * TimeUnit.MILLIS_PER_HOUR / uplayer.getPowerPerHour());
LinkedHashMap<TimeUnit, Long> unitcountsTillMax = TimeDiffUtil.unitcounts(millisTillMax, TimeUnit.getAllButMillis());
unitcountsTillMax = TimeDiffUtil.limit(unitcountsTillMax, 2);
String unitcountsTillMaxFormated = TimeDiffUtil.formatedVerboose(unitcountsTillMax, "<i>");
stringTillMax = Txt.parse(" <i>(%s <i>left till max)", unitcountsTillMaxFormated);
}
msg("<k>Power per Hour: <v>%.2f%s", uplayer.getPowerPerHour(), stringTillMax);
// INFO: Power per Death
msg("<k>Power per Death: <v>%.2f", uplayer.getPowerPerDeath());
}
}

View File

@@ -1,80 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARDouble;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsPowerBoost extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsPowerBoost()
{
// Aliases
this.addAliases("powerboost");
// Args
this.addRequiredArg("p|f|player|faction");
this.addRequiredArg("name");
this.addRequiredArg("#");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
String type = this.arg(0).toLowerCase();
boolean doPlayer = true;
if (type.equals("f") || type.equals("faction"))
{
doPlayer = false;
}
else if (!type.equals("p") && !type.equals("player"))
{
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
return;
}
Double targetPower = this.arg(2, ARDouble.get());
if (targetPower == null) return;
String target;
if (doPlayer)
{
UPlayer targetPlayer = this.arg(1, ARUPlayer.getAny(sender));
if (targetPlayer == null) return;
targetPlayer.setPowerBoost(targetPower);
target = "Player \""+targetPlayer.getName()+"\"";
}
else
{
Faction targetFaction = this.arg(1, ARFaction.get(sender));
if (targetFaction == null) return;
targetFaction.setPowerBoost(targetPower);
target = "Faction \""+targetFaction.getName()+"\"";
}
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
Factions.get().log(usender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
}
}

View File

@@ -1,78 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsPromote extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsPromote()
{
// Aliases
this.addAliases("promote");
// Args
this.addRequiredArg("player");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node));
//To promote someone from recruit -> member you must be an officer.
//To promote someone from member -> officer you must be a leader.
//We'll handle this internally
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
UPlayer you = this.arg(0, ARUPlayer.getAny(sender));
if (you == null) return;
if (you.getFaction() != usenderFaction)
{
msg("%s<b> is not a member in your faction.", you.describeTo(usender, true));
return;
}
if (you == usender)
{
msg("<b>The target player mustn't be yourself.");
return;
}
if (you.getRole() == Rel.RECRUIT)
{
if (!usender.getRole().isAtLeast(Rel.OFFICER))
{
msg("<b>You must be an officer to promote someone to member.");
return;
}
you.setRole(Rel.MEMBER);
usenderFaction.msg("%s<i> was promoted to being a member of your faction.", you.describeTo(usenderFaction, true));
}
else if (you.getRole() == Rel.MEMBER)
{
if (!usender.getRole().isAtLeast(Rel.LEADER))
{
msg("<b>You must be the leader to promote someone to officer.");
return;
}
// Give
you.setRole(Rel.OFFICER);
usenderFaction.msg("%s<i> was promoted to being a officer in your faction.", you.describeTo(usenderFaction, true));
}
}
}

View File

@@ -1,107 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FFlag;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsRelationChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public abstract class CmdFactionsRelationAbstract extends FCommand
{
public Rel targetRelation;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsRelationAbstract()
{
// Aliases
this.addRequiredArg("faction");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction otherFaction = this.arg(0, ARFaction.get(sender));
if (otherFaction == null) return;
Rel newRelation = targetRelation;
/*if ( ! them.isNormal())
{
msg("<b>Nope! You can't.");
return;
}*/
// Verify
if (otherFaction == usenderFaction)
{
msg("<b>Nope! You can't declare a relation to yourself :)");
return;
}
if (usenderFaction.getRelationWish(otherFaction) == newRelation)
{
msg("<b>You already have that relation wish set with %s.", otherFaction.getName());
return;
}
// Event
EventFactionsRelationChange event = new EventFactionsRelationChange(sender, usenderFaction, otherFaction, newRelation);
event.run();
if (event.isCancelled()) return;
newRelation = event.getNewRelation();
// try to set the new relation
usenderFaction.setRelationWish(otherFaction, newRelation);
Rel currentRelation = usenderFaction.getRelationTo(otherFaction, true);
// if the relation change was successful
if (newRelation == currentRelation)
{
otherFaction.msg("%s<i> is now %s.", usenderFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne());
usenderFaction.msg("%s<i> is now %s.", otherFaction.describeTo(usenderFaction, true), newRelation.getDescFactionOne());
}
// inform the other faction of your request
else
{
otherFaction.msg("%s<i> wishes to be %s.", usenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
otherFaction.msg("<i>Type <c>/"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+usenderFaction.getName()+"<i> to accept.");
usenderFaction.msg("%s<i> were informed that you wish to be %s<i>.", otherFaction.describeTo(usenderFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
}
// TODO: The ally case should work!!
// * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only
if ( newRelation != Rel.TRUCE && otherFaction.getFlag(FFlag.PEACEFUL))
{
otherFaction.msg("<i>This will have no effect while your faction is peaceful.");
usenderFaction.msg("<i>This will have no effect while their faction is peaceful.");
}
if ( newRelation != Rel.TRUCE && usenderFaction.getFlag(FFlag.PEACEFUL))
{
otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
usenderFaction.msg("<i>This will have no effect while your faction is peaceful.");
}
}
}

View File

@@ -1,20 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
public class CmdFactionsRelationAlly extends CmdFactionsRelationAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsRelationAlly()
{
// Aliases
this.addAliases("ally");
// Misc
this.targetRelation = Rel.ALLY;
}
}

View File

@@ -1,20 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
public class CmdFactionsRelationEnemy extends CmdFactionsRelationAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsRelationEnemy()
{
// Aliases
this.addAliases("enemy");
// Misc
this.targetRelation = Rel.ENEMY;
}
}

View File

@@ -1,20 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
public class CmdFactionsRelationNeutral extends CmdFactionsRelationAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsRelationNeutral()
{
// Aliases
this.addAliases("neutral");
// Misc
this.targetRelation = Rel.NEUTRAL;
}
}

View File

@@ -1,20 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
public class CmdFactionsRelationTruce extends CmdFactionsRelationAbstract
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsRelationTruce()
{
// Aliases
this.addAliases("truce");
// Misc
this.targetRelation = Rel.TRUCE;
}
}

View File

@@ -1,81 +0,0 @@
package com.massivecraft.factions.cmd;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.util.VisualizeUtil;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
public class CmdFactionsSeeChunk extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsSeeChunk()
{
// Aliases
this.addAliases("sc", "seechunk");
// Requirements
// this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node));
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
World world = me.getWorld();
PS chunk = PS.valueOf(me).getChunk(true);
int chunkX = chunk.getChunkX();
int chunkZ = chunk.getChunkZ();
// Apply
int blockX;
int blockZ;
blockX = chunkX*16;
blockZ = chunkZ*16;
showPillar(me, world, blockX, blockZ);
blockX = chunkX*16 + 15;
blockZ = chunkZ*16;
showPillar(me, world, blockX, blockZ);
blockX = chunkX*16;
blockZ = chunkZ*16 + 15;
showPillar(me, world, blockX, blockZ);
blockX = chunkX*16 + 15;
blockZ = chunkZ*16 + 15;
showPillar(me, world, blockX, blockZ);
// Inform
msg("<i>Visualized %s", chunk.toString(PSFormatHumanSpace.get()));
}
@SuppressWarnings("deprecation")
public static void showPillar(Player player, World world, int blockX, int blockZ)
{
for (int blockY = 0; blockY < world.getMaxHeight(); blockY++)
{
Location loc = new Location(world, blockX, blockY, blockZ);
if (loc.getBlock().getType() != Material.AIR) continue;
int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
VisualizeUtil.addLocation(player, loc, typeId);
}
}
}

View File

@@ -1,83 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.event.EventFactionsHomeChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsSethome extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsSethome()
{
// Aliases
this.addAliases("sethome");
// Args
this.addOptionalArg("faction", "you");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction);
if (faction == null) return;
PS newHome = PS.valueOf(me.getLocation());
// Validate
if ( ! UConf.get(faction).homesEnabled)
{
usender.msg("<b>Sorry, Faction homes are disabled on this server.");
return;
}
// FPerm
if ( ! FPerm.SETHOME.has(usender, faction, true)) return;
// Verify
if (!usender.isUsingAdminMode() && !faction.isValidHome(newHome))
{
usender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
return;
}
// Event
EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, newHome);
event.run();
if (event.isCancelled()) return;
newHome = event.getNewHome();
// Apply
faction.setHome(newHome);
// Inform
faction.msg("%s<i> set the home for your faction. You can now use:", usender.describeTo(usenderFaction, true));
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
if (faction != usenderFaction)
{
usender.msg("<b>You have set the home for the "+faction.getName(usender)+"<i> faction.");
}
}
}

View File

@@ -1,73 +0,0 @@
package com.massivecraft.factions.cmd;
import org.bukkit.ChatColor;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.arg.ARUPlayer;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.event.EventFactionsTitleChange;
import com.massivecraft.massivecore.cmd.arg.ARString;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.util.Txt;
public class CmdFactionsTitle extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsTitle()
{
// Aliases
this.addAliases("title");
// Args
this.addRequiredArg("player");
this.addOptionalArg("title", "");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
UPlayer you = this.arg(0, ARUPlayer.getAny(sender));
if (you == null) return;
String newTitle = this.argConcatFrom(1, ARString.get(), "");
if (newTitle == null) return;
newTitle = Txt.parse(newTitle);
if (!Perm.TITLE_COLOR.has(sender, false))
{
newTitle = ChatColor.stripColor(newTitle);
}
// Verify
if ( ! canIAdministerYou(usender, you)) return;
// Event
EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
event.run();
if (event.isCancelled()) return;
newTitle = event.getNewTitle();
// Apply
you.setTitle(newTitle);
// Inform
usenderFaction.msg("%s<i> changed a title: %s", usender.describeTo(usenderFaction, true), you.describeTo(usenderFaction, true));
}
}

View File

@@ -1,45 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsUnclaim extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsUnclaim()
{
// Aliases
this.addAliases("unclaim");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqIsPlayer.get());
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
PS chunk = PS.valueOf(me).getChunk(true);
Faction newFaction = FactionColls.get().get(me).getNone();
// Apply
if (usender.tryClaim(newFaction, chunk, true, true)) return;
}
}

View File

@@ -1,84 +0,0 @@
package com.massivecraft.factions.cmd;
import java.util.Set;
import com.massivecraft.factions.FPerm;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.EventFactionsChunkChange;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsUnclaimall extends FCommand
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsUnclaimall()
{
// Aliases
this.addAliases("unclaimall");
// Requirements
this.addRequirements(ReqFactionsEnabled.get());
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform()
{
// Args
Faction faction = usenderFaction;
Faction newFaction = FactionColls.get().get(faction).getNone();
// FPerm
if (!FPerm.TERRITORY.has(usender, faction, true)) return;
// Apply
BoardColl boardColl = BoardColls.get().get(faction);
Set<PS> chunks = boardColl.getChunks(faction);
int countTotal = chunks.size();
int countSuccess = 0;
int countFail = 0;
for (PS chunk : chunks)
{
EventFactionsChunkChange event = new EventFactionsChunkChange(sender, chunk, newFaction);
event.run();
if (event.isCancelled())
{
countFail++;
}
else
{
countSuccess++;
boardColl.setFactionAt(chunk, newFaction);
}
}
// Inform
usenderFaction.msg("%s<i> unclaimed <h>%d <i>of your <h>%d <i>faction land. You now have <h>%d <i>land claimed.", usender.describeTo(usenderFaction, true), countSuccess, countTotal, countFail);
// Log
if (MConf.get().logLandUnclaims)
{
Factions.get().log(usender.getName()+" unclaimed everything for the faction: "+usenderFaction.getName());
}
}
}

View File

@@ -1,80 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.util.Txt;
public abstract class FCommand extends MassiveCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public MPlayer msender;
public UPlayer usender;
public Faction usenderFaction;
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void fixSenderVars()
{
this.msender = MPlayer.get(sender);
this.usender = null;
this.usenderFaction = null;
// Check disabled
if (UConf.isDisabled(sender)) return;
this.usender = UPlayer.get(this.sender);
this.usenderFaction = this.usender.getFaction();
}
// -------------------------------------------- //
// COMMONLY USED LOGIC
// -------------------------------------------- //
public boolean canIAdministerYou(UPlayer i, UPlayer you)
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
return false;
}
if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
{
return true;
}
if (you.getRole().equals(Rel.LEADER))
{
i.sendMessage(Txt.parse("<b>Only the faction leader can do that."));
}
else if (i.getRole().equals(Rel.OFFICER))
{
if ( i == you )
{
return true; //Moderators can control themselves
}
else
{
i.sendMessage(Txt.parse("<b>Moderators can't control each other..."));
}
}
else
{
i.sendMessage(Txt.parse("<b>You must be a faction moderator to do that."));
}
return false;
}
}

View File

@@ -1,51 +0,0 @@
package com.massivecraft.factions.cmd.arg;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.FFlag;
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
import com.massivecraft.massivecore.util.Txt;
public class ARFFlag extends ARAbstractSelect<FFlag>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARFFlag i = new ARFFlag();
public static ARFFlag get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String typename()
{
return "faction flag";
}
@Override
public FFlag select(String str, CommandSender sender)
{
return FFlag.parse(str);
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (FFlag fflag : FFlag.values())
{
ret.add(Txt.getNicedEnum(fflag));
}
return ret;
}
}

View File

@@ -1,51 +0,0 @@
package com.massivecraft.factions.cmd.arg;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.FPerm;
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
import com.massivecraft.massivecore.util.Txt;
public class ARFPerm extends ARAbstractSelect<FPerm>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARFPerm i = new ARFPerm();
public static ARFPerm get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String typename()
{
return "faction permission";
}
@Override
public FPerm select(String str, CommandSender sender)
{
return FPerm.parse(str);
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (FPerm fperm : FPerm.values())
{
ret.add(Txt.getNicedEnum(fperm));
}
return ret;
}
}

View File

@@ -1,64 +0,0 @@
package com.massivecraft.factions.cmd.arg;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract;
import com.massivecraft.massivecore.cmd.arg.ArgResult;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.Txt;
public class ARFaction extends ArgReaderAbstract<Faction>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static ARFaction get(Object universe) { return new ARFaction(FactionColls.get().get(universe)); }
private ARFaction(FactionColl coll)
{
this.coll = coll;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final FactionColl coll;
public FactionColl getColl() { return this.coll;}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public ArgResult<Faction> read(String str, CommandSender sender)
{
ArgResult<Faction> result = new ArgResult<Faction>();
// Faction Name Exact
result.setResult(this.getColl().getByName(str));
if (result.hasResult()) return result;
// Faction Name Match
result.setResult(this.getColl().getBestNameMatch(str));
if (result.hasResult()) return result;
// UPlayer Name Exact
String id = IdUtil.getId(str);
UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(id);
if (uplayer != null)
{
result.setResult(uplayer.getFaction());
return result;
}
result.setErrors(Txt.parse("<b>No faction or player matching \"<p>%s<b>\".", str));
return result;
}
}

View File

@@ -1,51 +0,0 @@
package com.massivecraft.factions.cmd.arg;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Rel;
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
import com.massivecraft.massivecore.util.Txt;
public class ARRel extends ARAbstractSelect<Rel>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ARRel i = new ARRel();
public static ARRel get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public String typename()
{
return "role";
}
@Override
public Rel select(String str, CommandSender sender)
{
return Rel.parse(str);
}
@Override
public Collection<String> altNames(CommandSender sender)
{
List<String> ret = new ArrayList<String>();
for (Rel rel : Rel.values())
{
ret.add(Txt.getNicedEnum(rel));
}
return ret;
}
}

View File

@@ -1,17 +0,0 @@
package com.massivecraft.factions.cmd.arg;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.factions.entity.UPlayerColls;
import com.massivecraft.massivecore.cmd.arg.ArgReader;
public class ARUPlayer
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
public static ArgReader<UPlayer> getAny(Object o) { return UPlayerColls.get().get(o).getAREntity(); }
public static ArgReader<UPlayer> getOnline(Object o) { return UPlayerColls.get().get(o).getAREntity(true); }
}

View File

@@ -1,42 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt;
public class ReqBankCommandsEnabled extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqBankCommandsEnabled i = new ReqBankCommandsEnabled();
public static ReqBankCommandsEnabled get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled;
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
UConf uconf = UConf.get(sender);
if (!uconf.bankEnabled)
{
return Txt.parse("<b>Faction banks are disabled in the <h>%s <b>universe.", uconf.getUniverse());
}
return Txt.parse("<b>Faction economy features are disabled in the <h>%s <b>universe.", uconf.getUniverse());
}
}

View File

@@ -1,36 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UConf;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
public class ReqFactionsEnabled extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqFactionsEnabled i = new ReqFactionsEnabled();
public static ReqFactionsEnabled get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return !UConf.isDisabled(sender);
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return UConf.getDisabledMessage(sender);
}
}

View File

@@ -1,37 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt;
public class ReqHasFaction extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqHasFaction i = new ReqHasFaction();
public static ReqHasFaction get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return UPlayer.get(sender).hasFaction();
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return Txt.parse("<b>You must belong to a faction to "+(command == null ? "do that" : command.getDesc())+".");
}
}

View File

@@ -1,37 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt;
public class ReqHasntFaction extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static ReqHasntFaction i = new ReqHasntFaction();
public static ReqHasntFaction get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
return !UPlayer.get(sender).hasFaction();
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return Txt.parse("<b>You must leave your current faction before you "+(command == null ? "do that" : command.getDesc())+".");
}
}

View File

@@ -1,46 +0,0 @@
package com.massivecraft.factions.cmd.req;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
import com.massivecraft.massivecore.util.Txt;
public class ReqRoleIsAtLeast extends ReqAbstract
{
private static final long serialVersionUID = 1L;
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private final Rel rel;
public Rel getRel() { return this.rel; }
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
public static ReqRoleIsAtLeast get(Rel rel) { return new ReqRoleIsAtLeast(rel); }
private ReqRoleIsAtLeast(Rel rel) { this.rel = rel; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(CommandSender sender, MassiveCommand command)
{
UPlayer uplayer = UPlayer.get(sender);
return uplayer.getRole().isAtLeast(this.rel);
}
@Override
public String createErrorMessage(CommandSender sender, MassiveCommand command)
{
return Txt.parse("<b>You must be <h>%s <b>or higher to "+(command == null ? "do that" : command.getDesc())+".", Txt.getNicedEnum(this.rel));
}
}