From b5be4e3aca293c8caec6f0e28f35ca85cc47e2f9 Mon Sep 17 00:00:00 2001 From: Magnus Ulf Date: Fri, 25 Jan 2019 13:30:17 +0100 Subject: [PATCH] Better Factions in-game documentation --- plugin.yml | 6 +++ src/com/massivecraft/factions/Perm.java | 2 + .../cmd/CmdFactionsDocumentation.java | 15 +++++++ .../cmd/CmdFactionsDocumentationFlags.java | 39 ++++++++++++++++ .../cmd/CmdFactionsDocumentationPerms.java | 45 +++++++++++++++++++ .../cmd/CmdFactionsDocumentationPower.java | 18 ++++---- .../cmd/CmdFactionsDocumentationRanks.java | 27 +++++------ .../factions/cmd/CmdFactionsPermView.java | 2 + .../cmd/FactionsCommandDocumentation.java | 11 ++++- 9 files changed, 141 insertions(+), 24 deletions(-) create mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsDocumentationFlags.java create mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPerms.java diff --git a/plugin.yml b/plugin.yml index 1d96ae33..965839cd 100644 --- a/plugin.yml +++ b/plugin.yml @@ -28,7 +28,9 @@ permissions: factions.description: {description: change faction description, default: false} factions.disband: {description: disband faction, 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.perms: {description: show perms 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} @@ -127,6 +129,8 @@ permissions: factions.description: true factions.disband: true factions.documentation: true + factions.documentation.flags: true + factions.documentation.perms: true factions.documentation.power: true factions.documentation.ranks: true factions.expansions: true @@ -257,6 +261,8 @@ permissions: factions.description: true factions.disband: true factions.documentation: true + factions.documentation.flags: true + factions.documentation.perms: true factions.documentation.power: true factions.documentation.ranks: true factions.expansions: true diff --git a/src/com/massivecraft/factions/Perm.java b/src/com/massivecraft/factions/Perm.java index 33a629d7..8441aaee 100644 --- a/src/com/massivecraft/factions/Perm.java +++ b/src/com/massivecraft/factions/Perm.java @@ -27,6 +27,8 @@ public enum Perm implements Identified DESCRIPTION, DISBAND, DOCUMENTATION, + DOCUMENTATION_FLAGS, + DOCUMENTATION_PERMS, DOCUMENTATION_POWER, DOCUMENTATION_RANKS, EXPANSIONS, diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentation.java b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentation.java index afeb0595..6ef70ef1 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentation.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentation.java @@ -1,12 +1,27 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.Factions; +import org.bukkit.ChatColor; + 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 // -------------------------------------------- // public CmdFactionsDocumentationPower cmdFactionsDocumentationPower = new CmdFactionsDocumentationPower(); public CmdFactionsDocumentationRanks cmdFactionsDocumentationRanks = new CmdFactionsDocumentationRanks(); + public CmdFactionsDocumentationFlags cmdFactionsDocumentationFlags = new CmdFactionsDocumentationFlags(); + public CmdFactionsDocumentationPerms cmdFactionsDocumentationPerms = new CmdFactionsDocumentationPerms(); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationFlags.java b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationFlags.java new file mode 100644 index 00000000..e855a6ef --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationFlags.java @@ -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 flags = MFlagColl.get().getAll(MFlag::isEditable).stream().map(flag -> Txt.parse("%s", flag.getName())).collect(Collectors.toList()); + String str = Txt.implodeCommaAndDot(flags, Txt.parse("")); + msgDoc("The flags you can edit for your faction are: %s", str); + } + +} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPerms.java b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPerms.java new file mode 100644 index 00000000..fa316f5a --- /dev/null +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPerms.java @@ -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)); + } + +} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPower.java b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPower.java index dfb61926..ec9a990b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPower.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationPower.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.entity.MConf; import com.massivecraft.massivecore.MassiveException; -public class CmdFactionsDocumentationPower extends FactionsCommand +public class CmdFactionsDocumentationPower extends FactionsCommandDocumentation { // -------------------------------------------- // // CONSTRUCT @@ -21,16 +21,16 @@ public class CmdFactionsDocumentationPower extends FactionsCommand @Override public void perform() throws MassiveException { - msg("1) All players have an amount of power ranging from %.2f to %.2f.", MConf.get().powerMin, MConf.get().powerMax); - msg("2) The power of a faction is equal to the combined power of all it's members."); - msg("3) Your power is %.2f", msender.getPower()); - msg("4) Your faction's power is %.2f", msenderFaction.getPower()); - msg("5) The amount of chunks a faction can claim is the amount power it has."); - msg("6) For every hour you are online you gain %.2f power.", MConf.get().powerPerHour); - msg("7) Every time you die you power is decreased by %.2f .", MConf.get().powerPerDeath*-1); + msgDoc("All players have an amount of power ranging from %.2f to %.2f.", MConf.get().powerMin, MConf.get().powerMax); + msgDoc("The power of a faction is equal to the combined power of all it's members."); + msgDoc("Your power is %.2f", msender.getPower()); + msgDoc("Your faction's power is %.2f", msenderFaction.getPower()); + msgDoc("The amount of chunks a faction can claim is the amount power it has."); + msgDoc("For every hour you are online you gain %.2f power.", MConf.get().powerPerHour); + msgDoc("Every time you die you power is decreased by %.2f .", MConf.get().powerPerDeath*-1); if (!MConf.get().canLeaveWithNegativePower && MConf.get().powerMin < 0) { - msg("8) You can't leave a faction if your power is negative."); + msgDoc("You can't leave a faction if your power is negative."); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationRanks.java b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationRanks.java index e564a735..14ab32d6 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationRanks.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDocumentationRanks.java @@ -4,12 +4,13 @@ import com.massivecraft.factions.entity.Rank; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.mson.Mson; import com.massivecraft.massivecore.util.Txt; +import org.bukkit.ChatColor; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; -public class CmdFactionsDocumentationRanks extends FactionsCommand +public class CmdFactionsDocumentationRanks extends FactionsCommandDocumentation { // -------------------------------------------- // // CONSTRUCT @@ -27,27 +28,27 @@ public class CmdFactionsDocumentationRanks extends FactionsCommand @Override public void perform() throws MassiveException { - int i = 1; - msg("" + i++ + ") Ranks divide the faction into groups."); + msgDoc("Ranks divide the faction into groups."); List ranks = msenderFaction.getRanks().getAll(Comparator.comparingInt(Rank::getPriority).reversed()); List rankDesc = ranks.stream().map(r -> r.getDisplayName(msender)).collect(Collectors.toList()); - msg("" + i++ + ") Your faction has: %s", Txt.implodeCommaAndDot(rankDesc, Txt.parse(""))); + msgDoc("Your faction has: %s", Txt.implodeCommaAndDot(rankDesc, Txt.parse(""))); - msg("" + i++ + ") Ranks can have a prefix that will be prepended before any player name. Prefixes can be coloured."); - msg("" + i++ + ") All ranks have a priority showed in parentheses after the name."); + msgDoc("Ranks can have a prefix that will be prepended before any player name. Prefixes can be coloured."); + msgDoc("All ranks have a priority showed in parentheses after the name."); - Mson msonLeader = Mson.parse("" + 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("" + i++ + ") Whenever a new person joins the faction they will be assigned the rank with the lowest priority."); - msg("" + i++ + ") Priorities are important because they determine who can do what." + + 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") + .tooltip("For yor faction the leader rank is" + rankDesc.get(0)) + .color(ChatColor.YELLOW); + messageDoc(msonLeader); + 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 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("" + i++ + ") To show, set or edit ranks do:"); + msgDoc("To show, set or edit ranks do:"); message(CmdFactions.get().cmdFactionsRank.getTemplate(false, true, sender)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermView.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermView.java index 6b83bf33..10af058a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermView.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermView.java @@ -96,6 +96,8 @@ public class CmdFactionsPermView extends FactionsCommand Mson msons = Mson.implode(MUtil.list(msonFaction, msonRelation), Mson.SPACE); message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons)); } + msg("To view all perms held by %s type:", permable.getDisplayName(sender)); + message(CmdFactions.get().cmdFactionsPerm.cmdFactionsPermViewall.getTemplateWithArgs(sender, MUtil.list(permable.getName(), faction.getName()))); } } diff --git a/src/com/massivecraft/factions/cmd/FactionsCommandDocumentation.java b/src/com/massivecraft/factions/cmd/FactionsCommandDocumentation.java index 4cdfa112..8a0a9c17 100644 --- a/src/com/massivecraft/factions/cmd/FactionsCommandDocumentation.java +++ b/src/com/massivecraft/factions/cmd/FactionsCommandDocumentation.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled; +import com.massivecraft.massivecore.mson.Mson; public class FactionsCommandDocumentation extends FactionsCommand { @@ -35,10 +36,16 @@ public class FactionsCommandDocumentation extends FactionsCommand // MESSAGE // -------------------------------------------- // - public void msgDoc(String msg, String... args) + public void msgDoc(String msg, Object... args) { - msg = "" + this.num++ + ") "; + msg = "" + this.num++ + ") " + msg; msg(msg, args); } + public void messageDoc(Mson message) + { + Mson mson = mson(Mson.parse("" + this.num++ + ") "), message); + message(mson); + } + }