v0.6.1 - Added GUI menu for plugin. Use /nvus menu
This commit is contained in:
parent
dd7f9ad6e8
commit
6ba21eaf68
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>me.NVus</groupId>
|
<groupId>me.NVus</groupId>
|
||||||
<artifactId>NVus_Prison_Setup</artifactId>
|
<artifactId>NVus_Prison_Setup</artifactId>
|
||||||
<version>0.6.1</version>
|
<version>0.6.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>NVus_PrisonSetup</name>
|
<name>NVus_PrisonSetup</name>
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package me.nvus.nvus_prison_setup.Configs;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class SettingsMenu implements Listener {
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
private final ConfigManager configManager;
|
||||||
|
|
||||||
|
public SettingsMenu(JavaPlugin plugin, ConfigManager configManager) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.configManager = configManager;
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openSettingsMenu(Player player) {
|
||||||
|
Inventory inv = Bukkit.createInventory(null, 9, ChatColor.DARK_GREEN + "NVus Prison Settings");
|
||||||
|
|
||||||
|
// Toggle AutoPickup
|
||||||
|
ItemStack toggleAutoPickup = new ItemStack(Material.HOPPER);
|
||||||
|
ItemMeta metaAutoPickup = toggleAutoPickup.getItemMeta();
|
||||||
|
metaAutoPickup.setDisplayName(ChatColor.GREEN + "Toggle AutoPickup");
|
||||||
|
toggleAutoPickup.setItemMeta(metaAutoPickup);
|
||||||
|
inv.setItem(3, toggleAutoPickup);
|
||||||
|
|
||||||
|
// Toggle AutoSwitch
|
||||||
|
ItemStack toggleAutoSwitch = new ItemStack(Material.LEVER);
|
||||||
|
ItemMeta metaAutoSwitch = toggleAutoSwitch.getItemMeta();
|
||||||
|
metaAutoSwitch.setDisplayName(ChatColor.GREEN + "Toggle AutoSwitch");
|
||||||
|
toggleAutoSwitch.setItemMeta(metaAutoSwitch);
|
||||||
|
inv.setItem(4, toggleAutoSwitch);
|
||||||
|
|
||||||
|
// Reload Configurations
|
||||||
|
ItemStack reloadConfigs = new ItemStack(Material.BOOK);
|
||||||
|
ItemMeta metaReloadConfigs = reloadConfigs.getItemMeta();
|
||||||
|
metaReloadConfigs.setDisplayName(ChatColor.GREEN + "Reload Configs");
|
||||||
|
reloadConfigs.setItemMeta(metaReloadConfigs);
|
||||||
|
inv.setItem(5, reloadConfigs);
|
||||||
|
|
||||||
|
player.openInventory(inv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (!event.getView().getTitle().equals(ChatColor.DARK_GREEN + "Settings Menu")) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
ItemStack clickedItem = event.getCurrentItem();
|
||||||
|
if (clickedItem == null || !clickedItem.hasItemMeta()) return;
|
||||||
|
|
||||||
|
String displayName = clickedItem.getItemMeta().getDisplayName();
|
||||||
|
if (displayName.equals(ChatColor.GREEN + "Toggle AutoPickup")) {
|
||||||
|
// Toggle AutoPickup logic here
|
||||||
|
} else if (displayName.equals(ChatColor.GREEN + "Toggle AutoSwitch")) {
|
||||||
|
// Toggle AutoSwitch logic here
|
||||||
|
} else if (displayName.equals(ChatColor.GREEN + "Reload Configs")) {
|
||||||
|
configManager.reloadConfig("config.yml");
|
||||||
|
configManager.reloadConfig("auto_switch.yml");
|
||||||
|
configManager.reloadConfig("banned_items.yml");
|
||||||
|
player.sendMessage(ChatColor.GREEN + "Configuration files reloaded.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package me.nvus.nvus_prison_setup.Listeners;
|
package me.nvus.nvus_prison_setup.Listeners;
|
||||||
|
|
||||||
import me.nvus.nvus_prison_setup.Configs.ConfigManager;
|
import me.nvus.nvus_prison_setup.Configs.ConfigManager;
|
||||||
|
import me.nvus.nvus_prison_setup.Configs.SettingsMenu;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -27,7 +28,7 @@ public class CommandListener implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /nvus <reload|version|autopickup|autoswitch> [arguments]");
|
sender.sendMessage(ChatColor.RED + "Usage: /nvus <reload|version|menu|autopickup|autoswitch> [arguments]");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +39,14 @@ public class CommandListener implements CommandExecutor {
|
||||||
case "version":
|
case "version":
|
||||||
handleVersionCommand(sender);
|
handleVersionCommand(sender);
|
||||||
break;
|
break;
|
||||||
|
case "menu":
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "This command can only be used by players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
new SettingsMenu(plugin, configManager).openSettingsMenu(player);
|
||||||
|
break;
|
||||||
case "autopickup":
|
case "autopickup":
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(ChatColor.RED + "Usage: /nvus autopickup <true|false>");
|
sender.sendMessage(ChatColor.RED + "Usage: /nvus autopickup <true|false>");
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
# www.FNGnation.net #
|
# www.FNGnation.net #
|
||||||
# Discord: FNGnation.net/discord #
|
# Discord: FNGnation.net/discord #
|
||||||
#======================================================================================#
|
#======================================================================================#
|
||||||
# Remember to give all prisoner ranks/groups the permission ' nvus.prisoner ' and negate that permission for any
|
# Remember to give prisoner ranks/groups the permission ' nvus.prisoner ' and negate that permission for any
|
||||||
# players that are not or no longer considered a prisoner.
|
# players that are not or no longer considered a prisoner.
|
||||||
|
|
||||||
# Should prisoners auto pickup blocks they have mined?
|
# Should prisoners auto pickup blocks they have mined?
|
||||||
|
# Use /nvus autopickup true|false to toggle this in-game! (Requires permission: nvus.admin)
|
||||||
AutoPickup: true
|
AutoPickup: true
|
||||||
# Should prisoners be able to auto switch to the correct tool for whatever they are mining?
|
# Should prisoners be able to auto switch to the correct tool for whatever they are mining?
|
||||||
#i.e. If hitting dirt/clay with a pickaxe, they will auto switch to a shovel (if in their quickbar)
|
#i.e. If hitting dirt/clay with a pickaxe, they will auto switch to a shovel (if in their quickbar)
|
||||||
|
# Use /nvus autoswitch true|false to toggle this in-game! (Requires permission: nvus.admin)
|
||||||
AutoSwitch: true
|
AutoSwitch: true
|
||||||
|
|
|
@ -8,4 +8,5 @@ website: https://FNGnation.net
|
||||||
commands:
|
commands:
|
||||||
nvus:
|
nvus:
|
||||||
description: Base command for NVus Prison Setup
|
description: Base command for NVus Prison Setup
|
||||||
usage: /<command> <reload|version|autopickup|autoswitch> [arguments]
|
usage: /<command> <reload|version|autopickup|autoswitch|menu> [arguments]
|
||||||
|
aliases: [nvusmenu]
|
||||||
|
|
Loading…
Reference in New Issue