Reimplement (sorta) dynamic command registration
This commit is contained in:
parent
9a4a68e30c
commit
d24ed94cf8
13
plugin.yml
13
plugin.yml
@ -7,10 +7,6 @@ authors: [Madus, Cayorion, Ulumulu1510, MarkehMe, Brettflan]
|
||||
depend: [MassiveCore]
|
||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, LocalAreaChat, LWC, ChatManager, AuthMe, Vault, WorldEdit, WorldGuard]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
f:
|
||||
description: Factions basecommand
|
||||
permission: factions.basecommand
|
||||
permissions:
|
||||
# -------------------------------------------- #
|
||||
# THE REAL NODES
|
||||
@ -31,6 +27,9 @@ permissions:
|
||||
factions.create: {description: create new faction, default: false}
|
||||
factions.description: {description: change faction description, default: false}
|
||||
factions.disband: {description: disband faction, default: false}
|
||||
factions.documentation: {description: show documentation, default: false}
|
||||
factions.documentation.power: {description: show power documentation, default: false}
|
||||
factions.documentation.ranks: {description: show rank 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}
|
||||
@ -127,6 +126,9 @@ permissions:
|
||||
factions.demote: true
|
||||
factions.description: true
|
||||
factions.disband: true
|
||||
factions.documentation: true
|
||||
factions.documentation.power: true
|
||||
factions.documentation.ranks: true
|
||||
factions.expansions: true
|
||||
factions.faction: true
|
||||
factions.flag: true
|
||||
@ -254,6 +256,9 @@ permissions:
|
||||
factions.demote: true
|
||||
factions.description: true
|
||||
factions.disband: true
|
||||
factions.documentation: true
|
||||
factions.documentation.power: true
|
||||
factions.documentation.ranks: true
|
||||
factions.expansions: true
|
||||
factions.faction: true
|
||||
factions.flag: true
|
||||
|
@ -26,6 +26,9 @@ public enum Perm implements Identified
|
||||
CREATE,
|
||||
DESCRIPTION,
|
||||
DISBAND,
|
||||
DOCUMENTATION,
|
||||
DOCUMENTATION_POWER,
|
||||
DOCUMENTATION_RANKS,
|
||||
EXPANSIONS,
|
||||
FACTION,
|
||||
FLAG,
|
||||
|
@ -22,6 +22,7 @@ public class CmdFactions extends FactionsCommand
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDocumentation cmdFactionsDocumentation = new CmdFactionsDocumentation();
|
||||
public CmdFactionsList cmdFactionsList = new CmdFactionsList();
|
||||
public CmdFactionsFaction cmdFactionsFaction = new CmdFactionsFaction();
|
||||
public CmdFactionsPlayer cmdFactionsPlayer = new CmdFactionsPlayer();
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
public class CmdFactionsDocumentation extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower();
|
||||
public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks();
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
|
||||
public class CmdFactionsDocumentationPower extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDocumentationPower()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
msg("<lime>1) <i>All players have an amount of power ranging from <h>%.2f <i>to <h>%.2f<i>.", MConf.get().powerMin, MConf.get().powerMax);
|
||||
msg("<lime>2) <i>The power of a faction is equal to the combined power of all it's members.");
|
||||
msg("<lime>3) <i>Your power is <h>%.2f<i>", msender.getPower());
|
||||
msg("<lime>4) <i>Your faction's power is <h>%.2f<i>", msenderFaction.getPower());
|
||||
msg("<lime>5) <i>The amount of chunks a faction can claim is the amount power it has.");
|
||||
msg("<lime>6) <i>For every hour you are online you gain <h>%.2f <i>power.", MConf.get().powerPerHour);
|
||||
msg("<lime>7) <i>Every time you die you power is decreased by <h>%.2f <i>.", MConf.get().powerPerDeath*-1);
|
||||
if (!MConf.get().canLeaveWithNegativePower && MConf.get().powerMin < 0)
|
||||
{
|
||||
msg("8) <i>You can't leave a faction if your power is negative.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.entity.Rank;
|
||||
import com.massivecraft.massivecore.MassiveException;
|
||||
import com.massivecraft.massivecore.mson.Mson;
|
||||
import com.massivecraft.massivecore.util.Txt;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CmdFactionsDocumentationRanks extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public CmdFactionsDocumentationRanks()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void perform() throws MassiveException
|
||||
{
|
||||
int i = 1;
|
||||
msg("<lime>" + i++ + ") <i>Ranks divide the faction into groups.");
|
||||
|
||||
List<Rank> ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
|
||||
List<String> rankDesc = ranks.stream().map(r -> r.getDisplayName(msender)).collect(Collectors.toList());
|
||||
msg("<lime>" + i++ + ") <i>Your faction has: <reset>%s", Txt.implodeCommaAndDot(rankDesc, Txt.parse("<i>")));
|
||||
|
||||
msg("<lime>" + i++ + ") <i>Ranks can have a prefix that will be prepended before any player name. Prefixes can be coloured.");
|
||||
msg("<lime>" + i++ + ") <i>All ranks have a priority showed in parentheses after the name.");
|
||||
|
||||
Mson msonLeader = Mson.parse("<lime>" + i++ + ") <i>The rank with the highest priority is deemed the “leader rank”" +
|
||||
"(can be renamed) and only one person can have that rank");
|
||||
msonLeader = msonLeader.tooltip("For yor faction the leader rank is" + rankDesc.get(0));
|
||||
message(msonLeader);
|
||||
msg("<lime>" + i++ + ") <i>Whenever a new person joins the faction they will be assigned the rank with the lowest priority.");
|
||||
msg("<lime>" + i++ + ") <i>Priorities are important because they determine who can do what." +
|
||||
"For example: you can’t kick someone with the same or higher rank than yourself." +
|
||||
"So if you have both Officers, and Co-leaders, do not fear officers kicking co-leaders or the co-leaders kicking each other." +
|
||||
"They can’t. The same goes for changing ranks, titles and other similar things.");
|
||||
|
||||
msg("<lime>" + i++ + ") <i>To show, set or edit ranks do:");
|
||||
message(CmdFactions.get().cmdFactionsRank.getTemplate(false, true, sender));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
|
||||
|
||||
public class FactionsCommandDocumentation extends FactionsCommand
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// CONSTRUCT
|
||||
// -------------------------------------------- //
|
||||
|
||||
public FactionsCommandDocumentation()
|
||||
{
|
||||
this.addRequirements(ReqFactionHomesEnabled.get());
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public int num = 1;
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OVERRIDE
|
||||
// -------------------------------------------- //
|
||||
|
||||
@Override
|
||||
public void senderFields(boolean set)
|
||||
{
|
||||
super.senderFields(set);
|
||||
|
||||
num = 1;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// MESSAGE
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void msgDoc(String msg, String... args)
|
||||
{
|
||||
msg = "<lime>" + this.num++ + ") <i>";
|
||||
msg(msg, args);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user