Reimplement (sorta) dynamic command registration
This commit is contained in:
		@@ -26,6 +26,9 @@ public enum Perm implements Identified
 | 
			
		||||
	CREATE,
 | 
			
		||||
	DESCRIPTION,
 | 
			
		||||
	DISBAND,
 | 
			
		||||
	DOCUMENTATION,
 | 
			
		||||
	DOCUMENTATION_POWER,
 | 
			
		||||
	DOCUMENTATION_RANKS,
 | 
			
		||||
	EXPANSIONS,
 | 
			
		||||
	FACTION,
 | 
			
		||||
	FLAG,
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,8 @@ 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);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user