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
70f56cde66
commit
faced3df51
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>me.NVus</groupId>
|
||||
<artifactId>NVus_Prison</artifactId>
|
||||
<version>0.9.0</version>
|
||||
<version>0.9.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>NVus_PrisonSetup</name>
|
||||
|
|
|
@ -7,15 +7,23 @@ import java.sql.ResultSet;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.UUID;
|
||||
import java.io.File;
|
||||
|
||||
public class DatabaseManager {
|
||||
|
||||
private String url = "jdbc:sqlite:/plugins/NVus_Prison/nvus_prison.db";
|
||||
private String url;
|
||||
public DatabaseManager(File dataFolder) {
|
||||
// Construct the file path for the SQLite database
|
||||
File databaseFile = new File(dataFolder, "nvus_prison.db");
|
||||
this.url = "jdbc:sqlite:" + databaseFile.getAbsolutePath();
|
||||
initializeDatabase();
|
||||
}
|
||||
|
||||
public DatabaseManager() {
|
||||
initializeDatabase();
|
||||
}
|
||||
|
||||
|
||||
private Connection connect() {
|
||||
Connection conn = null;
|
||||
try {
|
||||
|
@ -53,6 +61,11 @@ public class DatabaseManager {
|
|||
}
|
||||
}
|
||||
|
||||
// Public Accessor to initialize the database
|
||||
public void initDatabase() {
|
||||
initializeDatabase();
|
||||
}
|
||||
|
||||
public void createGang(String name, String ownerUuid) {
|
||||
String sql = "INSERT INTO gangs(name, owner_uuid) VALUES(?,?)";
|
||||
|
||||
|
|
|
@ -20,11 +20,17 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.io.File;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public final class PrisonSetup extends JavaPlugin {
|
||||
|
||||
private ConfigManager configManager;
|
||||
private DatabaseManager dbManager; // Adjusted for clarity
|
||||
private DatabaseManager dbManager;
|
||||
private GangManager gangManager; // Added reference to GangManager
|
||||
// Initialize the DatabaseManager
|
||||
|
||||
|
@ -33,13 +39,27 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
// Initialize the ConfigManager
|
||||
configManager = new ConfigManager(this);
|
||||
|
||||
// Gangs & Database
|
||||
dbManager = new DatabaseManager(); // Initialize the DatabaseManager
|
||||
gangManager = new GangManager(dbManager); // Initialize GangManager with DatabaseManager
|
||||
// Get the plugin's data folder
|
||||
File dataFolder = getDataFolder();
|
||||
|
||||
// Initialize the DatabaseManager with the plugin's data folder
|
||||
dbManager = new DatabaseManager(dataFolder);
|
||||
|
||||
// Initialize the GangManager with the DatabaseManager
|
||||
gangManager = new GangManager(dbManager);
|
||||
|
||||
// Check if SQLite DB Exists, if not init it
|
||||
File databaseFile = new File(dataFolder, "nvus_prison.db");
|
||||
if (!databaseFile.exists()) {
|
||||
// If the database file doesn't exist, initialize the database
|
||||
dbManager.initDatabase();
|
||||
getLogger().info("SQLite database initialized successfully.");
|
||||
} else {
|
||||
getLogger().info("SQLite database already exists.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Save the default configs, if they doesn't exist
|
||||
// Save the default configs, if they don't exist
|
||||
configManager.saveDefaultConfig("config.yml");
|
||||
configManager.saveDefaultConfig("banned_items.yml");
|
||||
configManager.saveDefaultConfig("auto_switch.yml");
|
||||
|
@ -52,10 +72,8 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
getServer().getPluginManager().registerEvents(new ToolSwitchListener(configManager), this);
|
||||
this.getCommand("nvus").setExecutor(new CommandListener(this, configManager));
|
||||
|
||||
// Gang Related
|
||||
// Register the Gang Commands
|
||||
this.getCommand("gang create").setExecutor(new GangCommands(dbManager));
|
||||
this.getCommand("gang invite").setExecutor(new GangCommands(dbManager));
|
||||
// Gang Related...... GANG, GANG #LOLOLOLOL
|
||||
this.getCommand("gang").setExecutor(new GangCommands(dbManager));
|
||||
|
||||
// Settings Menu
|
||||
getServer().getPluginManager().registerEvents(new SettingsMenu(this, configManager), this);
|
||||
|
@ -102,7 +120,6 @@ public final class PrisonSetup extends JavaPlugin {
|
|||
return configManager;
|
||||
}
|
||||
|
||||
// Optionally, if other parts of your plugin need to access the DatabaseManager or GangManager
|
||||
public DatabaseManager getDatabaseManager() {
|
||||
return dbManager;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,25 @@ commands:
|
|||
usage: |
|
||||
/nvus reload - Reloads all configuration files.
|
||||
/nvus version - Shows the plugin version.
|
||||
/nvus menu - Opens the settings menu (player only).
|
||||
/nvus menu - Opens the settings menu.
|
||||
/nvus autopickup <true|false> - Toggles the auto item pickup feature.
|
||||
/nvus autoswitch <true|false> - Toggles the auto tool switch feature.
|
||||
/nvus prisonerarmor <true|false> - Toggles giving prisoners armor on join.
|
||||
/nvus restrictarmor <true|false> - Toggles the restriction on changing prisoner armor.
|
||||
/nvus tooldamage <true|false> - Toggle if prisoner tools receive damage. FALSE = No Damage.
|
||||
aliases: [nvusmenu]
|
||||
|
||||
gang:
|
||||
description: Base command for gang-related actions.
|
||||
usage: |
|
||||
/gang create <name/tag> - Create a gang
|
||||
/gang invite <player> - Invite a player to your gang.
|
||||
/gang accept - Accept a Gang Invite.
|
||||
/gang deny - Decline a Gang Invite.
|
||||
/gang leave - Leave your current Gang.
|
||||
-----COMING SOON-----
|
||||
/gang disband - Disband your gang.
|
||||
/gang kick <player> - Kick a player from your gang.
|
||||
/gang promote <player> - Promote a player to a higher rank.
|
||||
/gang demote <player> - Demote a player to a lower rank.
|
||||
aliases: [gangs]
|
Loading…
Reference in New Issue