Remove Maven
This commit is contained in:
@@ -1,124 +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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// 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 CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
|
||||
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
|
||||
public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
|
||||
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
|
||||
public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
|
||||
public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
|
||||
public CmdFactionsRank cmdFactionsRank = new CmdFactionsRank();
|
||||
public CmdFactionsRankOld cmdFactionsRankOldLeader = new CmdFactionsRankOld("leader");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldOfficer = new CmdFactionsRankOld("officer");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldPromote = new CmdFactionsRankOld("promote");
|
||||
public CmdFactionsRankOld cmdFactionsRankOldDemote = new CmdFactionsRankOld("demote");
|
||||
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
|
||||
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
|
||||
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
|
||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
|
||||
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 CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
|
||||
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
|
||||
public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
|
||||
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
|
||||
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
|
||||
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
|
||||
public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version");
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactions()
|
||||
{
|
||||
// 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.cmdFactionsMotd);
|
||||
this.addSubCommand(this.cmdFactionsSethome);
|
||||
this.addSubCommand(this.cmdFactionsUnsethome);
|
||||
this.addSubCommand(this.cmdFactionsInvite);
|
||||
this.addSubCommand(this.cmdFactionsKick);
|
||||
this.addSubCommand(this.cmdFactionsTitle);
|
||||
this.addSubCommand(this.cmdFactionsRank);
|
||||
this.addSubCommand(this.cmdFactionsRankOldLeader);
|
||||
this.addSubCommand(this.cmdFactionsRankOldOfficer);
|
||||
this.addSubCommand(this.cmdFactionsRankOldPromote);
|
||||
this.addSubCommand(this.cmdFactionsRankOldDemote);
|
||||
this.addSubCommand(this.cmdFactionsMoney);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunk);
|
||||
this.addSubCommand(this.cmdFactionsSeeChunkOld);
|
||||
this.addSubCommand(this.cmdFactionsClaim);
|
||||
this.addSubCommand(this.cmdFactionsUnclaim);
|
||||
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.cmdFactionsExpansions);
|
||||
this.addSubCommand(this.cmdFactionsTax);
|
||||
this.addSubCommand(this.cmdFactionsDynmap);
|
||||
this.addSubCommand(this.cmdFactionsAdmin);
|
||||
this.addSubCommand(this.cmdFactionsDisband);
|
||||
this.addSubCommand(this.cmdFactionsPowerBoost);
|
||||
this.addSubCommand(this.cmdFactionsVersion);
|
||||
|
||||
// Deprecated Commands
|
||||
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsClaim.cmdFactionsClaimAuto, "autoclaim"));
|
||||
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall"));
|
||||
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFlag, "open"));
|
||||
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFaction, "show", "who"));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public List<String> getAliases()
|
||||
{
|
||||
return MConf.get().aliasesF;
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
|
||||
|
||||
public class CmdFactionsAccess extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// 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(ReqIsPlayer.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node));
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +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.entity.BoardColl;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public PS chunk;
|
||||
public TerritoryAccess ta;
|
||||
public Faction hostFaction;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAccessAbstract()
|
||||
{
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
ta = BoardColl.get().getTerritoryAccessAt(chunk);
|
||||
hostFaction = ta.getHostFaction();
|
||||
|
||||
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(msender, true));
|
||||
msg("<k>Host Faction Allowed: %s", ta.isHostFactionAllowed() ? Txt.parse("<lime>TRUE") : Txt.parse("<rose>FALSE"));
|
||||
msg("<k>Granted Players: %s", describeRelationParticipators(ta.getGrantedMPlayers(), msender));
|
||||
msg("<k>Granted Factions: %s", describeRelationParticipators(ta.getGrantedFactions(), msender));
|
||||
}
|
||||
|
||||
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 "));
|
||||
}
|
||||
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
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());
|
||||
if (faction == null) return;
|
||||
|
||||
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId()));
|
||||
if (newValue == null) return;
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withFactionId(faction.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
this.sendAccessInfo();
|
||||
}
|
||||
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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
|
||||
MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
|
||||
if (mplayer == null) return;
|
||||
|
||||
Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(mplayer.getId()));
|
||||
if (newValue == null) return;
|
||||
|
||||
// MPerm
|
||||
if (!MPerm.getPermAccess().has(msender, hostFaction, true)) return;
|
||||
|
||||
// Apply
|
||||
ta = ta.withPlayerId(mplayer.getId(), newValue);
|
||||
BoardColl.get().setTerritoryAccessAt(chunk, ta);
|
||||
|
||||
// Inform
|
||||
this.sendAccessInfo();
|
||||
}
|
||||
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
@@ -1,52 +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;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsAdmin extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsAdmin()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("admin");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("on/off", "flip");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode());
|
||||
if (target == null) return;
|
||||
|
||||
// Apply
|
||||
msender.setUsingAdminMode(target);
|
||||
|
||||
// Inform
|
||||
String desc = Txt.parse(msender.isUsingAdminMode() ? "<g>ENABLED" : "<b>DISABLED");
|
||||
|
||||
String messageYou = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(msender), desc);
|
||||
String messageLog = Txt.parse("<i>%s %s <i>admin bypass mode.", msender.getDisplayName(IdUtil.getConsole()), desc);
|
||||
|
||||
msender.sendMessage(messageYou);
|
||||
Factions.get().log(messageLog);
|
||||
}
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
|
||||
public class CmdFactionsClaim extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetOne cmdFactionsClaimOne = new CmdFactionsSetOne(true);
|
||||
public CmdFactionsSetAuto cmdFactionsClaimAuto = new CmdFactionsSetAuto(true);
|
||||
public CmdFactionsSetFill cmdFactionsClaimFill = new CmdFactionsSetFill(true);
|
||||
public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true);
|
||||
public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true);
|
||||
public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsClaim()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("claim");
|
||||
|
||||
// Add SubCommands
|
||||
this.addSubCommand(this.cmdFactionsClaimOne);
|
||||
this.addSubCommand(this.cmdFactionsClaimAuto);
|
||||
this.addSubCommand(this.cmdFactionsClaimFill);
|
||||
this.addSubCommand(this.cmdFactionsClaimSquare);
|
||||
this.addSubCommand(this.cmdFactionsClaimCircle);
|
||||
this.addSubCommand(this.cmdFactionsClaimAll);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
|
||||
}
|
||||
|
||||
}
|
@@ -1,91 +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.ReqHasntFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsCreate()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("create");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("name");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasntFaction.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.CREATE.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
String newName = this.arg(0);
|
||||
|
||||
// Verify
|
||||
if (FactionColl.get().isNameTaken(newName))
|
||||
{
|
||||
msg("<b>That name is already in use.");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> nameValidationErrors = FactionColl.get().validateName(newName);
|
||||
if (nameValidationErrors.size() > 0)
|
||||
{
|
||||
sendMessage(nameValidationErrors);
|
||||
return;
|
||||
}
|
||||
|
||||
// Pre-Generate Id
|
||||
String factionId = MStore.createId();
|
||||
|
||||
// Event
|
||||
EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName);
|
||||
createEvent.run();
|
||||
if (createEvent.isCancelled()) return;
|
||||
|
||||
// Apply
|
||||
Faction faction = FactionColl.get().create(factionId);
|
||||
faction.setName(newName);
|
||||
|
||||
msender.setRole(Rel.LEADER);
|
||||
msender.setFaction(faction);
|
||||
|
||||
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
|
||||
joinEvent.run();
|
||||
// NOTE: join event cannot be cancelled or you'll have an empty faction
|
||||
|
||||
// Inform
|
||||
msg("<i>You created the faction %s", faction.getName(msender));
|
||||
msg("<i>You should now: %s", Factions.get().getOuterCmdFactions().cmdFactionsDescription.getUseageTemplate());
|
||||
|
||||
// Log
|
||||
if (MConf.get().logFactionCreate)
|
||||
{
|
||||
Factions.get().log(msender.getName()+" created a new faction: "+newName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
|
||||
public class CmdFactionsDescription extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDescription()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("desc");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("desc");
|
||||
this.setErrorOnToManyArgs(false);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
String newDescription = this.argConcatFrom(0);
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermDesc().has(msender, msenderFaction, true)) return;
|
||||
|
||||
// Event
|
||||
EventFactionsDescriptionChange event = new EventFactionsDescriptionChange(sender, msenderFaction, newDescription);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
newDescription = event.getNewDescription();
|
||||
|
||||
// Apply
|
||||
msenderFaction.setDescription(newDescription);
|
||||
|
||||
// Inform
|
||||
for (MPlayer follower : msenderFaction.getMPlayers())
|
||||
{
|
||||
follower.msg("<i>%s <i>set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,93 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
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.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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDisband()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("disband");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermDisband().has(msender, faction, true)) return;
|
||||
|
||||
// Verify
|
||||
if (faction.getFlag(MFlag.getFlagPermanent()))
|
||||
{
|
||||
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 (MPlayer mplayer : faction.getMPlayers())
|
||||
{
|
||||
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND);
|
||||
membershipChangeEvent.run();
|
||||
}
|
||||
|
||||
// Inform
|
||||
for (MPlayer mplayer : faction.getMPlayersWhereOnline(true))
|
||||
{
|
||||
mplayer.msg("<h>%s<i> disbanded your faction.", msender.describeTo(mplayer));
|
||||
}
|
||||
|
||||
if (msenderFaction != faction)
|
||||
{
|
||||
msender.msg("<i>You disbanded <h>%s<i>." , faction.describeTo(msender));
|
||||
}
|
||||
|
||||
// Log
|
||||
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(), msender.getDisplayName(IdUtil.getConsole())));
|
||||
}
|
||||
|
||||
// Apply
|
||||
faction.detach();
|
||||
}
|
||||
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.massivecraft.factions.event.EventFactionsExpansions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsExpansions extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsExpansions()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("e", "expansions");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.EXPANSIONS.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Event
|
||||
EventFactionsExpansions event = new EventFactionsExpansions(sender);
|
||||
event.run();
|
||||
|
||||
// Title
|
||||
msg(Txt.titleize("Factions Expansions"));
|
||||
|
||||
// Lines
|
||||
for (Entry<String, Boolean> entry : event.getExpansions().entrySet())
|
||||
{
|
||||
String name = entry.getKey();
|
||||
Boolean installed = entry.getValue();
|
||||
String format = (installed ? "<g>[X] <h>%s" : "<b>[ ] <h>%s");
|
||||
msg(format, name);
|
||||
}
|
||||
|
||||
// URL Suggestion
|
||||
msg("<i>Learn all about expansions in the online documentation:");
|
||||
msg("<aqua>http://www.massivecraft.com/factions");
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.event.EventFactionsFactionShowAsync;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.PriorityLines;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsFaction extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsFaction()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("f", "faction");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.FACTION.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
final CommandSender sender = this.sender;
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Event
|
||||
EventFactionsFactionShowAsync event = new EventFactionsFactionShowAsync(sender, faction);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Title
|
||||
Mixin.messageOne(sender, Txt.titleize("Faction " + faction.getName(msender)));
|
||||
|
||||
// Lines
|
||||
TreeSet<PriorityLines> priorityLiness = new TreeSet<PriorityLines>(event.getIdPriorityLiness().values());
|
||||
for (PriorityLines priorityLines : priorityLiness)
|
||||
{
|
||||
Mixin.messageOne(sender, priorityLines.getLines());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMFlag;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.event.EventFactionsFlagChange;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsFlag extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsFlag()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("flag");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
this.addOptionalArg("flag", "all");
|
||||
this.addOptionalArg("yes/no", "read");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.FLAG.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Arg: Faction
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
// Case: Show All
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
msg(Txt.titleize("Flags for " + faction.describeTo(msender, true)));
|
||||
for (MFlag mflag : MFlag.getAll())
|
||||
{
|
||||
if (!mflag.isVisible() && !msender.isUsingAdminMode()) continue;
|
||||
msg(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Arg: MFlag
|
||||
MFlag mflag = this.arg(1, ARMFlag.get());
|
||||
if (mflag == null) return;
|
||||
|
||||
// Case: Show One
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(Txt.titleize("Flag for " + faction.describeTo(msender, true)));
|
||||
msg(mflag.getStateDesc(faction.getFlag(mflag), true, true, true, true, false));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do the sender have the right to change flags for this faction?
|
||||
if ( ! MPerm.getPermFlags().has(msender, faction, true)) return;
|
||||
|
||||
// Is this flag editable?
|
||||
if (!msender.isUsingAdminMode() && !mflag.isEditable())
|
||||
{
|
||||
msg("<b>The flag <h>%s <b>is not editable.", mflag.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Arg: Target Value
|
||||
Boolean targetValue = this.arg(2, ARBoolean.get());
|
||||
if (targetValue == null) return;
|
||||
|
||||
// Event
|
||||
EventFactionsFlagChange event = new EventFactionsFlagChange(sender, faction, mflag, targetValue);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
targetValue = event.isNewValue();
|
||||
|
||||
// Apply
|
||||
faction.setFlag(mflag, targetValue);
|
||||
|
||||
// Inform
|
||||
String stateInfo = mflag.getStateDesc(faction.getFlag(mflag), true, false, true, true, true);
|
||||
if (msender.getFaction() != faction)
|
||||
{
|
||||
// Send message to sender
|
||||
msg("<h>%s <i>set a flag for <h>%s", msender.describeTo(msender, true), faction.describeTo(msender, true));
|
||||
msg(stateInfo);
|
||||
}
|
||||
faction.msg("<h>%s <i>set a flag for <h>%s", msender.describeTo(faction, true), faction.describeTo(faction, true));
|
||||
faction.msg(stateInfo);
|
||||
}
|
||||
|
||||
}
|
@@ -1,158 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 FactionsCommandHome
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsHome()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("home");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.HOME.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
if ( ! MConf.get().homesTeleportCommandEnabled)
|
||||
{
|
||||
msender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Args
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
PS home = faction.getHome();
|
||||
String homeDesc = "home for " + faction.describeTo(msender, false);
|
||||
|
||||
// Any and MPerm
|
||||
if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
|
||||
|
||||
if (home == null)
|
||||
{
|
||||
msender.msg("<b>%s <b>does not have a home.", faction.describeTo(msender, true));
|
||||
|
||||
if (MPerm.getPermSethome().has(msender, faction, false))
|
||||
{
|
||||
msender.msg("<i>You should:");
|
||||
msender.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getUseageTemplate());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory())
|
||||
{
|
||||
msender.msg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", homeDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(home.getWorld()))
|
||||
{
|
||||
msender.msg("<b>You cannot teleport to %s <b>while in a different world.", homeDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
|
||||
Location locationHere = 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
|
||||
(
|
||||
MConf.get().homesTeleportAllowedEnemyDistance > 0
|
||||
&&
|
||||
factionHere.getFlag(MFlag.getFlagPvp())
|
||||
&&
|
||||
(
|
||||
! msender.isInOwnTerritory()
|
||||
||
|
||||
(
|
||||
msender.isInOwnTerritory()
|
||||
&&
|
||||
! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory
|
||||
)
|
||||
)
|
||||
)
|
||||
{
|
||||
World w = locationHere.getWorld();
|
||||
double x = locationHere.getX();
|
||||
double y = locationHere.getY();
|
||||
double z = locationHere.getZ();
|
||||
|
||||
for (Player p : me.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
|
||||
continue;
|
||||
|
||||
MPlayer fp = MPlayer.get(p);
|
||||
if (msender.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 = MConf.get().homesTeleportAllowedEnemyDistance;
|
||||
|
||||
// box-shaped distance check
|
||||
if (dx > max || dy > max || dz > max)
|
||||
continue;
|
||||
|
||||
msender.msg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", homeDesc, MConf.get().homesTeleportAllowedEnemyDistance);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Apply
|
||||
try
|
||||
{
|
||||
Mixin.teleport(me, home, homeDesc, sender);
|
||||
}
|
||||
catch (TeleporterException e)
|
||||
{
|
||||
me.sendMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsInvite()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("inv", "invite");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("player");
|
||||
this.addOptionalArg("yes/no", "toggle");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.INVITE.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
|
||||
if (mplayer == null) return;
|
||||
|
||||
Boolean newInvited = this.arg(1, ARBoolean.get(), !msenderFaction.isInvited(mplayer));
|
||||
if (newInvited == null) return;
|
||||
|
||||
// Allready member?
|
||||
if (mplayer.getFaction() == msenderFaction)
|
||||
{
|
||||
msg("%s<i> is already a member of %s", mplayer.getName(), msenderFaction.getName());
|
||||
msg("<i>You might want to: " + Factions.get().getOuterCmdFactions().cmdFactionsKick.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
||||
|
||||
// Event
|
||||
EventFactionsInvitedChange event = new EventFactionsInvitedChange(sender, mplayer, msenderFaction, newInvited);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
newInvited = event.isNewInvited();
|
||||
|
||||
// Apply
|
||||
msenderFaction.setInvited(mplayer, newInvited);
|
||||
|
||||
// Inform
|
||||
if (newInvited)
|
||||
{
|
||||
mplayer.msg("%s<i> invited you to %s", msender.describeTo(mplayer, true), msenderFaction.describeTo(mplayer));
|
||||
msenderFaction.msg("%s<i> invited %s<i> to your faction.", msender.describeTo(msenderFaction, true), mplayer.describeTo(msenderFaction));
|
||||
}
|
||||
else
|
||||
{
|
||||
mplayer.msg("%s<i> revoked your invitation to <h>%s<i>.", msender.describeTo(mplayer), msenderFaction.describeTo(mplayer));
|
||||
msenderFaction.msg("%s<i> revoked %s's<i> invitation.", msender.describeTo(msenderFaction), mplayer.describeTo(msenderFaction));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,126 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsJoin()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("join");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("faction");
|
||||
this.addOptionalArg("player", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.JOIN.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.arg(0, ARFaction.get());
|
||||
if (faction == null) return;
|
||||
|
||||
MPlayer mplayer = this.arg(1, ARMPlayer.getAny(), msender);
|
||||
if (mplayer == null) return;
|
||||
Faction mplayerFaction = mplayer.getFaction();
|
||||
|
||||
boolean samePlayer = mplayer == msender;
|
||||
|
||||
// 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 == mplayerFaction)
|
||||
{
|
||||
msg("<i>%s <i>%s already a member of %s<i>.", mplayer.describeTo(msender, true), (samePlayer ? "are" : "is"), faction.getName(msender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (MConf.get().factionMemberLimit > 0 && faction.getMPlayers().size() >= MConf.get().factionMemberLimit)
|
||||
{
|
||||
msg(" <b>!<white> The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(msender), MConf.get().factionMemberLimit, mplayer.describeTo(msender, false));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mplayerFaction.isNormal())
|
||||
{
|
||||
msg("<b>%s must leave %s current faction first.", mplayer.describeTo(msender, true), (samePlayer ? "your" : "their"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
|
||||
{
|
||||
msg("<b>%s cannot join a faction with a negative power level.", mplayer.describeTo(msender, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if( ! (faction.getFlag(MFlag.getFlagOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false)))
|
||||
{
|
||||
msg("<i>This faction requires invitation.");
|
||||
if (samePlayer)
|
||||
{
|
||||
faction.msg("%s<i> tried to join your faction.", mplayer.describeTo(faction, true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.JOIN);
|
||||
membershipChangeEvent.run();
|
||||
if (membershipChangeEvent.isCancelled()) return;
|
||||
|
||||
// Inform
|
||||
if (!samePlayer)
|
||||
{
|
||||
mplayer.msg("<i>%s <i>moved you into the faction %s<i>.", msender.describeTo(mplayer, true), faction.getName(mplayer));
|
||||
}
|
||||
faction.msg("<i>%s <i>joined <lime>your faction<i>.", mplayer.describeTo(faction, true));
|
||||
msender.msg("<i>%s <i>successfully joined %s<i>.", mplayer.describeTo(msender, true), faction.getName(msender));
|
||||
|
||||
// Apply
|
||||
mplayer.resetFactionData();
|
||||
mplayer.setFaction(faction);
|
||||
|
||||
faction.setInvited(mplayer, false);
|
||||
|
||||
// Derplog
|
||||
if (MConf.get().logFactionJoin)
|
||||
{
|
||||
if (samePlayer)
|
||||
{
|
||||
Factions.get().log(Txt.parse("%s joined the faction %s.", mplayer.getName(), faction.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Factions.get().log(Txt.parse("%s moved the player %s into the faction %s.", msender.getName(), mplayer.getName(), faction.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,97 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsKick()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("kick");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("player");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.KICK.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Arg
|
||||
MPlayer mplayer = this.arg(0, ARMPlayer.getAny());
|
||||
if (mplayer == null) return;
|
||||
|
||||
// Validate
|
||||
if (msender == mplayer)
|
||||
{
|
||||
msg("<b>You cannot kick yourself.");
|
||||
msg("<i>You might want to: %s", Factions.get().getOuterCmdFactions().cmdFactionsLeave.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mplayer.getRole() == Rel.LEADER && !(this.senderIsConsole || msender.isUsingAdminMode()))
|
||||
{
|
||||
msg("<b>The leader can not be kicked.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! MConf.get().canLeaveWithNegativePower && mplayer.getPower() < 0)
|
||||
{
|
||||
msg("<b>You cannot kick that member until their power is positive.");
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm
|
||||
Faction mplayerFaction = mplayer.getFaction();
|
||||
if ( ! MPerm.getPermKick().has(msender, mplayerFaction, true)) return;
|
||||
|
||||
// Event
|
||||
EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, mplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Inform
|
||||
mplayerFaction.msg("%s<i> kicked %s<i> from the faction! :O", msender.describeTo(mplayerFaction, true), mplayer.describeTo(mplayerFaction, true));
|
||||
mplayer.msg("%s<i> kicked you from %s<i>! :O", msender.describeTo(mplayer, true), mplayerFaction.describeTo(mplayer));
|
||||
if (mplayerFaction != msenderFaction)
|
||||
{
|
||||
msender.msg("<i>You kicked %s<i> from the faction %s<i>!", mplayer.describeTo(msender), mplayerFaction.describeTo(msender));
|
||||
}
|
||||
|
||||
if (MConf.get().logFactionKick)
|
||||
{
|
||||
Factions.get().log(msender.getDisplayName(IdUtil.getConsole()) + " kicked " + mplayer.getName() + " from the faction " + mplayerFaction.getName());
|
||||
}
|
||||
|
||||
// Apply
|
||||
if (mplayer.getRole() == Rel.LEADER)
|
||||
{
|
||||
mplayerFaction.promoteNewLeader();
|
||||
}
|
||||
mplayerFaction.setInvited(mplayer, false);
|
||||
mplayer.resetFactionData();
|
||||
}
|
||||
|
||||
}
|
@@ -1,33 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsLeave extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsLeave()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("leave");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
msender.leave();
|
||||
}
|
||||
|
||||
}
|
@@ -1,90 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.FactionListComparator;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.pager.PagerSimple;
|
||||
import com.massivecraft.massivecore.pager.Stringifier;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsList extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsList()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("l", "list");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("page", "1");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.LIST.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Integer pageHumanBased = this.arg(0, ARInteger.get(), 1);
|
||||
if (pageHumanBased == null) return;
|
||||
|
||||
// NOTE: The faction list is quite slow and mostly thread safe.
|
||||
// We run it asynchronously to spare the primary server thread.
|
||||
final CommandSender sender = this.sender;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
// Create Pager
|
||||
final List<Faction> factions = FactionColl.get().getAll(null, FactionListComparator.get());
|
||||
final PagerSimple<Faction> pager = new PagerSimple<Faction>(factions, sender);
|
||||
|
||||
// Use Pager
|
||||
List<String> messages = pager.getPageTxt(pageHumanBased, "Faction List", new Stringifier<Faction>() {
|
||||
@Override
|
||||
public String toString(Faction faction)
|
||||
{
|
||||
if (faction.isNone())
|
||||
{
|
||||
return Txt.parse("<i>Factionless<i> %d online", FactionColl.get().getNone().getMPlayersWhereOnline(true).size());
|
||||
}
|
||||
else
|
||||
{
|
||||
return Txt.parse("%s<i> %d/%d online, %d/%d/%d",
|
||||
faction.getName(msender),
|
||||
faction.getMPlayersWhereOnline(true).size(),
|
||||
faction.getMPlayers().size(),
|
||||
faction.getLandCount(),
|
||||
faction.getPowerRounded(),
|
||||
faction.getPowerMaxRounded()
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Send Messages
|
||||
Mixin.messageOne(sender, messages);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.massivecraft.factions.Const;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMap()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("map");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("on/off", "once");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.MAP.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
if ( ! this.argIsSet(0))
|
||||
{
|
||||
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT_FULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.arg(0, ARBoolean.get(), !msender.isMapAutoUpdating()))
|
||||
{
|
||||
// And show the map once
|
||||
showMap(Const.MAP_WIDTH, Const.MAP_HEIGHT);
|
||||
|
||||
// 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(int width, int height)
|
||||
{
|
||||
Location location = me.getLocation();
|
||||
List<String> message = BoardColl.get().getMap(msenderFaction, PS.valueOf(location), location.getYaw(), width, height);
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsMoney extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// 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(ReqBankCommandsEnabled.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY.node));
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +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.entity.Faction;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsMoneyBalance extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyBalance()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("b", "balance");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node));
|
||||
this.addRequirements(ReqBankCommandsEnabled.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
if (faction != msenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return;
|
||||
|
||||
Econ.sendBalanceInfo(msender, faction);
|
||||
}
|
||||
|
||||
}
|
@@ -1,58 +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.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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyDeposit()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("d", "deposit");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("amount");
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
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(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
boolean success = Econ.transferMoney(msender, msender, faction, amount);
|
||||
|
||||
if (success && MConf.get().logMoneyTransactions)
|
||||
{
|
||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s deposited %s in the faction bank: %s", msender.getName(), Money.format(amount), faction.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +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.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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferFf()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("ff");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("amount");
|
||||
this.addRequiredArg("faction");
|
||||
this.addRequiredArg("faction");
|
||||
|
||||
// Requirements
|
||||
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());
|
||||
if (from == null) return;
|
||||
|
||||
Faction to = this.arg(2, ARFaction.get());
|
||||
if (to == null) return;
|
||||
|
||||
boolean success = Econ.transferMoney(msender, 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\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferFp()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("fp");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("amount");
|
||||
this.addRequiredArg("faction");
|
||||
this.addRequiredArg("player");
|
||||
|
||||
// Requirements
|
||||
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());
|
||||
if (from == null) return;
|
||||
|
||||
MPlayer to = this.arg(2, ARMPlayer.getAny());
|
||||
if (to == null) return;
|
||||
|
||||
boolean success = Econ.transferMoney(msender, 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\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyTransferPf()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("pf");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("amount");
|
||||
this.addRequiredArg("player");
|
||||
this.addRequiredArg("faction");
|
||||
|
||||
// Requirements
|
||||
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;
|
||||
|
||||
MPlayer from = this.arg(1, ARMPlayer.getAny());
|
||||
if (from == null) return;
|
||||
|
||||
Faction to = this.arg(2, ARFaction.get());
|
||||
if (to == null) return;
|
||||
|
||||
boolean success = Econ.transferMoney(msender, 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\"", msender.getName(), Money.format(amount), from.describeTo(null), to.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,62 +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.entity.MPlayer;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMoneyWithdraw()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("w", "withdraw");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("amount");
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
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(), msenderFaction);
|
||||
if (from == null) return;
|
||||
|
||||
MPlayer to = msender;
|
||||
|
||||
boolean success = Econ.transferMoney(msender, from, to, amount);
|
||||
|
||||
if (success && MConf.get().logMoneyTransactions)
|
||||
{
|
||||
Factions.get().log(ChatColor.stripColor(Txt.parse("%s withdrew %s from the faction bank: %s", msender.getName(), Money.format(amount), from.describeTo(null))));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,94 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsMotdChange;
|
||||
import com.massivecraft.massivecore.MassiveCore;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsMotd extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsMotd()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("motd");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("new", "read");
|
||||
this.setErrorOnToManyArgs(false);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.MOTD.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Read
|
||||
if ( ! this.argIsSet(0))
|
||||
{
|
||||
sendMessage(msenderFaction.getMotdMessages());
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermMotd().has(msender, msenderFaction, true)) return;
|
||||
|
||||
// Args
|
||||
String target = this.argConcatFrom(0);
|
||||
target = target.trim();
|
||||
target = Txt.parse(target);
|
||||
|
||||
// Removal
|
||||
if (target != null && MassiveCore.NOTHING_REMOVE.contains(target))
|
||||
{
|
||||
target = null;
|
||||
}
|
||||
|
||||
// Get Old
|
||||
String old = null;
|
||||
if (msenderFaction.hasMotd())
|
||||
{
|
||||
old = msenderFaction.getMotd();
|
||||
}
|
||||
|
||||
// Target Desc
|
||||
String targetDesc = target;
|
||||
if (targetDesc == null) targetDesc = Txt.parse("<silver>nothing");
|
||||
|
||||
// NoChange
|
||||
if (MUtil.equals(old, target))
|
||||
{
|
||||
msg("<i>The motd for %s <i>is already: <h>%s", msenderFaction.describeTo(msender, true), target);
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsMotdChange event = new EventFactionsMotdChange(sender, msenderFaction, target);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
target = event.getNewMotd();
|
||||
|
||||
// Apply
|
||||
msenderFaction.setMotd(target);
|
||||
|
||||
// Inform
|
||||
for (MPlayer follower : msenderFaction.getMPlayers())
|
||||
{
|
||||
follower.msg("<i>%s <i>set your faction motd to:\n%s", Mixin.getDisplayName(sender, follower), msenderFaction.getMotd());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,81 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.event.EventFactionsNameChange;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsName extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsName()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("name");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("new name");
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.NAME.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
String newName = this.arg(0);
|
||||
|
||||
Faction faction = this.arg(1, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermName().has(msender, faction, true)) return;
|
||||
|
||||
// TODO does not first test cover selfcase?
|
||||
if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(faction.getComparisonName()))
|
||||
{
|
||||
msg("<b>That name is already taken");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<String> errors = new ArrayList<String>();
|
||||
errors.addAll(FactionColl.get().validateName(newName));
|
||||
if (errors.size() > 0)
|
||||
{
|
||||
sendMessage(errors);
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsNameChange event = new EventFactionsNameChange(sender, faction, newName);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
newName = event.getNewName();
|
||||
|
||||
// Apply
|
||||
faction.setName(newName);
|
||||
|
||||
// Inform
|
||||
faction.msg("%s<i> changed your faction name to %s", msender.describeTo(faction, true), faction.getName(faction));
|
||||
if (msenderFaction != faction)
|
||||
{
|
||||
msg("<i>You changed the faction name to %s", faction.getName(msender));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -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.ARMPerm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.cmd.arg.ARRel;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARBoolean;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsPerm extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// 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(ReqHasPerm.get(Perm.PERM.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Arg: Faction
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
// Case: Show All
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
msg(Txt.titleize("Perms for " + faction.describeTo(msender, true)));
|
||||
msg(MPerm.getStateHeaders());
|
||||
for (MPerm perm : MPerm.getAll())
|
||||
{
|
||||
msg(perm.getStateInfo(faction.getPermitted(perm), true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Arg: MPerm
|
||||
MPerm mperm = this.arg(1, ARMPerm.get());
|
||||
if (mperm == null) return;
|
||||
|
||||
// Case: Show One
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
msg(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
|
||||
msg(MPerm.getStateHeaders());
|
||||
msg(mperm.getStateInfo(faction.getPermitted(mperm), true));
|
||||
return;
|
||||
}
|
||||
|
||||
// Do the sender have the right to change perms for this faction?
|
||||
if ( ! MPerm.getPermPerms().has(msender, faction, true)) return;
|
||||
|
||||
// Is this perm editable?
|
||||
if (!msender.isUsingAdminMode() && !mperm.isEditable())
|
||||
{
|
||||
msg("<b>The perm <h>%s <b>is not editable.", mperm.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Arg: Rel
|
||||
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.upperCaseFirst(mperm.getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Arg: Target Value
|
||||
Boolean targetValue = this.arg(3, ARBoolean.get(), null);
|
||||
if (targetValue == null) return;
|
||||
|
||||
// Apply
|
||||
faction.setRelationPermitted(mperm, rel, targetValue);
|
||||
|
||||
// The following is to make sure the leader always has the right to change perms if that is our goal.
|
||||
if (mperm == MPerm.getPermPerms() && MPerm.getPermPerms().getStandard().contains(Rel.LEADER))
|
||||
{
|
||||
faction.setRelationPermitted(MPerm.getPermPerms(), Rel.LEADER, true);
|
||||
}
|
||||
|
||||
// Inform
|
||||
msg(Txt.titleize("Perm for " + faction.describeTo(msender, true)));
|
||||
msg(MPerm.getStateHeaders());
|
||||
msg(mperm.getStateInfo(faction.getPermitted(mperm), true));
|
||||
}
|
||||
|
||||
}
|
@@ -1,114 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPlayer()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("p", "player");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("player", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
MPlayer mplayer = this.arg(0, ARMPlayer.getAny(), msender);
|
||||
if (mplayer == null) return;
|
||||
|
||||
// INFO: Title
|
||||
msg(Txt.titleize("Player " + mplayer.describeTo(msender)));
|
||||
|
||||
// INFO: Power (as progress bar)
|
||||
double progressbarQuota = 0;
|
||||
double playerPowerMax = mplayer.getPowerMax();
|
||||
if (playerPowerMax != 0)
|
||||
{
|
||||
progressbarQuota = mplayer.getPower() / playerPowerMax;
|
||||
}
|
||||
|
||||
int progressbarWidth = (int) Math.round(mplayer.getPowerMax() / mplayer.getPowerMaxUniversal() * 100);
|
||||
msg("<a>Power: <v>%s", Progressbar.HEALTHBAR_CLASSIC.withQuota(progressbarQuota).withWidth(progressbarWidth).render());
|
||||
|
||||
// INFO: Power (as digits)
|
||||
msg("<a>Power: <v>%.2f / %.2f", mplayer.getPower(), mplayer.getPowerMax());
|
||||
|
||||
// INFO: Power Boost
|
||||
if (mplayer.hasPowerBoost())
|
||||
{
|
||||
double powerBoost = mplayer.getPowerBoost();
|
||||
String powerBoostType = (powerBoost > 0 ? "bonus" : "penalty");
|
||||
msg("<a>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 = mplayer.getPowerMax() - mplayer.getPower();
|
||||
if (powerTillMax > 0)
|
||||
{
|
||||
long millisTillMax = (long) (powerTillMax * TimeUnit.MILLIS_PER_HOUR / mplayer.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("<a>Power per Hour: <v>%.2f%s", mplayer.getPowerPerHour(), stringTillMax);
|
||||
|
||||
// INFO: Power per Death
|
||||
msg("<a>Power per Death: <v>%.2f", mplayer.getPowerPerDeath());
|
||||
|
||||
// Display automatic kick / remove info if the system is in use
|
||||
if (MConf.get().removePlayerMillisDefault <= 0) return;
|
||||
|
||||
EventFactionsRemovePlayerMillis event = new EventFactionsRemovePlayerMillis(false, mplayer);
|
||||
event.run();
|
||||
msg("<i>Automatic removal after %s <i>of inactivity:", format(event.getMillis()));
|
||||
for (Entry<String, Long> causeMillis : event.getCauseMillis().entrySet())
|
||||
{
|
||||
String cause = causeMillis.getKey();
|
||||
long millis = causeMillis.getValue();
|
||||
msg("<a>%s<a>: <v>%s", cause, format(millis));
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// TIME FORMAT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String format(long millis)
|
||||
{
|
||||
LinkedHashMap<TimeUnit, Long> unitcounts = TimeDiffUtil.unitcounts(millis, TimeUnit.getAllBut(TimeUnit.MILLISECOND, TimeUnit.WEEK, TimeUnit.MONTH));
|
||||
return TimeDiffUtil.formatedVerboose(unitcounts);
|
||||
}
|
||||
|
||||
}
|
@@ -1,78 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARDouble;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsPowerBoost extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsPowerBoost()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("powerboost");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("p|f|player|faction");
|
||||
this.addRequiredArg("name");
|
||||
this.addRequiredArg("#");
|
||||
|
||||
// Requirements
|
||||
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)
|
||||
{
|
||||
MPlayer targetPlayer = this.arg(1, ARMPlayer.getAny());
|
||||
if (targetPlayer == null) return;
|
||||
|
||||
targetPlayer.setPowerBoost(targetPower);
|
||||
target = "Player \""+targetPlayer.getName()+"\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
Faction targetFaction = this.arg(1, ARFaction.get());
|
||||
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(msender.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
|
||||
}
|
||||
|
||||
}
|
@@ -1,346 +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.Rel;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.cmd.arg.ARRank;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.MPlayerColl;
|
||||
import com.massivecraft.factions.event.EventFactionsRankChange;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.util.IdUtil;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class CmdFactionsRank extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTANTS
|
||||
// -------------------------------------------- //
|
||||
|
||||
// The rank required to do any rank changes.
|
||||
final static Rel rankReq = Rel.OFFICER;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
// These fields are set upon perform() and unset afterwards.
|
||||
|
||||
// Target
|
||||
private Faction targetFaction = null;
|
||||
private MPlayer target = null;
|
||||
|
||||
// Roles
|
||||
private Rel senderRank = null;
|
||||
private Rel targetRank = null;
|
||||
private Rel rank = null;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRank()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("rank");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("player", "you");
|
||||
this.addOptionalArg("action", "show");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.RANK.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// This sets target and much other. Returns false if not succeeded.
|
||||
if ( ! this.registerFields())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Sometimes we just want to show the rank.
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
if ( ! Perm.RANK_SHOW.has(sender, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.showRank();
|
||||
return;
|
||||
}
|
||||
|
||||
// Permission check.
|
||||
if ( ! Perm.RANK_ACTION.has(sender, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Is the player allowed or not. Method can be found later down.
|
||||
if ( ! this.isPlayerAllowed())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Does the change make sense.
|
||||
if ( ! this.isChangeRequired())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EventFactionsRankChange event = new EventFactionsRankChange(sender, target, rank);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
rank = event.getNewRank();
|
||||
|
||||
// Change the rank.
|
||||
this.changeRank();
|
||||
}
|
||||
|
||||
// This is always run after performing a MassiveCommand.
|
||||
@Override
|
||||
public void unsetSenderVars()
|
||||
{
|
||||
super.unsetSenderVars();
|
||||
this.unregisterFields();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private boolean registerFields()
|
||||
{
|
||||
// Getting the target and faction.
|
||||
target = this.arg(0, ARMPlayer.getAny(), msender);
|
||||
if (null == target) return false;
|
||||
targetFaction = target.getFaction();
|
||||
|
||||
// Rank if any passed.
|
||||
if (this.argIsSet(1))
|
||||
{
|
||||
rank = this.arg(1, ARRank.get(target.getRole()));
|
||||
if (null == rank) return false;
|
||||
}
|
||||
|
||||
// Ranks
|
||||
senderRank = msender.getRole();
|
||||
targetRank = target.getRole();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void unregisterFields()
|
||||
{
|
||||
targetFaction = null;
|
||||
target = null;
|
||||
|
||||
senderRank = null;
|
||||
targetRank = null;
|
||||
rank = null;
|
||||
}
|
||||
|
||||
private void showRank()
|
||||
{
|
||||
String targetName = target.describeTo(msender, true);
|
||||
String isAre = target == msender ? "are" : "is";
|
||||
String theAan = targetRank == Rel.LEADER ? "the" : Txt.aan(targetRank.name());
|
||||
String rankName = Txt.getNicedEnum(targetRank).toLowerCase();
|
||||
String ofIn = targetRank == Rel.LEADER ? "of" : "in";
|
||||
String factionName = targetFaction.describeTo(msender, true);
|
||||
if (targetFaction == msenderFaction)
|
||||
{
|
||||
factionName = factionName.toLowerCase();
|
||||
}
|
||||
msg("%s <i>%s %s <h>%s <i>%s %s<i>.", targetName, isAre, theAan, rankName, ofIn, factionName);
|
||||
}
|
||||
|
||||
private boolean isPlayerAllowed()
|
||||
{
|
||||
// People with permission don't follow the normal rules.
|
||||
if (msender.isUsingAdminMode())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// If somone gets the leadership of wilderness (Which has happened before).
|
||||
// We can at least try to limit their powers.
|
||||
if (targetFaction.isNone())
|
||||
{
|
||||
msg("%s <b>doesn't use ranks sorry :(", targetFaction.getName() );
|
||||
return false;
|
||||
}
|
||||
|
||||
if (targetFaction != msenderFaction)
|
||||
{
|
||||
// Don't change ranks outside of your faction.
|
||||
msg("%s <b>is not in the same faction as you.", target.describeTo(msender));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target == msender)
|
||||
{
|
||||
// Don't change your own rank.
|
||||
msg("<b>The target player mustn't be yourself.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (senderRank.isLessThan(rankReq))
|
||||
{
|
||||
// You need a specific rank to change ranks.
|
||||
msg("<b>You must be %s or higher to change ranks.", Txt.getNicedEnum(rankReq).toLowerCase());
|
||||
return false;
|
||||
}
|
||||
|
||||
// The following two if statements could be merged.
|
||||
// But isn't for the sake of nicer error messages.
|
||||
if (senderRank == targetRank)
|
||||
{
|
||||
// You can't change someones rank if it is equal to yours.
|
||||
msg("<b>%s can't manage eachother.", Txt.getNicedEnum(rankReq)+"s");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (senderRank.isLessThan(targetRank))
|
||||
{
|
||||
// You can't change someones rank if it is higher than yours.
|
||||
msg("<b>You can't manage people of higher rank.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (senderRank.isAtMost(rank) && senderRank != Rel.LEADER)
|
||||
{
|
||||
// You can't set ranks equal to or higer than your own. Unless you are the leader.
|
||||
msg("<b>You can't set ranks higher than or equal to your own.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If it wasn't cancelled above, player is allowed.
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isChangeRequired()
|
||||
{
|
||||
// Just a nice msg. It would however be caught by an if statement below.
|
||||
if (target.getRole() == Rel.RECRUIT && arg(1).equalsIgnoreCase("demote"))
|
||||
{
|
||||
msg("%s <b>is already recruit.", target.describeTo(msender));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Just a nice msg. It would however be caught by an if statement below.
|
||||
if (target.getRole() == Rel.LEADER && arg(1).equalsIgnoreCase("promote"))
|
||||
{
|
||||
msg("%s <b>is already leader.", target.describeTo(msender));
|
||||
return false;
|
||||
}
|
||||
|
||||
// There must be a change, else it is all waste of time.
|
||||
if (target.getRole() == rank)
|
||||
{
|
||||
msg("%s <b>already has that rank.", target.describeTo(msender));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void changeRank()
|
||||
{
|
||||
// In case of leadership change, we do special things not done in other rank changes.
|
||||
if (rank == Rel.LEADER)
|
||||
{
|
||||
this.changeRankLeader();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.changeRankOther();
|
||||
}
|
||||
}
|
||||
|
||||
private void changeRankLeader()
|
||||
{
|
||||
// If there is a current leader. Demote & inform them.
|
||||
MPlayer targetFactionCurrentLeader = targetFaction.getLeader();
|
||||
if (targetFactionCurrentLeader != null)
|
||||
{
|
||||
// Inform & demote the old leader.
|
||||
targetFactionCurrentLeader.setRole(Rel.OFFICER);
|
||||
if (targetFactionCurrentLeader != msender)
|
||||
{
|
||||
// They kinda know if they fired the command themself.
|
||||
targetFactionCurrentLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", msender.describeTo(targetFactionCurrentLeader, true));
|
||||
}
|
||||
}
|
||||
|
||||
// Inform & promote the new leader.
|
||||
target.setRole(Rel.LEADER);
|
||||
if (target != msender)
|
||||
{
|
||||
// They kinda know if they fired the command themself.
|
||||
target.msg("<i>You have been promoted to the position of faction leader by %s<i>.", msender.describeTo(target, true));
|
||||
}
|
||||
|
||||
// Inform the msg sender
|
||||
msg("<i>You have promoted %s<i> to the position of faction leader.", target.describeTo(msender, true));
|
||||
|
||||
// Inform everyone
|
||||
for (MPlayer recipient : MPlayerColl.get().getAllOnline())
|
||||
{
|
||||
String changerName = senderIsConsole ? "A server admin" : msender.describeTo(recipient);
|
||||
recipient.msg("%s<i> gave %s<i> the leadership of %s<i>.", changerName, target.describeTo(recipient), targetFaction.describeTo(recipient));
|
||||
}
|
||||
}
|
||||
|
||||
private void changeRankOther()
|
||||
{
|
||||
// If the target is currently the leader and faction isn't permanent...
|
||||
if (targetRank == Rel.LEADER && !MConf.get().permanentFactionsDisableLeaderPromotion && targetFaction.getFlag(MFlag.ID_PERMANENT))
|
||||
{
|
||||
// ...we must promote a new one.
|
||||
targetFaction.promoteNewLeader();
|
||||
}
|
||||
// But if still no leader exists...
|
||||
if (targetFaction.getLeader() == null && ! targetFaction.getFlag(MFlag.ID_PERMANENT))
|
||||
{
|
||||
// ...we will disband it.
|
||||
// I'm kinda lazy, so I just make the console perform the command.
|
||||
Factions.get().getOuterCmdFactions().cmdFactionsDisband.execute(IdUtil.getConsole(), MUtil.list( targetFaction.getName() ));
|
||||
}
|
||||
|
||||
List<MPlayer> recipients = targetFaction.getMPlayers();
|
||||
if ( ! recipients.contains(msender))
|
||||
{
|
||||
recipients.add(msender);
|
||||
}
|
||||
|
||||
// Were they demoted or promoted?
|
||||
String change = (rank.isLessThan(targetRank) ? "demoted" : "promoted");
|
||||
|
||||
// The rank will be set before the msg, so they have the appropriate prefix.
|
||||
target.setRole(rank);
|
||||
String oldRankName = Txt.getNicedEnum(targetRank).toLowerCase();
|
||||
String rankName = Txt.getNicedEnum(rank).toLowerCase();
|
||||
|
||||
for(MPlayer recipient : recipients)
|
||||
{
|
||||
String targetName = target.describeTo(recipient, true);
|
||||
String wasWere = recipient == target ? "were" : "was";
|
||||
recipient.msg("%s<i> %s %s from %s to <h>%s <i>in %s<i>.", targetName, wasWere, change, oldRankName, rankName, targetFaction.describeTo(msender));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
public class CmdFactionsRankOld extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public final String rankName;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRankOld(String rank)
|
||||
{
|
||||
// Fields
|
||||
this.rankName = rank.toLowerCase();
|
||||
|
||||
// Aliases
|
||||
this.addAliases(rankName);
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("player");
|
||||
|
||||
// VisibilityMode
|
||||
this.setVisibilityMode(VisibilityMode.INVISIBLE);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
Factions.get().getOuterCmdFactions().cmdFactionsRank.execute(sender, MUtil.list(this.arg(0), this.rankName));
|
||||
}
|
||||
|
||||
}
|
@@ -1,107 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.cmd.req.ReqHasFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MFlag;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.event.EventFactionsRelationChange;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public abstract class CmdFactionsRelationAbstract extends FactionsCommand
|
||||
{
|
||||
public Rel targetRelation;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsRelationAbstract()
|
||||
{
|
||||
// Aliases
|
||||
this.addRequiredArg("faction");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction otherFaction = this.arg(0, ARFaction.get());
|
||||
if (otherFaction == null) return;
|
||||
|
||||
Rel newRelation = targetRelation;
|
||||
|
||||
/*if ( ! them.isNormal())
|
||||
{
|
||||
msg("<b>Nope! You can't.");
|
||||
return;
|
||||
}*/
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermRel().has(msender, msenderFaction, true)) return;
|
||||
|
||||
// Verify
|
||||
|
||||
if (otherFaction == msenderFaction)
|
||||
{
|
||||
msg("<b>Nope! You can't declare a relation to yourself :)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (msenderFaction.getRelationWish(otherFaction) == newRelation)
|
||||
{
|
||||
msg("<b>You already have that relation wish set with %s.", otherFaction.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsRelationChange event = new EventFactionsRelationChange(sender, msenderFaction, otherFaction, newRelation);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
newRelation = event.getNewRelation();
|
||||
|
||||
// try to set the new relation
|
||||
msenderFaction.setRelationWish(otherFaction, newRelation);
|
||||
Rel currentRelation = msenderFaction.getRelationTo(otherFaction, true);
|
||||
|
||||
// if the relation change was successful
|
||||
if (newRelation == currentRelation)
|
||||
{
|
||||
otherFaction.msg("%s<i> is now %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getDescFactionOne());
|
||||
msenderFaction.msg("%s<i> is now %s.", otherFaction.describeTo(msenderFaction, true), newRelation.getDescFactionOne());
|
||||
}
|
||||
// inform the other faction of your request
|
||||
else
|
||||
{
|
||||
otherFaction.msg("%s<i> wishes to be %s.", msenderFaction.describeTo(otherFaction, true), newRelation.getColor()+newRelation.getDescFactionOne());
|
||||
otherFaction.msg("<i>Type <c>/"+MConf.get().aliasesF.get(0)+" "+newRelation+" "+msenderFaction.getName()+"<i> to accept.");
|
||||
msenderFaction.msg("%s<i> were informed that you wish to be %s<i>.", otherFaction.describeTo(msenderFaction, 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(MFlag.getFlagPeaceful()))
|
||||
{
|
||||
otherFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||
msenderFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||
}
|
||||
|
||||
if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(MFlag.getFlagPeaceful()))
|
||||
{
|
||||
otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||
msenderFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -1,56 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
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.util.Txt;
|
||||
|
||||
public class CmdFactionsSeeChunk extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSeeChunk()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("sc", "seechunk");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("active", "toggle");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SEECHUNK.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
boolean old = msender.isSeeingChunk();
|
||||
boolean targetDefault = !old;
|
||||
Boolean target = this.arg(0, ARBoolean.get(), targetDefault);
|
||||
if (target == null) return;
|
||||
String targetDesc = Txt.parse(target ? "<g>ON": "<b>OFF");
|
||||
|
||||
// NoChange
|
||||
if (target.equals(old))
|
||||
{
|
||||
msg("<i>See Chunk is already %s<i>.", targetDesc);
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply
|
||||
msender.setSeeingChunk(target);
|
||||
|
||||
// Inform
|
||||
msg("<i>See Chunk is now %s<i>.", targetDesc);
|
||||
}
|
||||
|
||||
}
|
@@ -1,80 +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 CmdFactionsSeeChunkOld extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSeeChunkOld()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("sco", "seechunkold");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SEECHUNKOLD.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
World world = me.getWorld();
|
||||
PS chunk = PS.valueOf(me.getLocation()).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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.Board;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARWorldId;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
|
||||
public class CmdFactionsSetAll extends CmdFactionsSetXAll
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetAll(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("all");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// World
|
||||
String word = (this.isClaim() ? "claim" : "unclaim");
|
||||
|
||||
// Create Ret
|
||||
Set<PS> chunks = null;
|
||||
|
||||
// Args
|
||||
Faction oldFaction = this.getOldFaction();
|
||||
if (oldFaction == null) return null;
|
||||
|
||||
if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase()))
|
||||
{
|
||||
chunks = BoardColl.get().getChunks(oldFaction);
|
||||
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all.");
|
||||
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " all.");
|
||||
}
|
||||
else
|
||||
{
|
||||
String worldId = null;
|
||||
if (MUtil.list("map").contains(this.arg(0).toLowerCase()))
|
||||
{
|
||||
if (me != null)
|
||||
{
|
||||
worldId = me.getWorld().getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("<b>You must specify which map from console.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
worldId = this.arg(0, ARWorldId.get());
|
||||
if (worldId == null) return null;
|
||||
}
|
||||
Board board = BoardColl.get().get(worldId);
|
||||
chunks = board.getChunks(oldFaction);
|
||||
String worldDisplayName = Mixin.getWorldDisplayName(worldId);
|
||||
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " <h>" + worldDisplayName + "<i>.");
|
||||
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " <h>" + worldDisplayName + "<i>.");
|
||||
}
|
||||
|
||||
// Return Ret
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@@ -1,91 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
|
||||
public class CmdFactionsSetAuto extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
private boolean claim = true;
|
||||
public boolean isClaim() { return this.claim; }
|
||||
public void setClaim(boolean claim) { this.claim = claim; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetAuto(boolean claim)
|
||||
{
|
||||
// Fields
|
||||
this.setClaim(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("a", "auto");
|
||||
|
||||
// Args
|
||||
if (claim)
|
||||
{
|
||||
this.addOptionalArg("faction", "you");
|
||||
}
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_AUTO.node : Perm.UNCLAIM_AUTO.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Faction newFaction;
|
||||
if (claim)
|
||||
{
|
||||
newFaction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
newFaction = FactionColl.get().getNone();
|
||||
}
|
||||
|
||||
// Disable?
|
||||
if (newFaction == null || newFaction == msender.getAutoClaimFaction())
|
||||
{
|
||||
msender.setAutoClaimFaction(null);
|
||||
msg("<i>Disabled auto-setting as you walk around.");
|
||||
return;
|
||||
}
|
||||
|
||||
// MPerm Preemptive Check
|
||||
if (newFaction.isNormal() && ! MPerm.getPermTerritory().has(msender, newFaction, true)) return;
|
||||
|
||||
// Apply / Inform
|
||||
msender.setAutoClaimFaction(newFaction);
|
||||
msg("<i>Now auto-setting <h>%s<i> land.", newFaction.describeTo(msender));
|
||||
|
||||
// Chunks
|
||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
Set<PS> chunks = Collections.singleton(chunk);
|
||||
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks);
|
||||
}
|
||||
|
||||
}
|
@@ -1,70 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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 CmdFactionsSetCircle extends CmdFactionsSetXRadius
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetCircle(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("c", "circle");
|
||||
|
||||
// Format
|
||||
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using circle.");
|
||||
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using circle.");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_CIRCLE.node : Perm.UNCLAIM_CIRCLE.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Common Startup
|
||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
final Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
|
||||
chunks.add(chunk); // The center should come first for pretty messages
|
||||
|
||||
Integer radiusZero = this.getRadiusZero();
|
||||
if (radiusZero == null) return null;
|
||||
|
||||
double radiusSquared = radiusZero * radiusZero;
|
||||
|
||||
for (int dx = -radiusZero; dx <= radiusZero; dx++)
|
||||
{
|
||||
for (int dz = -radiusZero; dz <= radiusZero; dz++)
|
||||
{
|
||||
if (dx*dx + dz*dz > radiusSquared) continue;
|
||||
|
||||
int x = chunk.getChunkX() + dx;
|
||||
int z = chunk.getChunkZ() + dz;
|
||||
|
||||
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@@ -1,115 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.entity.BoardColl;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
|
||||
|
||||
public class CmdFactionsSetFill extends CmdFactionsSetXSimple
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetFill(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("f", "fill");
|
||||
|
||||
// Format
|
||||
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using fill.");
|
||||
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using fill.");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_FILL.node : Perm.UNCLAIM_FILL.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Common Startup
|
||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
final Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
|
||||
// What faction (aka color) resides there?
|
||||
// NOTE: Wilderness/None is valid.
|
||||
final Faction color = BoardColl.get().getFactionAt(chunk);
|
||||
|
||||
// We start where we are!
|
||||
chunks.add(chunk);
|
||||
|
||||
// Flood!
|
||||
int max = MConf.get().setFillMax;
|
||||
floodSearch(chunks, color, max);
|
||||
|
||||
// Limit Reached?
|
||||
if (chunks.size() >= max)
|
||||
{
|
||||
msg("<b>Fill limit of <h>%d <b>reached.", max);
|
||||
return null;
|
||||
}
|
||||
|
||||
// OK!
|
||||
return chunks;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FLOOD FILL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static void floodSearch(Set<PS> set, Faction color, int max)
|
||||
{
|
||||
// Clean
|
||||
if (set == null) throw new NullPointerException("set");
|
||||
if (color == null) throw new NullPointerException("color");
|
||||
|
||||
// Expand
|
||||
Set<PS> expansion = new LinkedHashSet<PS>();
|
||||
for (PS chunk : set)
|
||||
{
|
||||
Set<PS> neighbours = MUtil.set(
|
||||
chunk.withChunkX(chunk.getChunkX() + 1),
|
||||
chunk.withChunkX(chunk.getChunkX() - 1),
|
||||
chunk.withChunkZ(chunk.getChunkZ() + 1),
|
||||
chunk.withChunkZ(chunk.getChunkZ() - 1)
|
||||
);
|
||||
|
||||
for (PS neighbour : neighbours)
|
||||
{
|
||||
if (set.contains(neighbour)) continue;
|
||||
Faction faction = BoardColl.get().getFactionAt(neighbour);
|
||||
if (faction == null) continue;
|
||||
if (faction != color) continue;
|
||||
expansion.add(neighbour);
|
||||
}
|
||||
}
|
||||
set.addAll(expansion);
|
||||
|
||||
// No Expansion?
|
||||
if (expansion.isEmpty()) return;
|
||||
|
||||
// Reached Max?
|
||||
if (set.size() >= max) return;
|
||||
|
||||
// Recurse
|
||||
floodSearch(set, color, max);
|
||||
}
|
||||
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
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 CmdFactionsSetOne extends CmdFactionsSetXSimple
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetOne(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("o", "one");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_ONE.node : Perm.UNCLAIM_ONE.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
final Set<PS> chunks = Collections.singleton(chunk);
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
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 CmdFactionsSetSquare extends CmdFactionsSetXRadius
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetSquare(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Aliases
|
||||
this.addAliases("s", "square");
|
||||
|
||||
// Format
|
||||
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk %s<i> using square.");
|
||||
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks near %s<i> using square.");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
String node = claim ? Perm.CLAIM_SQUARE.node : Perm.UNCLAIM_SQUARE.node;
|
||||
this.addRequirements(ReqHasPerm.get(node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public Set<PS> getChunks()
|
||||
{
|
||||
// Common Startup
|
||||
final PS chunk = PS.valueOf(me.getLocation()).getChunk(true);
|
||||
final Set<PS> chunks = new LinkedHashSet<PS>();
|
||||
|
||||
chunks.add(chunk); // The center should come first for pretty messages
|
||||
|
||||
Integer radiusZero = this.getRadiusZero();
|
||||
if (radiusZero == null) return null;
|
||||
|
||||
for (int dx = -radiusZero; dx <= radiusZero; dx++)
|
||||
{
|
||||
for (int dz = -radiusZero; dz <= radiusZero; dz++)
|
||||
{
|
||||
int x = chunk.getChunkX() + dx;
|
||||
int z = chunk.getChunkZ() + dz;
|
||||
|
||||
chunks.add(chunk.withChunkX(x).withChunkZ(z));
|
||||
}
|
||||
}
|
||||
|
||||
return chunks;
|
||||
}
|
||||
|
||||
}
|
@@ -1,82 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.massivecore.ps.PS;
|
||||
|
||||
|
||||
public abstract class CmdFactionsSetX extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
private String formatOne = null;
|
||||
public String getFormatOne() { return this.formatOne; }
|
||||
public void setFormatOne(String formatOne) { this.formatOne = formatOne; }
|
||||
|
||||
private String formatMany = null;
|
||||
public String getFormatMany() { return this.formatMany; }
|
||||
public void setFormatMany(String formatMany) { this.formatMany = formatMany; }
|
||||
|
||||
private boolean claim = true;
|
||||
public boolean isClaim() { return this.claim; }
|
||||
public void setClaim(boolean claim) { this.claim = claim; }
|
||||
|
||||
private int factionArgIndex = 0;
|
||||
public int getFactionArgIndex() { return this.factionArgIndex; }
|
||||
public void setFactionArgIndex(int factionArgIndex) { this.factionArgIndex = factionArgIndex; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetX(boolean claim)
|
||||
{
|
||||
this.setClaim(claim);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
final Faction newFaction = this.getNewFaction();
|
||||
if (newFaction == null) return;
|
||||
|
||||
final Set<PS> chunks = this.getChunks();
|
||||
if (chunks == null) return;
|
||||
|
||||
// Apply / Inform
|
||||
msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// ABSTRACT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public abstract Set<PS> getChunks();
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Faction getNewFaction()
|
||||
{
|
||||
if (this.isClaim())
|
||||
{
|
||||
return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FactionColl.get().getNone();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,36 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.arg.ARFaction;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
|
||||
public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXAll(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("all|map");
|
||||
this.addRequiredArg("faction");
|
||||
if (claim)
|
||||
{
|
||||
this.addRequiredArg("newfaction");
|
||||
this.setFactionArgIndex(2);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Faction getOldFaction()
|
||||
{
|
||||
return this.arg(1, ARFaction.get());
|
||||
}
|
||||
|
||||
}
|
@@ -1,60 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARInteger;
|
||||
|
||||
|
||||
public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXRadius(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("radius", "1");
|
||||
if (claim)
|
||||
{
|
||||
this.addOptionalArg("faction", "you");
|
||||
this.setFactionArgIndex(1);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public Integer getRadius()
|
||||
{
|
||||
Integer radius = this.arg(0, ARInteger.get(), 1);
|
||||
if (radius == null) return radius;
|
||||
|
||||
// Radius Claim Min
|
||||
if (radius < 1)
|
||||
{
|
||||
msg("<b>If you specify a radius, it must be at least 1.");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Radius Claim Max
|
||||
if (radius > MConf.get().setRadiusMax && ! msender.isUsingAdminMode())
|
||||
{
|
||||
msg("<b>The maximum radius allowed is <h>%s<b>.", MConf.get().setRadiusMax);
|
||||
return null;
|
||||
}
|
||||
|
||||
return radius;
|
||||
}
|
||||
|
||||
public Integer getRadiusZero()
|
||||
{
|
||||
Integer ret = this.getRadius();
|
||||
if (ret == null) return ret;
|
||||
return ret - 1;
|
||||
}
|
||||
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetXSimple(boolean claim)
|
||||
{
|
||||
// Super
|
||||
super(claim);
|
||||
|
||||
// Args
|
||||
if (claim)
|
||||
{
|
||||
this.addOptionalArg("faction", "you");
|
||||
this.setFactionArgIndex(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,73 +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.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
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 FactionsCommandHome
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSethome()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("sethome");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node));
|
||||
this.addRequirements(ReqIsPlayer.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
PS newHome = PS.valueOf(me.getLocation());
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
|
||||
|
||||
// Verify
|
||||
if (!msender.isUsingAdminMode() && !faction.isValidHome(newHome))
|
||||
{
|
||||
msender.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:", msender.describeTo(msenderFaction, true));
|
||||
faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getUseageTemplate());
|
||||
if (faction != msenderFaction)
|
||||
{
|
||||
msender.msg("<i>You have set the home for " + faction.getName(msender) + "<i>.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,72 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.factions.cmd.arg.ARMPlayer;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsTitle()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("title");
|
||||
|
||||
// Args
|
||||
this.addRequiredArg("player");
|
||||
this.addOptionalArg("title", "");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.TITLE.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
MPlayer you = this.arg(0, ARMPlayer.getAny());
|
||||
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);
|
||||
}
|
||||
|
||||
// MPerm
|
||||
if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
|
||||
|
||||
// Verify
|
||||
if ( ! canIAdministerYou(msender, you)) return;
|
||||
|
||||
// Event
|
||||
EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
newTitle = event.getNewTitle();
|
||||
|
||||
// Apply
|
||||
you.setTitle(newTitle);
|
||||
|
||||
// Inform
|
||||
msenderFaction.msg("%s<i> changed a title: %s", msender.describeTo(msenderFaction, true), you.describeTo(msenderFaction, true));
|
||||
}
|
||||
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Perm;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
|
||||
public class CmdFactionsUnclaim extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsSetOne cmdFactionsUnclaimOne = new CmdFactionsSetOne(false);
|
||||
public CmdFactionsSetAuto cmdFactionsUnclaimAuto = new CmdFactionsSetAuto(false);
|
||||
public CmdFactionsSetFill cmdFactionsUnclaimFill = new CmdFactionsSetFill(false);
|
||||
public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false);
|
||||
public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false);
|
||||
public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false);
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsUnclaim()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("unclaim");
|
||||
|
||||
// Add SubCommands
|
||||
this.addSubCommand(this.cmdFactionsUnclaimOne);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimAuto);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimFill);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimSquare);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimCircle);
|
||||
this.addSubCommand(this.cmdFactionsUnclaimAll);
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
|
||||
}
|
||||
|
||||
}
|
@@ -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.entity.Faction;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||
|
||||
public class CmdFactionsUnsethome extends FactionsCommandHome
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsUnsethome()
|
||||
{
|
||||
// Aliases
|
||||
this.addAliases("unsethome");
|
||||
|
||||
// Args
|
||||
this.addOptionalArg("faction", "you");
|
||||
|
||||
// Requirements
|
||||
this.addRequirements(ReqHasPerm.get(Perm.UNSETHOME.node));
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
// Args
|
||||
Faction faction = this.arg(0, ARFaction.get(), msenderFaction);
|
||||
if (faction == null) return;
|
||||
|
||||
// Any and MPerm
|
||||
if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
|
||||
|
||||
// NoChange
|
||||
if ( ! faction.hasHome())
|
||||
{
|
||||
msender.msg("<i>%s <i>does already not have a home.", faction.describeTo(msender));
|
||||
return;
|
||||
}
|
||||
|
||||
// Event
|
||||
EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, null);
|
||||
event.run();
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
// Apply
|
||||
faction.setHome(null);
|
||||
|
||||
// Inform
|
||||
faction.msg("%s<i> unset the home for your faction.", msender.describeTo(msenderFaction, true));
|
||||
if (faction != msenderFaction)
|
||||
{
|
||||
msender.msg("<i>You have unset the home for " + faction.getName(msender) + "<i>.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
|
||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
|
||||
|
||||
|
||||
public class CmdFactionsXDeprecated extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public MassiveCommand target;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsXDeprecated(MassiveCommand target, String... aliases)
|
||||
{
|
||||
// Fields
|
||||
this.target = target;
|
||||
|
||||
// Aliases
|
||||
this.addAliases(aliases);
|
||||
|
||||
// Args
|
||||
this.setErrorOnToManyArgs(false);
|
||||
|
||||
// Visibility
|
||||
this.setVisibilityMode(VisibilityMode.INVISIBLE);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
msg("<i>Use this new command instead:");
|
||||
sendMessage(target.getUseageTemplate(true));
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsXPlaceholder extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public String extensionName;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsXPlaceholder(String extensionName, String... aliases)
|
||||
{
|
||||
// Fields
|
||||
this.extensionName = extensionName;
|
||||
|
||||
// Aliases
|
||||
this.addAliases(aliases);
|
||||
|
||||
// Desc
|
||||
this.setDesc("Use " + extensionName);
|
||||
|
||||
// Args
|
||||
this.setErrorOnToManyArgs(false);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
msg("<b>The extension <h>%s <b>isn't installed.", this.extensionName);
|
||||
msg("<g>Learn more and download the extension here:");
|
||||
msg("<aqua>http://www.massivecraft.com/%s", this.extensionName.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
@@ -1,77 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class FactionsCommand extends MassiveCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public MPlayer msender;
|
||||
public Faction msenderFaction;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void fixSenderVars()
|
||||
{
|
||||
this.msender = MPlayer.get(sender);
|
||||
this.msenderFaction = this.msender.getFaction();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unsetSenderVars()
|
||||
{
|
||||
this.msender = null;
|
||||
this.msenderFaction = null;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// COMMONLY USED LOGIC
|
||||
// -------------------------------------------- //
|
||||
|
||||
public boolean canIAdministerYou(MPlayer i, MPlayer 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>Officers can't control each other..."));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i.sendMessage(Txt.parse("<b>You must be a faction officer to do that."));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@@ -1,28 +0,0 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.VisibilityMode;
|
||||
|
||||
public class FactionsCommandHome extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public FactionsCommandHome()
|
||||
{
|
||||
this.addRequirements(ReqFactionHomesEnabled.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public VisibilityMode getVisibilityMode()
|
||||
{
|
||||
return MConf.get().homesEnabled ? super.getVisibilityMode() : VisibilityMode.INVISIBLE;
|
||||
}
|
||||
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.arg;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.factions.entity.FactionColl;
|
||||
import com.massivecraft.massivecore.MassiveCore;
|
||||
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
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARFaction i = new ARFaction();
|
||||
public static ARFaction get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public ArgResult<Faction> read(String str, CommandSender sender)
|
||||
{
|
||||
ArgResult<Faction> result = new ArgResult<Faction>();
|
||||
|
||||
// Nothing/Remove targets Wilderness
|
||||
if (MassiveCore.NOTHING_REMOVE.contains(str))
|
||||
{
|
||||
result.setResult(FactionColl.get().getNone());
|
||||
return result;
|
||||
}
|
||||
|
||||
// Faction Id Exact
|
||||
if (FactionColl.get().containsId(str))
|
||||
{
|
||||
result.setResult(FactionColl.get().get(str));
|
||||
if (result.hasResult()) return result;
|
||||
}
|
||||
|
||||
// Faction Name Exact
|
||||
result.setResult(FactionColl.get().getByName(str));
|
||||
if (result.hasResult()) return result;
|
||||
|
||||
// MPlayer Name Exact
|
||||
String id = IdUtil.getId(str);
|
||||
MPlayer mplayer = MPlayer.get(id);
|
||||
if (mplayer != null)
|
||||
{
|
||||
result.setResult(mplayer.getFaction());
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setErrors(Txt.parse("<b>No faction or player matching \"<p>%s<b>\".", str));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +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.entity.MFlag;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class ARMFlag extends ARAbstractSelect<MFlag>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMFlag i = new ARMFlag();
|
||||
public static ARMFlag get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
return "faction flag";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MFlag select(String arg, CommandSender sender)
|
||||
{
|
||||
if (arg == null) return null;
|
||||
arg = getComparable(arg);
|
||||
|
||||
// Algorithmic General Detection
|
||||
int startswithCount = 0;
|
||||
MFlag startswith = null;
|
||||
for (MFlag mflag : MFlag.getAll())
|
||||
{
|
||||
String comparable = getComparable(mflag);
|
||||
if (comparable.equals(arg)) return mflag;
|
||||
if (comparable.startsWith(arg))
|
||||
{
|
||||
startswith = mflag;
|
||||
startswithCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (startswithCount == 1)
|
||||
{
|
||||
return startswith;
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> altNames(CommandSender sender)
|
||||
{
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
||||
for (MFlag mflag : MFlag.getAll())
|
||||
{
|
||||
ret.add(Txt.upperCaseFirst(mflag.getName()));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String getComparable(String string)
|
||||
{
|
||||
return string.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getComparable(MFlag mflag)
|
||||
{
|
||||
return getComparable(mflag.getName());
|
||||
}
|
||||
|
||||
}
|
@@ -1,88 +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.entity.MPerm;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class ARMPerm extends ARAbstractSelect<MPerm>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ARMPerm i = new ARMPerm();
|
||||
public static ARMPerm get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
return "faction permission";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MPerm select(String arg, CommandSender sender)
|
||||
{
|
||||
if (arg == null) return null;
|
||||
arg = getComparable(arg);
|
||||
|
||||
// Algorithmic General Detection
|
||||
int startswithCount = 0;
|
||||
MPerm startswith = null;
|
||||
for (MPerm mperm : MPerm.getAll())
|
||||
{
|
||||
String comparable = getComparable(mperm);
|
||||
if (comparable.equals(arg)) return mperm;
|
||||
if (comparable.startsWith(arg))
|
||||
{
|
||||
startswith = mperm;
|
||||
startswithCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (startswithCount == 1)
|
||||
{
|
||||
return startswith;
|
||||
}
|
||||
|
||||
// Nothing found
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> altNames(CommandSender sender)
|
||||
{
|
||||
List<String> ret = new ArrayList<String>();
|
||||
|
||||
for (MPerm mperm : MPerm.getAll())
|
||||
{
|
||||
ret.add(Txt.upperCaseFirst(mperm.getName()));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// UTIL
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static String getComparable(String string)
|
||||
{
|
||||
return string.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getComparable(MPerm mperm)
|
||||
{
|
||||
return getComparable(mperm.getName());
|
||||
}
|
||||
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.arg;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.MPlayerColl;
|
||||
import com.massivecraft.massivecore.cmd.arg.ArgReader;
|
||||
|
||||
public class ARMPlayer
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public static ArgReader<MPlayer> getAny()
|
||||
{
|
||||
return MPlayerColl.get().getAREntity();
|
||||
}
|
||||
|
||||
public static ArgReader<MPlayer> getOnline()
|
||||
{
|
||||
return MPlayerColl.get().getAREntity(true);
|
||||
}
|
||||
|
||||
}
|
@@ -1,144 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.arg;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect;
|
||||
import com.massivecraft.massivecore.mixin.Mixin;
|
||||
import com.massivecraft.massivecore.util.MUtil;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class ARRank extends ARAbstractSelect<Rel>
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
// Default constructor. Can't use promote and demote.
|
||||
private static ARRank i = new ARRank();
|
||||
public static ARRank get() { return i; }
|
||||
|
||||
public ARRank()
|
||||
{
|
||||
this.startRank = null;
|
||||
}
|
||||
|
||||
// Fancy constructor. Can use promote and demote.
|
||||
public static ARRank get(Rel rank) { return new ARRank(rank); }
|
||||
|
||||
public ARRank(Rel rank)
|
||||
{
|
||||
this.startRank = rank;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
private final Rel startRank;
|
||||
public Rel getStartRank() { return this.startRank; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public String typename()
|
||||
{
|
||||
return "rank";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rel select(String arg, CommandSender sender)
|
||||
{
|
||||
// This is especially useful when one rank can have aliases.
|
||||
// In the case of promote/demote,
|
||||
// that would require 10 lines of code repeated for each alias.
|
||||
arg = this.prepareArg(arg);
|
||||
|
||||
// All the normal ranks
|
||||
if (arg.equals("leader")) return Rel.LEADER;
|
||||
if (arg.equals("officer")) return Rel.OFFICER;
|
||||
if (arg.equals("member")) return Rel.MEMBER;
|
||||
if (arg.equals("recruit")) return Rel.RECRUIT;
|
||||
|
||||
// No start rank?
|
||||
if (startRank == null)
|
||||
{
|
||||
// This might happen of the default constructor is used
|
||||
Mixin.msgOne(sender, Txt.parse("<b>You can't use promote & demote"));
|
||||
return null;
|
||||
}
|
||||
|
||||
// Promote
|
||||
if (arg.equals("promote"))
|
||||
{
|
||||
if (Rel.LEADER.equals(startRank)) return Rel.LEADER;
|
||||
if (Rel.OFFICER.equals(startRank)) return Rel.LEADER;
|
||||
if (Rel.MEMBER.equals(startRank)) return Rel.OFFICER;
|
||||
if (Rel.RECRUIT.equals(startRank)) return Rel.MEMBER;
|
||||
}
|
||||
|
||||
// Demote
|
||||
if (arg.equals("demote"))
|
||||
{
|
||||
if (Rel.LEADER.equals(startRank)) return Rel.OFFICER;
|
||||
if (Rel.OFFICER.equals(startRank)) return Rel.MEMBER;
|
||||
if (Rel.MEMBER.equals(startRank)) return Rel.RECRUIT;
|
||||
if (Rel.RECRUIT.equals(startRank)) return Rel.RECRUIT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> altNames(CommandSender sender)
|
||||
{
|
||||
return MUtil.list(
|
||||
Txt.getNicedEnum(Rel.LEADER),
|
||||
Txt.getNicedEnum(Rel.OFFICER),
|
||||
Txt.getNicedEnum(Rel.MEMBER),
|
||||
Txt.getNicedEnum(Rel.RECRUIT),
|
||||
"Promote",
|
||||
"Demote"
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// PRIVATE
|
||||
// -------------------------------------------- //
|
||||
|
||||
private String prepareArg(String str)
|
||||
{
|
||||
String ret = str.toLowerCase();
|
||||
|
||||
if (ret.startsWith("admin") || ret.startsWith("lea"))
|
||||
{
|
||||
ret = "leader";
|
||||
}
|
||||
else if (ret.startsWith("mod") || ret.startsWith("off"))
|
||||
{
|
||||
ret = "officer";
|
||||
}
|
||||
else if (ret.startsWith("mem"))
|
||||
{
|
||||
ret = "member";
|
||||
}
|
||||
else if (ret.startsWith("rec"))
|
||||
{
|
||||
ret = "recruit";
|
||||
}
|
||||
else if (ret.startsWith("+") || ret.startsWith("plus") || ret.startsWith("up"))
|
||||
{
|
||||
ret = "promote";
|
||||
}
|
||||
else if (ret.startsWith("-") || ret.startsWith("minus") || ret.startsWith("down"))
|
||||
{
|
||||
ret = "demote";
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.req;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
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 MConf.get().bankEnabled && Econ.isEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createErrorMessage(CommandSender sender, MassiveCommand command)
|
||||
{
|
||||
if ( ! MConf.get().bankEnabled)
|
||||
{
|
||||
return Txt.parse("<b>Faction banks are disabled.");
|
||||
}
|
||||
return Txt.parse("<b>Faction economy features are disabled.");
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.req;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.cmd.MassiveCommand;
|
||||
import com.massivecraft.massivecore.cmd.req.ReqAbstract;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
public class ReqFactionHomesEnabled extends ReqAbstract
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// INSTANCE & CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
private static ReqFactionHomesEnabled i = new ReqFactionHomesEnabled();
|
||||
public static ReqFactionHomesEnabled get() { return i; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public boolean apply(CommandSender sender, MassiveCommand command)
|
||||
{
|
||||
return MConf.get().homesEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createErrorMessage(CommandSender sender, MassiveCommand command)
|
||||
{
|
||||
return Txt.parse("<b>Homes must be enabled on the server to "+(command == null ? "do that" : command.getDesc())+".");
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.req;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 MPlayer.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())+".");
|
||||
}
|
||||
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
package com.massivecraft.factions.cmd.req;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
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 !MPlayer.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())+".");
|
||||
}
|
||||
|
||||
}
|
@@ -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.MPlayer;
|
||||
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)
|
||||
{
|
||||
MPlayer mplayer = MPlayer.get(sender);
|
||||
return mplayer.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));
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user