Delete src/main/java/net/viper/status/modules/economy/EconomyModule.java via Git Manager GUI
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
package net.viper.status.modules.economy;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.viper.status.StatusAPI;
|
||||
import net.viper.status.module.Module;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* EconomyModule – serverübergreifendes Geldkonto über MySQL (bc_accounts).
|
||||
*
|
||||
* Konfiguration in verify.properties:
|
||||
* economy.mysql.host=localhost
|
||||
* economy.mysql.port=3306
|
||||
* economy.mysql.database=survivalplus
|
||||
* economy.mysql.username=root
|
||||
* economy.mysql.password=
|
||||
* economy.start-balance=500.0
|
||||
*
|
||||
* Das Modul registriert sich im Modul-System der StatusAPI und hält
|
||||
* EconomyDatabase + EconomyManager, die von SurvivalPlus und allen
|
||||
* anderen Servern über die gemeinsame bc_accounts-Tabelle genutzt werden.
|
||||
*/
|
||||
public class EconomyModule implements Module {
|
||||
|
||||
private EconomyDatabase database;
|
||||
private EconomyManager manager;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "EconomyModule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable(Plugin plugin) {
|
||||
// Konfiguration aus verify.properties laden
|
||||
Properties props = ((StatusAPI) plugin).getVerifyProperties();
|
||||
|
||||
String host = getProp(props, "economy.mysql.host", "localhost");
|
||||
int port = getInt (props, "economy.mysql.port", 3306);
|
||||
String database = getProp(props, "economy.mysql.database", "survivalplus");
|
||||
String user = getProp(props, "economy.mysql.username", "root");
|
||||
String password = getProp(props, "economy.mysql.password", "");
|
||||
double startBal = getDbl (props, "economy.start-balance", 500.0);
|
||||
|
||||
this.database = new EconomyDatabase(plugin, host, port, database, user, password);
|
||||
|
||||
if (!this.database.isConnected()) {
|
||||
plugin.getLogger().severe("[Economy] Modul wird NICHT aktiviert – keine DB-Verbindung.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.manager = new EconomyManager(plugin, this.database, startBal);
|
||||
|
||||
// Listener registrieren (Login → load, Disconnect → save)
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, new EconomyListener(plugin, manager));
|
||||
plugin.getProxy().getPluginManager().registerCommand(plugin, new PayCommand(plugin, manager));
|
||||
plugin.getProxy().getPluginManager().registerCommand(plugin, new EcoAdminCommand(plugin, manager));
|
||||
|
||||
plugin.getLogger().info("[Economy] EconomyModule aktiviert (start-balance: " + startBal + ").");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(Plugin plugin) {
|
||||
if (database != null) {
|
||||
database.close();
|
||||
plugin.getLogger().info("[Economy] MySQL-Verbindung geschlossen.");
|
||||
}
|
||||
}
|
||||
|
||||
/** Gibt den EconomyManager zurück (für andere Module oder HTTP-Endpoints). */
|
||||
public EconomyManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Hilfsmethoden
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
private static String getProp(Properties p, String key, String def) {
|
||||
if (p == null) return def;
|
||||
String v = p.getProperty(key, def);
|
||||
return (v == null || v.trim().isEmpty()) ? def : v.trim();
|
||||
}
|
||||
|
||||
private static int getInt(Properties p, String key, int def) {
|
||||
try { return Integer.parseInt(getProp(p, key, String.valueOf(def))); }
|
||||
catch (NumberFormatException e) { return def; }
|
||||
}
|
||||
|
||||
private static double getDbl(Properties p, String key, double def) {
|
||||
try { return Double.parseDouble(getProp(p, key, String.valueOf(def))); }
|
||||
catch (NumberFormatException e) { return def; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user