Better Factions in-game documentation

This commit is contained in:
Magnus Ulf 2019-01-25 13:30:17 +01:00
parent 5118e18a0b
commit b5be4e3aca
9 changed files with 141 additions and 24 deletions

View File

@ -28,7 +28,9 @@ permissions:
factions.description: {description: change faction description, default: false} factions.description: {description: change faction description, default: false}
factions.disband: {description: disband faction, default: false} factions.disband: {description: disband faction, default: false}
factions.documentation: {description: show documentation, default: false} factions.documentation: {description: show documentation, default: false}
factions.documentation.flags: {description: show flag documentation, default: false}
factions.documentation.power: {description: show power documentation, default: false} 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.ranks: {description: show rank documentation, default: false}
factions.expansions: {description: list expansions, default: false} factions.expansions: {description: list expansions, default: false}
factions.faction: {description: show faction information, default: false} factions.faction: {description: show faction information, default: false}
@ -127,6 +129,8 @@ permissions:
factions.description: true factions.description: true
factions.disband: true factions.disband: true
factions.documentation: true factions.documentation: true
factions.documentation.flags: true
factions.documentation.perms: true
factions.documentation.power: true factions.documentation.power: true
factions.documentation.ranks: true factions.documentation.ranks: true
factions.expansions: true factions.expansions: true
@ -257,6 +261,8 @@ permissions:
factions.description: true factions.description: true
factions.disband: true factions.disband: true
factions.documentation: true factions.documentation: true
factions.documentation.flags: true
factions.documentation.perms: true
factions.documentation.power: true factions.documentation.power: true
factions.documentation.ranks: true factions.documentation.ranks: true
factions.expansions: true factions.expansions: true

View File

@ -27,6 +27,8 @@ public enum Perm implements Identified
DESCRIPTION, DESCRIPTION,
DISBAND, DISBAND,
DOCUMENTATION, DOCUMENTATION,
DOCUMENTATION_FLAGS,
DOCUMENTATION_PERMS,
DOCUMENTATION_POWER, DOCUMENTATION_POWER,
DOCUMENTATION_RANKS, DOCUMENTATION_RANKS,
EXPANSIONS, EXPANSIONS,

View File

@ -1,12 +1,27 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Factions;
import org.bukkit.ChatColor;
public class CmdFactionsDocumentation extends FactionsCommand public class CmdFactionsDocumentation extends FactionsCommand
{ {
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDocumentation()
{
String web = Factions.get().getDescription().getWebsite();
this.setHelp(mson("More help can be found at ", mson(web).link(web).color(ChatColor.AQUA)));
}
// -------------------------------------------- // // -------------------------------------------- //
// FIELDS // FIELDS
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower(); public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower();
public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks(); public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks();
public CmdFactionsDocumentationFlags cmdFactionsDocumentationFlags = new CmdFactionsDocumentationFlags();
public CmdFactionsDocumentationPerms cmdFactionsDocumentationPerms = new CmdFactionsDocumentationPerms();
} }

View File

@ -0,0 +1,39 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.entity.MFlag;
import com.massivecraft.factions.entity.MFlagColl;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.util.Txt;
import java.util.List;
import java.util.stream.Collectors;
public class CmdFactionsDocumentationFlags extends FactionsCommandDocumentation
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDocumentationFlags()
{
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
msgDoc("Flags are a way to give certain factions certain attributes " +
" such as disabling pvp or enabling friendly fire.");
msgDoc("To see all the flags type:");
message(CmdFactions.get().cmdFactionsFlag.cmdFactionsFlagList.getTemplate(false, true, sender));
List<String> flags = MFlagColl.get().getAll(MFlag::isEditable).stream().map(flag -> Txt.parse("<h>%s", flag.getName())).collect(Collectors.toList());
String str = Txt.implodeCommaAndDot(flags, Txt.parse("<i>"));
msgDoc("The flags you can edit for your faction are: %s", str);
}
}

View File

@ -0,0 +1,45 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.massivecore.MassiveException;
public class CmdFactionsDocumentationPerms extends FactionsCommandDocumentation
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsDocumentationPerms()
{
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void perform() throws MassiveException
{
msgDoc("Permissions decide who can do what in your faction. " +
"Permissions can be given to a rank, a player, a relation, " +
"everyone in another faction or everyone with a specific rank in another faction.");
msgDoc("Because perms can be given to all of these groups individually, it allows for extreme degrees of fine tuning.");
msgDoc("To list all permissions type:");
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermList.getTemplate(false, true, sender));
msgDoc("To see who has a specific perm type:");
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermShow.getTemplate(false, true, sender));
msgDoc("Per default permissions are only granted to ranks within your faction " +
"and a few perms are given to allies, but if you have changed it that will be displayed by the command above.");
msgDoc("When you create a new rank, you will have to set up their perms from scratch.");
msgDoc("If you want to know what permissions are specifically given to someone do:");
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermView.getTemplate(false, true, sender));
msgDoc("To set perms do: ");
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermSet.getTemplate(false, true, sender));
}
}

View File

@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
public class CmdFactionsDocumentationPower extends FactionsCommand public class CmdFactionsDocumentationPower extends FactionsCommandDocumentation
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
@ -21,16 +21,16 @@ public class CmdFactionsDocumentationPower extends FactionsCommand
@Override @Override
public void perform() throws MassiveException 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); msgDoc("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."); msgDoc("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()); msgDoc("Your power is <h>%.2f<i>", msender.getPower());
msg("<lime>4) <i>Your faction's power is <h>%.2f<i>", msenderFaction.getPower()); msgDoc("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."); msgDoc("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); msgDoc("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); msgDoc("Every time you die you power is decreased by <h>%.2f <i>.", MConf.get().powerPerDeath*-1);
if (!MConf.get().canLeaveWithNegativePower && MConf.get().powerMin < 0) if (!MConf.get().canLeaveWithNegativePower && MConf.get().powerMin < 0)
{ {
msg("8) <i>You can't leave a faction if your power is negative."); msgDoc("You can't leave a faction if your power is negative.");
} }
} }

View File

@ -4,12 +4,13 @@ import com.massivecraft.factions.entity.Rank;
import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.mson.Mson;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import org.bukkit.ChatColor;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class CmdFactionsDocumentationRanks extends FactionsCommand public class CmdFactionsDocumentationRanks extends FactionsCommandDocumentation
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
@ -27,27 +28,27 @@ public class CmdFactionsDocumentationRanks extends FactionsCommand
@Override @Override
public void perform() throws MassiveException public void perform() throws MassiveException
{ {
int i = 1; msgDoc("Ranks divide the faction into groups.");
msg("<lime>" + i++ + ") <i>Ranks divide the faction into groups.");
List<Rank> ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed()); List<Rank> ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed());
List<String> rankDesc = ranks.stream().map(r -> r.getDisplayName(msender)).collect(Collectors.toList()); 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>"))); msgDoc("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."); msgDoc("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."); msgDoc("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”" + Mson msonLeader = mson("The rank with the highest priority is deemed the “leader rank”" +
"(can be renamed) and only one person can have that 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)); .tooltip("For yor faction the leader rank is" + rankDesc.get(0))
message(msonLeader); .color(ChatColor.YELLOW);
msg("<lime>" + i++ + ") <i>Whenever a new person joins the faction they will be assigned the rank with the lowest priority."); messageDoc(msonLeader);
msg("<lime>" + i++ + ") <i>Priorities are important because they determine who can do what." + msgDoc("Whenever a new person joins the faction they will be assigned the rank with the lowest priority.");
msgDoc("Priorities are important because they determine who can do what." +
"For example: you cant kick someone with the same or higher rank than yourself." + "For example: you cant 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." + "So if you have both Officers, and Co-leaders, do not fear officers kicking co-leaders or the co-leaders kicking each other." +
"They cant. The same goes for changing ranks, titles and other similar things."); "They cant. The same goes for changing ranks, titles and other similar things.");
msg("<lime>" + i++ + ") <i>To show, set or edit ranks do:"); msgDoc("To show, set or edit ranks do:");
message(CmdFactions.get().cmdFactionsRank.getTemplate(false, true, sender)); message(CmdFactions.get().cmdFactionsRank.getTemplate(false, true, sender));
} }

View File

@ -96,6 +96,8 @@ public class CmdFactionsPermView extends FactionsCommand
Mson msons = Mson.implode(MUtil.list(msonFaction, msonRelation), Mson.SPACE); Mson msons = Mson.implode(MUtil.list(msonFaction, msonRelation), Mson.SPACE);
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons)); message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons));
} }
msg("<i>To view all perms held by %s <i>type:", permable.getDisplayName(sender));
message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermViewall.getTemplateWithArgs(sender, MUtil.list(permable.getName(), faction.getName())));
} }
} }

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled; import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
import com.massivecraft.massivecore.mson.Mson;
public class FactionsCommandDocumentation extends FactionsCommand public class FactionsCommandDocumentation extends FactionsCommand
{ {
@ -35,10 +36,16 @@ public class FactionsCommandDocumentation extends FactionsCommand
// MESSAGE // MESSAGE
// -------------------------------------------- // // -------------------------------------------- //
public void msgDoc(String msg, String... args) public void msgDoc(String msg, Object... args)
{ {
msg = "<lime>" + this.num++ + ") <i>"; msg = "<lime>" + this.num++ + ") <i>" + msg;
msg(msg, args); msg(msg, args);
} }
public void messageDoc(Mson message)
{
Mson mson = mson(Mson.parse("<lime>" + this.num++ + ") "), message);
message(mson);
}
} }