diff --git a/pom.xml b/pom.xml
index 4b845695..f55f0eae 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.William278
HuskHomes
- 2.5.1-dev
+ 2.5.1
jar
HuskHomes
diff --git a/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java b/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java
index c510b401..2ee3f5fd 100644
--- a/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java
+++ b/src/main/java/me/william278/huskhomes2/commands/HuskHomesCommand.java
@@ -4,6 +4,7 @@ import de.themoep.minedown.MineDown;
import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.MessageManager;
import me.william278.huskhomes2.migrators.EssentialsMigrator;
+import me.william278.huskhomes2.util.ChatList;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -12,6 +13,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -28,6 +30,32 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
.append("[• Report Issues:](white) [[Link]](#00fb9a show_text=&7Click to open link open_url=https://github.com/WiIIiam278/HuskHomes2/issues)\n")
.append("[• Support Discord:](white) [[Link]](#00fb9a show_text=&7Click to join open_url=https://discord.gg/tVYhJfyDWG)");
+ // Show users a list of available commands
+ public static void showHelpMenu(Player player, int pageNumber) {
+ ArrayList commandDisplay = new ArrayList<>();
+ for (String command : plugin.getDescription().getCommands().keySet()) {
+ if (HuskHomes.getSettings().hideCommandsFromHelpMenuWithoutPermission()) {
+ if (!player.hasPermission((String) plugin.getDescription().getCommands().get(command).get("permission"))) {
+ continue;
+ }
+ }
+ if (command.equals("huskhomes") && HuskHomes.getSettings().hideHuskHomesCommandFromHelpMenu()) {
+ continue;
+ }
+ String description = (String) plugin.getDescription().getCommands().get(command).get("description");
+ String commandUsage = (String) plugin.getDescription().getCommands().get(command).get("usage");
+ commandDisplay.add("[/" + command + "](#00fb9a show_text=fb9a&" + commandUsage + " suggest_command=/" + command + ") [•](white) [" + description + "](gray)");
+ }
+
+ MessageManager.sendMessage(player, "command_list_header");
+ ChatList helpList = new ChatList(commandDisplay, 10, "/huskhomes help", "\n");
+ if (helpList.doesNotContainPage(pageNumber)) {
+ MessageManager.sendMessage(player, "error_invalid_page_number");
+ return;
+ }
+ player.spigot().sendMessage(helpList.getPage(pageNumber));
+ }
+
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
@@ -43,6 +71,17 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
}
switch (args[0]) {
+ case "about":
+ case "info":
+ if (sender instanceof Player) {
+ Player p = (Player) sender;
+ if (!p.hasPermission("huskhomes.about")) {
+ MessageManager.sendMessage(p, "error_no_permission");
+ return true;
+ }
+ }
+ sender.spigot().sendMessage(new MineDown(PLUGIN_INFORMATION.toString()).toComponent());
+ return true;
case "update":
if (sender instanceof Player) {
Player p = (Player) sender;
@@ -97,15 +136,27 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
sender.sendMessage(ChatColor.RED + "Invalid syntax! Usage: /huskhomes migrate essentialsX");
}
return true;
- default:
+ case "help":
if (sender instanceof Player) {
- Player p = (Player) sender;
- if (!p.hasPermission("huskhomes.about")) {
- MessageManager.sendMessage(p, "error_no_permission");
- return true;
+ Player player = (Player) sender;
+ if (args.length == 2) {
+ try {
+ int pageNo = Integer.parseInt(args[1]);
+ showHelpMenu(player, pageNo);
+ } catch (NumberFormatException ex) {
+ MessageManager.sendMessage(player, "error_invalid_page_number");
+ }
+ } else {
+ showHelpMenu(player, 1);
}
}
- sender.spigot().sendMessage(new MineDown(PLUGIN_INFORMATION.toString()).toComponent());
+ return true;
+ default:
+ if (sender instanceof Player) {
+ showHelpMenu((Player) sender, 1);
+ } else {
+ sender.spigot().sendMessage(new MineDown(PLUGIN_INFORMATION.toString()).toComponent());
+ }
return true;
}
}
@@ -115,19 +166,20 @@ public class HuskHomesCommand extends CommandBase implements TabCompleter {
// Console is fine too
}
+ final static String[] COMMAND_TAB_ARGS = {"help", "about", "update", "reload"};
+
@Override
public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
+ Player p = (Player) sender;
+ if (command.getPermission() != null) {
+ if (!p.hasPermission(command.getPermission())) {
+ return Collections.emptyList();
+ }
+ }
if (args.length == 1) {
final List tabCompletions = new ArrayList<>();
- List tabOptions = new ArrayList<>();
- tabOptions.add("about");
- tabOptions.add("reload");
- tabOptions.add("update");
-
- StringUtil.copyPartialMatches(args[0], tabOptions, tabCompletions);
-
+ StringUtil.copyPartialMatches(args[0], Arrays.asList(COMMAND_TAB_ARGS), tabCompletions);
Collections.sort(tabCompletions);
-
return tabCompletions;
} else {
return Collections.emptyList();
diff --git a/src/main/java/me/william278/huskhomes2/config/Settings.java b/src/main/java/me/william278/huskhomes2/config/Settings.java
index 0be6f5af..2829b116 100644
--- a/src/main/java/me/william278/huskhomes2/config/Settings.java
+++ b/src/main/java/me/william278/huskhomes2/config/Settings.java
@@ -77,6 +77,10 @@ public class Settings {
private int publicHomesPerPage;
private int warpsPerPage;
+ // Help menu options
+ private boolean hideCommandsFromHelpMenuWithoutPermission;
+ private boolean hideHuskHomesCommandFromHelpMenu;
+
// RTP command settings
private boolean doRtpCommand;
private int rtpRange;
@@ -220,6 +224,9 @@ public class Settings {
this.publicHomesPerPage = config.getInt("general.lists.public_homes_per_page");
this.warpsPerPage = config.getInt("general.lists.warps_per_page");
+ this.hideCommandsFromHelpMenuWithoutPermission = config.getBoolean("general.help_menu.hide_commands_without_permission");
+ this.hideHuskHomesCommandFromHelpMenu = config.getBoolean("general.help_menu.hide_huskhomes_command");
+
this.maximumHomes = config.getInt("general.max_sethomes");
this.teleportRequestExpiryTime = config.getInt("general.teleport_request_expiry_time");
this.teleportWarmupTime = config.getInt("general.teleport_warmup_time");
@@ -438,4 +445,12 @@ public class Settings {
public boolean doHideRestrictedWarps() {
return hideRestrictedWarps;
}
+
+ public boolean hideCommandsFromHelpMenuWithoutPermission() {
+ return hideCommandsFromHelpMenuWithoutPermission;
+ }
+
+ public boolean hideHuskHomesCommandFromHelpMenu() {
+ return hideHuskHomesCommandFromHelpMenu;
+ }
}
diff --git a/src/main/resources/Languages/en-gb.yml b/src/main/resources/Languages/en-gb.yml
index 2236f308..bb595e04 100644
--- a/src/main/resources/Languages/en-gb.yml
+++ b/src/main/resources/Languages/en-gb.yml
@@ -120,4 +120,5 @@ page_options: '[←](gray show_text=&7View previous page run_command=%1%) [Viewi
page_options_min: '\n[Viewing Page %1%/%2%](#00fb9a) [→](gray show_text=&7View next page run_command=%3%)'
page_options_min_max: '\n[Viewing Page %1%/%2%](#00fb9a)'
page_options_max: '\n[←](gray show_text=&7View previous page run_command=%1%) [Viewing Page %2%/%3%](#00fb9a)'
-page_no_items: '[(No items to display on this page)](gray show_text=&7Try a different page number)'
\ No newline at end of file
+page_no_items: '[(No items to display on this page)](gray show_text=&7Try a different page number)'
+command_list_header: '\n[HuskHomes](#00fb9a bold) [| Command List](#00fb9a)'
\ No newline at end of file
diff --git a/src/main/resources/Languages/it-it.yml b/src/main/resources/Languages/it-it.yml
index 2f464b0b..78656f94 100644
--- a/src/main/resources/Languages/it-it.yml
+++ b/src/main/resources/Languages/it-it.yml
@@ -120,4 +120,5 @@ page_options: '[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina
page_options_min: '\n[Pagina %1%/%2%](#00fb9a) [→](gray show_text=&7Pagina successiva run_command=%3%)'
page_options_min_max: '\n[Pagina %1%/%2%](#00fb9a)'
page_options_max: '\n[←](gray show_text=&7Pagina precedente run_command=%1%) [Pagina %2%/%3%](#00fb9a)'
-page_no_items: '[(Nessun oggetto visibile in questa pagina)](gray show_text=&7Prova un numero differente)'
\ No newline at end of file
+page_no_items: '[(Nessun oggetto visibile in questa pagina)](gray show_text=&7Prova un numero differente)'
+command_list_header: '\n[HuskHomes](#00fb9a bold) [| Command List](#00fb9a)'
\ No newline at end of file
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index b643c7ef..4f22012f 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -32,6 +32,9 @@ general:
private_homes_per_page: 10
public_homes_per_page: 10
warps_per_page: 10
+ help_menu:
+ hide_commands_without_permission: true
+ hide_huskhomes_command: false
bungee_options:
enable_bungee_mode: false
server_id: 'server'