Add warp documentation command
This commit is contained in:
parent
9e81d6d865
commit
1b0f2d29f8
@ -32,6 +32,7 @@ permissions:
|
||||
factions.documentation.power: {description: show power documentation, default: false}
|
||||
factions.documentation.perms: {description: show perms documentation, default: false}
|
||||
factions.documentation.ranks: {description: show rank documentation, default: false}
|
||||
factions.documentation.warps: {description: show warp documentation, default: false}
|
||||
factions.expansions: {description: list expansions, default: false}
|
||||
factions.faction: {description: show faction information, default: false}
|
||||
factions.flag: {description: manage faction flags, default: false}
|
||||
@ -138,6 +139,7 @@ permissions:
|
||||
factions.documentation.perms: true
|
||||
factions.documentation.power: true
|
||||
factions.documentation.ranks: true
|
||||
factions.documentation.warps: true
|
||||
factions.expansions: true
|
||||
factions.faction: true
|
||||
factions.flag: true
|
||||
@ -279,6 +281,7 @@ permissions:
|
||||
factions.documentation.perms: true
|
||||
factions.documentation.power: true
|
||||
factions.documentation.ranks: true
|
||||
factions.documentation.warps: true
|
||||
factions.expansions: true
|
||||
factions.faction: true
|
||||
factions.flag: true
|
||||
|
@ -31,6 +31,7 @@ public enum Perm implements Identified
|
||||
DOCUMENTATION_PERMS,
|
||||
DOCUMENTATION_POWER,
|
||||
DOCUMENTATION_RANKS,
|
||||
DOCUMENTATION_WARPS,
|
||||
EXPANSIONS,
|
||||
FACTION,
|
||||
FLAG,
|
||||
|
@ -21,6 +21,7 @@ public class CmdFactionsDocumentation extends FactionsCommand
|
||||
|
||||
public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower();
|
||||
public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks();
|
||||
public CmdFactionsDocumentationWarps cmdFactionsDocumentationWarps = new CmdFactionsDocumentationWarps();
|
||||
public CmdFactionsDocumentationFlags cmdFactionsDocumentationFlags = new CmdFactionsDocumentationFlags();
|
||||
public CmdFactionsDocumentationPerms cmdFactionsDocumentationPerms = new CmdFactionsDocumentationPerms();
|
||||
|
||||
|
@ -0,0 +1,76 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.req.ReqFactionWarpsEnabled;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.factions.entity.MPerm;
|
||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class CmdFactionsDocumentationWarps extends FactionsCommandDocumentation
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDocumentationWarps()
|
||||
{
|
||||
this.addRequirements(ReqFactionWarpsEnabled.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
msgDoc("A faction can have warps which allows it's members to easily go to important places within the faction.");
|
||||
|
||||
if (MConf.get().warpsMax < 0)
|
||||
{
|
||||
msgDoc("There is no limit to how many warps a faction can have.");
|
||||
}
|
||||
else
|
||||
{
|
||||
msgDoc("There is no limit to how many warps a faction can have.");
|
||||
}
|
||||
|
||||
if (MConf.get().warpsMustBeInClaimedTerritory)
|
||||
{
|
||||
msgDoc("Warps must be within claimed territory.");
|
||||
}
|
||||
|
||||
if (MConf.get().warpsTeleportToOnDeathActive)
|
||||
{
|
||||
msgDoc("If your faction has a warp with the name <h>%s <i>you will teleport there after death.", MConf.get().warpsTeleportToOnDeathName);
|
||||
}
|
||||
|
||||
if (!MConf.get().warpsTeleportAllowedFromEnemyTerritory)
|
||||
{
|
||||
msgDoc("You can't use faction warps while in enemy territory.");
|
||||
}
|
||||
|
||||
if (!MConf.get().warpsTeleportAllowedFromDifferentWorld)
|
||||
{
|
||||
msgDoc("You can't teleporty to a warp from another world.");
|
||||
}
|
||||
|
||||
if (MConf.get().warpsTeleportAllowedEnemyDistance > 0)
|
||||
{
|
||||
String str = String.format("You can't teleport home if there is an enemy within <h>%.1f <i>blocks of you", MConf.get().warpsTeleportAllowedEnemyDistance);
|
||||
if (MConf.get().warpsTeleportIgnoreEnemiesIfInOwnTerritory) str += " unless you are in your own territory.";
|
||||
else str += ".";
|
||||
msgDoc(str);
|
||||
}
|
||||
|
||||
if (msenderFaction.isNormal())
|
||||
{
|
||||
Set<MPermable> set = msenderFaction.getPermittedPermables(MPerm.getPermWarp());
|
||||
String permables = CmdFactionsPermShow.permablesToDisplayString(set, msender);
|
||||
msgDoc("In your faction warps can be used by: %s<i>.", permables);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -14,6 +14,7 @@ import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.collections.MassiveList;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
@ -83,4 +84,21 @@ public class CmdFactionsPermShow extends FactionsCommand
|
||||
throw new RuntimeException(id);
|
||||
}
|
||||
|
||||
public static String permablesToDisplayString(Collection<MPermable> permables, Object watcherObject)
|
||||
{
|
||||
MPlayer mplayer = MPlayer.get(watcherObject);
|
||||
Faction faction = mplayer.getFaction();
|
||||
|
||||
String removeString;
|
||||
if (faction.isNone()) removeString = "";
|
||||
else removeString = Txt.parse(" of ") + faction.getDisplayName(mplayer);
|
||||
|
||||
List<String> permableList = permables.stream()
|
||||
.map(permable -> permable.getDisplayName(mplayer))
|
||||
.map(s -> s.replace(removeString, ""))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return Txt.implodeCommaAnd(permableList, Txt.parse("<i>"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import com.massivecraft.factions.FactionsIndex;
|
||||
import com.massivecraft.factions.FactionsParticipator;
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.RelationParticipator;
|
||||
import com.massivecraft.factions.cmd.CmdFactionsPermShow;
|
||||
import com.massivecraft.factions.entity.MPerm.MPermable;
|
||||
import com.massivecraft.factions.predicate.PredicateCommandSenderFaction;
|
||||
import com.massivecraft.factions.predicate.PredicateMPlayerRank;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
@ -820,6 +822,18 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
|
||||
return getPermitted(mperm.getId());
|
||||
}
|
||||
|
||||
public Set<MPermable> getPermittedPermables(String permId)
|
||||
{
|
||||
return getPermitted(permId).stream()
|
||||
.map(CmdFactionsPermShow::idToMPermable)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public Set<MPermable> getPermittedPermables(MPerm mperm)
|
||||
{
|
||||
return getPermittedPermables(mperm.getId());
|
||||
}
|
||||
|
||||
public boolean isPermitted(String permableId, String permId)
|
||||
{
|
||||
if (permableId == null) throw new NullPointerException("permableId");
|
||||
|
Loading…
Reference in New Issue
Block a user