mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-05-29 18:47:32 +00:00
Searchable help.
Toggle commands with no permissions.
This commit is contained in:
parent
b7cb11cd95
commit
503b4fee55
3 changed files with 32 additions and 8 deletions
|
@ -190,11 +190,16 @@ public class Settings implements IConf
|
||||||
{
|
{
|
||||||
return config.getInt("spawnmob-limit", 10);
|
return config.getInt("spawnmob-limit", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean showNonEssCommandsInHelp()
|
public boolean showNonEssCommandsInHelp()
|
||||||
{
|
{
|
||||||
return config.getBoolean("non-ess-in-help", true);
|
return config.getBoolean("non-ess-in-help", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hidePermissionlessHelp()
|
||||||
|
{
|
||||||
|
return config.getBoolean("hide-permissionless-help", true);
|
||||||
|
}
|
||||||
|
|
||||||
public int getProtectCreeperMaxHeight()
|
public int getProtectCreeperMaxHeight()
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,17 +30,25 @@ public class Commandhelp extends EssentialsCommand
|
||||||
@Override
|
@Override
|
||||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
int page;
|
int page = 1;
|
||||||
|
String match = args[0].toLowerCase();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
page = args.length > 0 ? Integer.parseInt(args[0]) : 1;
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
page = Integer.parseInt(args[args.length - 1]);
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
match = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
page = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> lines = getHelpLines(user);
|
List<String> lines = getHelpLines(user, match);
|
||||||
int start = (page - 1) * 9;
|
int start = (page - 1) * 9;
|
||||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||||
|
|
||||||
|
@ -58,7 +66,7 @@ public class Commandhelp extends EssentialsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("CallToThreadDumpStack")
|
@SuppressWarnings("CallToThreadDumpStack")
|
||||||
private List<String> getHelpLines(User user) throws Exception
|
private List<String> getHelpLines(User user, String match) throws Exception
|
||||||
{
|
{
|
||||||
List<String> retval = new ArrayList<String>();
|
List<String> retval = new ArrayList<String>();
|
||||||
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
|
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
|
||||||
|
@ -98,6 +106,12 @@ public class Commandhelp extends EssentialsCommand
|
||||||
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
||||||
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
||||||
{
|
{
|
||||||
|
if ((!match.equalsIgnoreCase("")) && (!p.getDescription().getName().toLowerCase().contains(match))
|
||||||
|
&& (!p.getDescription().getDescription().toLowerCase().contains(match)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (p.getDescription().getName().toLowerCase().contains("essentials"))
|
if (p.getDescription().getName().toLowerCase().contains("essentials"))
|
||||||
{
|
{
|
||||||
final String node = "essentials." + k.getKey();
|
final String node = "essentials." + k.getKey();
|
||||||
|
@ -121,7 +135,10 @@ public class Commandhelp extends EssentialsCommand
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
if (!ess.getSettings().hidePermissionlessHelp())
|
||||||
|
{
|
||||||
|
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,6 @@ motd:
|
||||||
- '&cWelcome, {PLAYER}&c!'
|
- '&cWelcome, {PLAYER}&c!'
|
||||||
- '&fType &c/help&f for a list of commands.'
|
- '&fType &c/help&f for a list of commands.'
|
||||||
- 'Currently online: {PLAYERLIST}'
|
- 'Currently online: {PLAYERLIST}'
|
||||||
- 'You have {MAILS} mail messages'
|
|
||||||
|
|
||||||
# The server rules, available by typing /rules
|
# The server rules, available by typing /rules
|
||||||
rules:
|
rules:
|
||||||
|
@ -239,6 +238,9 @@ currency-symbol: '$'
|
||||||
#Show other plugins commands in help
|
#Show other plugins commands in help
|
||||||
non-ess-in-help: true
|
non-ess-in-help: true
|
||||||
|
|
||||||
|
#Hide plugins which dont give a permission
|
||||||
|
hide-permissionless-help: true
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | EssentialsChat | #
|
# | EssentialsChat | #
|
||||||
|
|
Loading…
Reference in a new issue