forked from never2nv/NVus_Prison
v0.9.1 - Fixed DB init. Fixed DB url. Fixed DB Connection. Added Gang Commands in plugin.yml. Added help menus for /nvus and /gang. Gangs not fully implemented yet but the database is there and several methods have been created so it's a start.
This commit is contained in:
parent
faced3df51
commit
2b7e98635a
|
@ -1,6 +1,7 @@
|
|||
package me.nvus.nvus_prison_setup.Gangs;
|
||||
|
||||
import me.nvus.nvus_prison_setup.Database.DatabaseManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -15,7 +16,6 @@ public class GangCommands implements CommandExecutor {
|
|||
this.gangManager = new GangManager(dbManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players can execute this command.");
|
||||
|
@ -25,15 +25,20 @@ public class GangCommands implements CommandExecutor {
|
|||
Player player = (Player) sender;
|
||||
UUID playerUuid = player.getUniqueId();
|
||||
|
||||
if (args.length >= 2 && args[0].equalsIgnoreCase("gang")) {
|
||||
if (args.length == 0 || (args.length == 1 && args[0].equalsIgnoreCase("gang"))) {
|
||||
// No subcommand specified, or only "gang" was specified
|
||||
sendGangCommandHelp(player);
|
||||
return true;
|
||||
} else if (args.length >= 1 && args[0].equalsIgnoreCase("gang")) {
|
||||
// A subcommand is specified, handle it accordingly
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "create":
|
||||
return handleGangCreate(player, args);
|
||||
case "invite":
|
||||
return handleGangInvite(sender, args);
|
||||
case "accept":
|
||||
// Dynamically determine the gangName the player is invited to join
|
||||
return handleGangAccept(player, playerUuid);
|
||||
case "deny":
|
||||
// Dynamically determine the gangName the player wants to deny
|
||||
return handleGangDeny(player, playerUuid);
|
||||
case "leave":
|
||||
return handleGangLeave(player, playerUuid);
|
||||
|
@ -45,6 +50,52 @@ public class GangCommands implements CommandExecutor {
|
|||
return false;
|
||||
}
|
||||
|
||||
private void sendGangCommandHelp(Player player) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append(ChatColor.GREEN).append("\n");
|
||||
message.append(ChatColor.LIGHT_PURPLE).append("NVus Prison Gangs:\n");
|
||||
message.append(ChatColor.DARK_GRAY).append("=======\n");
|
||||
message.append(ChatColor.GREEN).append("/gang create <name/tag> - Use this to create a gang.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang invite <player> - Invite player to your gang.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang accept - Accept an invite to a gang.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang deny - Deny an invite to a gang.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang leave - Leave your current gang.\n");
|
||||
message.append(ChatColor.GREEN).append("\n");
|
||||
message.append(ChatColor.YELLOW).append("COMING SOON:\n");
|
||||
message.append(ChatColor.YELLOW).append("=============\n");
|
||||
message.append(ChatColor.GREEN).append("/gang disband - Delete/Remove your gang.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang promote <player> - Promote a gang member to a higher rank.\n");
|
||||
message.append(ChatColor.GREEN).append("/gang kick <player> - Kick a member from your gang.\n");
|
||||
message.append(ChatColor.GREEN).append("\n");
|
||||
|
||||
player.sendMessage(message.toString());
|
||||
}
|
||||
|
||||
|
||||
private boolean handleGangCreate(Player player, String[] args) {
|
||||
if (args.length != 2) {
|
||||
player.sendMessage("Usage: /gang create <gangName>");
|
||||
return true;
|
||||
}
|
||||
|
||||
String gangName = args[1];
|
||||
|
||||
// Check if the player already belongs to a gang
|
||||
String currentGang = gangManager.getCurrentGangName(player.getUniqueId());
|
||||
if (currentGang != null) {
|
||||
player.sendMessage("You already belong to a gang.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Create the gang
|
||||
if (gangManager.createGang(gangName, player)) {
|
||||
player.sendMessage("Gang created successfully!");
|
||||
} else {
|
||||
player.sendMessage("Failed to create gang. The gang may already exist.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean handleGangInvite(CommandSender sender, String[] args) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /nvus gang invite <playerName> <gangName>");
|
||||
|
|
|
@ -13,14 +13,21 @@ public class GangManager {
|
|||
this.dbManager = dbManager;
|
||||
}
|
||||
|
||||
public boolean createGang(String gangName, UUID ownerUuid) {
|
||||
public boolean createGang(String gangName, Player owner) {
|
||||
UUID ownerUuid = owner.getUniqueId();
|
||||
String ownerUuidString = ownerUuid.toString();
|
||||
|
||||
// Check if the gang already exists
|
||||
if (dbManager.getGangIdByName(gangName) != null) {
|
||||
return false;
|
||||
}
|
||||
dbManager.createGang(gangName, ownerUuid.toString());
|
||||
|
||||
// Create the gang in the database
|
||||
dbManager.createGang(gangName, ownerUuidString);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Method to add a member to a gang
|
||||
public boolean addMemberToGang(String username, UUID uuid, String gangName, String rank) {
|
||||
Integer gangId = dbManager.getGangIdByName(gangName);
|
||||
|
@ -65,9 +72,6 @@ public class GangManager {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private String resolveUsername(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
|
|
|
@ -28,7 +28,28 @@ public class CommandListener implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /nvus <reload|version|menu|autopickup|autoswitch> [arguments]");
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append(ChatColor.GREEN).append("\n");
|
||||
message.append(ChatColor.GOLD).append("NVus Prison GOLD Edition:\n");
|
||||
message.append(ChatColor.DARK_GRAY).append("==========================\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus reload - Reloads all configuration files.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus version - Shows the plugin version.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus menu - Open a GUI menu to toggle options on/off.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus autopickup true|false - Toggle prisoner auto pickup of mined resources.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus autoswitch true|false - Toggle prisoner auto switching to correct tools when mining.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus prisonerarmor true|false - Toggle if prisoners spawn with orange leather armor aka jumpsuits.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus restrictarmor true|false - Toggle if prisoners can change their armor or not.\n");
|
||||
message.append(ChatColor.GREEN).append("/nvus tooldamage true|false - Toggle if prisoner tools receive damage. FALSE = no damage!\n");
|
||||
message.append(ChatColor.AQUA).append("Support: https://FNGnation.net/discord\n");
|
||||
message.append(ChatColor.AQUA).append("\n");
|
||||
message.append(ChatColor.LIGHT_PURPLE).append("GANGS:\n");
|
||||
message.append(ChatColor.DARK_GRAY).append("=======\n");
|
||||
message.append(ChatColor.GREEN).append("/gang - Use this to see full gang command list!");
|
||||
message.append(ChatColor.GREEN).append("\n");
|
||||
|
||||
sender.sendMessage(message.toString());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue