Update from Git Manager GUI
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4,36 +4,38 @@ import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
public class MySQLManager {
|
||||
/**
|
||||
* Setzt die Priorität (prio) für eine Zieltruhe (target chest) anhand von uuid, item, slot.
|
||||
* Legt die Spalte prio an, falls sie noch nicht existiert.
|
||||
*/
|
||||
public void setTargetChestPrio(String uuid, String item, int slot, int prio) {
|
||||
ensureConnected();
|
||||
// Spalte prio anlegen, falls sie fehlt
|
||||
try (Statement st = connection.createStatement()) {
|
||||
ResultSet rs = connection.getMetaData().getColumns(connection.getCatalog(), null, "asc_target_chests", "prio");
|
||||
if (!rs.next()) {
|
||||
st.execute("ALTER TABLE asc_target_chests ADD COLUMN prio INT DEFAULT 0;");
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
if (!e.getMessage().toLowerCase().contains("duplicate column")) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die Priorität (prio) für eine Zieltruhe (target chest) anhand von uuid, item, slot.
|
||||
* Legt die Spalte prio an, falls sie noch nicht existiert.
|
||||
*/
|
||||
public void setTargetChestPrio(String uuid, String item, int slot, int prio) {
|
||||
ensureConnected();
|
||||
// Spalte prio anlegen, falls sie fehlt (lazy migration)
|
||||
try (Statement st = connection.createStatement()) {
|
||||
ResultSet rs = connection.getMetaData().getColumns(connection.getCatalog(), null, "asc_target_chests", "prio");
|
||||
if (!rs.next()) {
|
||||
st.execute("ALTER TABLE asc_target_chests ADD COLUMN prio INT DEFAULT 0;");
|
||||
}
|
||||
// Prio setzen
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"UPDATE asc_target_chests SET prio=? WHERE uuid=? AND item=? AND slot=?;")) {
|
||||
ps.setInt(1, prio);
|
||||
ps.setString(2, uuid);
|
||||
ps.setString(3, item);
|
||||
ps.setInt(4, slot);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
if (!e.getMessage().toLowerCase().contains("duplicate column")) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// Prio setzen
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"UPDATE asc_target_chests SET prio=? WHERE uuid=? AND item=? AND slot=?;")) {
|
||||
ps.setInt(1, prio);
|
||||
ps.setString(2, uuid);
|
||||
ps.setString(3, item);
|
||||
ps.setInt(4, slot);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Connection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
@@ -372,6 +374,7 @@ public class MySQLManager {
|
||||
* serverName gesetzt → nur Transfers mit target_server == serverName ODER target_server == '' (Legacy).
|
||||
*/
|
||||
public List<Map<String, Object>> getPendingTransfers(String uuid, String serverName) {
|
||||
ensureConnected();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
try {
|
||||
PreparedStatement ps;
|
||||
@@ -573,6 +576,7 @@ public class MySQLManager {
|
||||
|
||||
/** Löscht eine spezifische Slot-Zieltruhe und verschiebt höhere Slots nach unten. */
|
||||
public void removeTargetChestSlot(String uuid, String item, int slot) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_target_chests WHERE uuid=? AND item=? AND slot=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -596,6 +600,7 @@ public class MySQLManager {
|
||||
|
||||
/** Gibt den nächsten freien Slot für ein Item zurück. */
|
||||
public int getNextTargetSlot(String uuid, String item) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT COALESCE(MAX(slot)+1, 0) AS next_slot FROM asc_target_chests WHERE uuid=? AND item=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -610,6 +615,7 @@ public class MySQLManager {
|
||||
|
||||
/** Zählt wie viele Zieltruhen für ein bestimmtes Item registriert sind. */
|
||||
public int countTargetChestsForItem(String uuid, String item) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT COUNT(*) FROM asc_target_chests WHERE uuid=? AND item=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -753,6 +759,7 @@ public class MySQLManager {
|
||||
|
||||
/** Gibt den nächsten freien Slot für Rest-Truhen zurück. */
|
||||
public int getNextRestSlot(String uuid) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT COALESCE(MAX(slot)+1, 0) AS next_slot FROM asc_rest_chests WHERE uuid=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -768,6 +775,7 @@ public class MySQLManager {
|
||||
* Gibt den Slot zurück, den diese Location bereits belegt, oder -1 wenn nicht gefunden.
|
||||
*/
|
||||
public int getRestSlotForLocation(String uuid, String world, int x, int y, int z) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT slot FROM asc_rest_chests WHERE uuid=? AND world=? AND x=? AND y=? AND z=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -849,6 +857,7 @@ public class MySQLManager {
|
||||
|
||||
/** Löscht eine spezifische Rest-Truhe anhand des Slots. */
|
||||
public void removeRestChestSlot(String uuid, int slot) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_rest_chests WHERE uuid=? AND slot=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -883,6 +892,7 @@ public class MySQLManager {
|
||||
|
||||
/** Löscht ALLE Rest-Truhen eines Spielers. */
|
||||
public void removeRestChest(String uuid) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_rest_chests WHERE uuid=?;")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -895,6 +905,7 @@ public class MySQLManager {
|
||||
// --- Hilfsmethoden für serverCrosslink (unverändert) ---
|
||||
|
||||
public List<Map<String, Object>> getAllInputChests() {
|
||||
ensureConnected();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM asc_input_chests;")) {
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -918,6 +929,7 @@ public class MySQLManager {
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getAllTargetChests() {
|
||||
ensureConnected();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM asc_target_chests;")) {
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -941,6 +953,7 @@ public class MySQLManager {
|
||||
}
|
||||
|
||||
public Map<String, Object> getAnyRestChest() {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT * FROM asc_rest_chests WHERE `public`=1 ORDER BY uuid, slot LIMIT 1;")) {
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -969,6 +982,7 @@ public class MySQLManager {
|
||||
|
||||
/** Legt eine Mülltruche an oder aktualisiert sie. */
|
||||
public void setTrashChest(String uuid, String world, int x, int y, int z, String server) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT INTO asc_trash_chests (uuid, world, x, y, z, server) VALUES (?,?,?,?,?,?) " +
|
||||
"ON DUPLICATE KEY UPDATE world=VALUES(world), x=VALUES(x), y=VALUES(y), z=VALUES(z), server=VALUES(server)")) {
|
||||
@@ -984,6 +998,7 @@ public class MySQLManager {
|
||||
|
||||
/** Gibt die Mülltruche eines Spielers zurück (nur die des eigenen Servers). */
|
||||
public Map<String, Object> getTrashChest(String uuid, String serverName) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT * FROM asc_trash_chests WHERE uuid=? AND (server=? OR server='') LIMIT 1")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -1004,6 +1019,7 @@ public class MySQLManager {
|
||||
|
||||
/** Gibt ALLE Mülltruchen zurück (für sign-update oder cross-server). */
|
||||
public List<Map<String, Object>> getAllTrashChests() {
|
||||
ensureConnected();
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
try (PreparedStatement ps = connection.prepareStatement("SELECT * FROM asc_trash_chests")) {
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -1023,6 +1039,7 @@ public class MySQLManager {
|
||||
|
||||
/** Entfernt die Mülltruche eines Spielers. */
|
||||
public void removeTrashChest(String uuid) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_trash_chests WHERE uuid=?")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -1032,6 +1049,7 @@ public class MySQLManager {
|
||||
|
||||
/** Speichert die komplette Filter-Liste (ersetzt alte Einträge). */
|
||||
public void setTrashItems(String uuid, List<String> items) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement del = connection.prepareStatement(
|
||||
"DELETE FROM asc_trash_items WHERE uuid=?")) {
|
||||
del.setString(1, uuid);
|
||||
@@ -1051,6 +1069,7 @@ public class MySQLManager {
|
||||
|
||||
/** Lädt die Filter-Liste eines Spielers. */
|
||||
public List<String> getTrashItems(String uuid) {
|
||||
ensureConnected();
|
||||
List<String> list = new ArrayList<>();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"SELECT item FROM asc_trash_items WHERE uuid=?")) {
|
||||
@@ -1063,6 +1082,7 @@ public class MySQLManager {
|
||||
|
||||
/** Fügt ein einzelnes Item zur Filter-Liste hinzu. */
|
||||
public void addTrashItem(String uuid, String item) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"INSERT IGNORE INTO asc_trash_items (uuid, item) VALUES (?,?)")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -1073,6 +1093,7 @@ public class MySQLManager {
|
||||
|
||||
/** Entfernt ein einzelnes Item aus der Filter-Liste. */
|
||||
public void removeTrashItem(String uuid, String item) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_trash_items WHERE uuid=? AND item=?")) {
|
||||
ps.setString(1, uuid);
|
||||
@@ -1083,6 +1104,7 @@ public class MySQLManager {
|
||||
|
||||
/** Entfernt alle Filter-Items eines Spielers. */
|
||||
public void removeAllTrashItems(String uuid) {
|
||||
ensureConnected();
|
||||
try (PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM asc_trash_items WHERE uuid=?")) {
|
||||
ps.setString(1, uuid);
|
||||
|
||||
@@ -6,6 +6,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Barrel;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -303,7 +305,7 @@ public class TrashChestManager {
|
||||
*/
|
||||
public void removeTrashChest(UUID uuid, Location loc) {
|
||||
trashChestLocations.remove(uuid);
|
||||
locationToOwner.remove(locKey(loc));
|
||||
if (loc != null) locationToOwner.remove(locKey(loc));
|
||||
trashFilterLists.remove(uuid);
|
||||
if (plugin.isMysqlEnabled() && plugin.getMysqlManager() != null) {
|
||||
plugin.getMysqlManager().removeTrashChest(uuid.toString());
|
||||
@@ -379,7 +381,9 @@ public class TrashChestManager {
|
||||
public void clearTrashChest(UUID ownerUUID) {
|
||||
Location loc = trashChestLocations.get(ownerUUID);
|
||||
if (loc == null || loc.getWorld() == null) return;
|
||||
if (loc.getBlock().getState() instanceof Chest chest) chest.getInventory().clear();
|
||||
BlockState state = loc.getBlock().getState();
|
||||
if (state instanceof Chest chest) chest.getInventory().clear();
|
||||
else if (state instanceof Barrel barrel) barrel.getInventory().clear();
|
||||
}
|
||||
|
||||
// ══════════════════════════════════════════════════════════════════════════
|
||||
@@ -473,8 +477,11 @@ public class TrashChestManager {
|
||||
for (Map.Entry<UUID, Location> entry : new HashMap<>(trashChestLocations).entrySet()) {
|
||||
Location loc = entry.getValue();
|
||||
if (loc == null || loc.getWorld() == null) continue;
|
||||
if (loc.getBlock().getState() instanceof Chest chest) {
|
||||
BlockState state = loc.getBlock().getState();
|
||||
if (state instanceof Chest chest) {
|
||||
processTrashChestInventory(entry.getKey(), chest.getInventory());
|
||||
} else if (state instanceof Barrel barrel) {
|
||||
processTrashChestInventory(entry.getKey(), barrel.getInventory());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -822,6 +829,7 @@ public class TrashChestManager {
|
||||
}
|
||||
|
||||
private String locKey(Location loc) {
|
||||
if (loc == null || loc.getWorld() == null) return "null";
|
||||
return loc.getWorld().getName() + ":" + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
# ============================================================
|
||||
|
||||
# Version der Konfigurationsdatei – bitte nicht ändern!
|
||||
version: "2.5"
|
||||
version: "2.8"
|
||||
|
||||
# Debug-Modus: true = Ausführliche Logs in der Konsole (nur zum Entwickeln)
|
||||
debug: false
|
||||
@@ -95,11 +95,17 @@ chest_limits:
|
||||
# WICHTIG: Spieler OHNE jegliche autosortchest.limit.*-Permission können bei
|
||||
# aktivierten Limits KEINE Truhen erstellen (Limit = 0).
|
||||
# Vergib autosortchest.limit.default an alle normalen Spieler (z.B. in LuckPerms).
|
||||
#
|
||||
# BARREL-UNTERSTÜTZUNG:
|
||||
# Fässer (Barrel) und Truhen (Chest) werden gemeinsam gezählt!
|
||||
# Das Limit gilt für BEIDE zusammen.
|
||||
# Beispiel: target: 50 = max. 50 Truhen ODER 50 Fässer ODER z.B. 30 Truhen + 20 Fässer.
|
||||
# Fässer können genau wie Truhen als Input, Ziel, Rest oder Mülltruhe eingesetzt werden.
|
||||
default:
|
||||
input: 1 # Eingangstruhen
|
||||
rest: 1 # Rest-Truhen (Fallback)
|
||||
target: 50 # Zieltruhen gesamt
|
||||
target_per_item: 1 # Zieltruhen pro Item-Typ
|
||||
input: 1 # Eingangstruhen + Eingangsfässer gesamt
|
||||
rest: 1 # Rest-Truhen + Rest-Fässer gesamt
|
||||
target: 50 # Zieltruhen + Zielfässer gesamt
|
||||
target_per_item: 1 # Zieltruhen/Zielfässer pro Item-Typ
|
||||
|
||||
vip:
|
||||
input: 2
|
||||
@@ -264,6 +270,19 @@ chest-titles:
|
||||
trash:
|
||||
de: "&4Mülltruhe"
|
||||
en: "&4Trash Chest"
|
||||
# Fass-Titel (Barrel) – werden automatisch verwendet wenn ein Fass geöffnet wird
|
||||
input-barrel:
|
||||
de: "&6Eingangsfass"
|
||||
en: "&6Input Barrel"
|
||||
target-barrel:
|
||||
de: "&6%item%"
|
||||
en: "&6%item%"
|
||||
rest-barrel:
|
||||
de: "&6Rest-Fass"
|
||||
en: "&6Rest Barrel"
|
||||
trash-barrel:
|
||||
de: "&4Müllfass"
|
||||
en: "&4Trash Barrel"
|
||||
|
||||
# ============================================================
|
||||
# SYSTEM-NACHRICHTEN (Spieler-Feedback)
|
||||
@@ -329,7 +348,7 @@ messages:
|
||||
|
||||
# --- AutoSign-Befehl (/asc autosign) ---
|
||||
# Platzhalter: %item% = Item-Name
|
||||
autosign-no-chest: "&cDu schaust auf keine Truhe! &7(max. 5 Blöcke)"
|
||||
autosign-no-chest: "&cDu schaust auf keine Truhe oder kein Fass! &7(max. 5 Blöcke)"
|
||||
autosign-invalid-type:"&cUngültiger Typ! Nutze: input, ziel, rest, trash"
|
||||
autosign-unknown-item:"&cUnbekanntes Item: &e%item%"
|
||||
autosign-no-space: "&cKein freier Platz für ein Schild an dieser Truhe!"
|
||||
@@ -353,6 +372,10 @@ messages:
|
||||
# --- Konsolen-Hinweis (wenn Spieler-Befehl per Konsole aufgerufen) ---
|
||||
console-only: "&cDieser Befehl ist nur für Spieler! (Konsole: reload, import, export, list)"
|
||||
|
||||
# --- Autosign-Verwendungshinweis ---
|
||||
autosign-player-only: "&cDieser Befehl ist nur für Spieler!"
|
||||
autosign-usage: "&cVerwendung: /asc autosign <input|ziel|rest|trash> [item|hand]"
|
||||
|
||||
# ============================================================
|
||||
# MÜLLTRUHEN-GUI
|
||||
# ============================================================
|
||||
@@ -462,8 +485,4 @@ trash-gui:
|
||||
export-backup: "&7 Backup: &f%file%"
|
||||
export-backup-skipped: "&7 Backup: &8Übersprungen (players.yml war leer)"
|
||||
export-error: "&cExport fehlgeschlagen: &e%error%"
|
||||
backup-failed: "&cBackup fehlgeschlagen: &e%error%"
|
||||
|
||||
# --- Autosign-Verwendungshinweis ---
|
||||
autosign-player-only: "&cDieser Befehl ist nur für Spieler!"
|
||||
autosign-usage: "&cVerwendung: /asc autosign <input|ziel|rest|trash> [item|hand]"
|
||||
backup-failed: "&cBackup fehlgeschlagen: &e%error%"
|
||||
@@ -1,9 +1,9 @@
|
||||
name: AutoSortChest
|
||||
version: 2.7
|
||||
version: 2.9
|
||||
main: com.viper.autosortchest.Main
|
||||
api-version: 1.21
|
||||
authors: [M_Viper]
|
||||
description: Ein Plugin zum automatischen Sortieren von Items in Truhen
|
||||
description: Ein Plugin zum automatischen Sortieren von Items in Truhen und Fässern
|
||||
commands:
|
||||
asc:
|
||||
description: AutoSortChest Befehle
|
||||
@@ -11,7 +11,7 @@ commands:
|
||||
aliases: [autosortchest]
|
||||
permissions:
|
||||
autosortchest.use:
|
||||
description: Erlaubt das Erstellen von AutoSortChest-Schildern (Eingang, Ziel, Rest, Muelltruhe) sowie die Verwendung von /asc autosign
|
||||
description: Erlaubt das Erstellen von ASC-Schildern an Truhen und Faessern (Eingang, Ziel, Rest, Muelltruhe) sowie /asc autosign
|
||||
default: true
|
||||
autosortchest.reload:
|
||||
description: Erlaubt das Neuladen der Konfiguration mit /asc reload
|
||||
|
||||
Reference in New Issue
Block a user