From 4da002788de3ab0580c4b6ec239f9d1c273f7768 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 16 Dec 2021 16:37:05 +0100 Subject: [PATCH 1/4] Implement Punishments --- .../src/de/steamwar/sql/Punishment.java | 146 ++++++++++++++++++ .../src/de/steamwar/sql/Statement.java | 130 ++++++++++++++++ 2 files changed, 276 insertions(+) create mode 100644 SpigotCore_Main/src/de/steamwar/sql/Punishment.java create mode 100644 SpigotCore_Main/src/de/steamwar/sql/Statement.java diff --git a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java new file mode 100644 index 0000000..19b0296 --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java @@ -0,0 +1,146 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.sql; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Timestamp; +import java.time.format.DateTimeFormatter; +import java.util.*; + +public class Punishment { + + private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1"); + private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)"); + private static final Statement getAllPunishments = new Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC"); + private static final Statement insert = new Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)"); + + public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) { + return getPunishment.select(rs -> { + if (rs.next()) + return new Punishment(rs); + return null; + }, user, type.name()); + } + + public static Map getPunishmentsOfPlayer(int user) { + return getPunishments.select(rs -> { + Map punishments = new HashMap<>(); + while (rs.next()) + punishments.put(PunishmentType.valueOf(rs.getString("Type")), new Punishment(rs)); + return punishments; + }, user); + } + + public static List getAllPunishmentsOfPlayer(int user) { + return getAllPunishments.select(rs -> { + List punishments = new ArrayList<>(); + while (rs.next()) + punishments.add(new Punishment(rs)); + return punishments; + }, user); + } + + public static Punishment createPunishment(int user, int executor, PunishmentType type, String reason, Timestamp endTime, boolean perma) { + insert.update(user, executor, type.name(), reason, endTime, perma); + return getPunishmentOfPlayer(user, type); + } + + private final Timestamp startTime; + private Timestamp endTime; + private final PunishmentType type; + private final int user; + private final int id; + private String reason; + private final int punisher; + private boolean perma; + + private Punishment(ResultSet set) throws SQLException { + user = set.getInt("UserId"); + reason = set.getString("Reason"); + type = PunishmentType.valueOf(set.getString("Type")); + startTime = set.getTimestamp("StartTime"); + endTime = set.getTimestamp("EndTime"); + punisher = set.getInt("Punisher"); + perma = set.getBoolean("Perma"); + id = set.getInt("PunishmentId"); + } + + public Timestamp getStartTime() { + return startTime; + } + + public Timestamp getEndTime() { + return endTime; + } + + public PunishmentType getType() { + return type; + } + + public int getUser() { + return user; + } + + public String getReason() { + return reason; + } + + public int getPunisher() { + return punisher; + } + + public boolean isPerma() { + return perma; + } + + public String getBantime(Timestamp endTime, boolean perma) { + if (perma) { + return "permanent"; + } else { + return endTime.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")); + } + } + + public boolean isCurrent() { + return isPerma() || getEndTime().after(new Date()); + } + + @AllArgsConstructor + @Getter + public enum PunishmentType { + Ban(false, "BAN_TEAM", "BAN_PERMA", "BAN_UNTIL", "UNBAN_ERROR", "UNBAN"), + Mute( false, "MUTE_TEAM", "MUTE_PERMA", "MUTE_UNTIL", "UNMUTE_ERROR", "UNMUTE"), + NoSchemReceiving(false, "NOSCHEMRECEIVING_TEAM", "NOSCHEMRECEIVING_PERMA", "NOSCHEMRECEIVING_UNTIL", "UNNOSCHEMRECEIVING_ERROR", "UNNOSCHEMRECEIVING"), + NoSchemSharing(false, "NOSCHEMSHARING_TEAM", "NOSCHEMSHARING_PERMA", "NOSCHEMSHARING_UNTIL", "UNNOSCHEMSHARING_ERROR", "UNNOSCHEMSHARING"), + NoSchemSubmitting(true, "NOSCHEMSUBMITTING_TEAM", "NOSCHEMSUBMITTING_PERMA", "NOSCHEMSUBMITTING_UNTIL", "UNNOSCHEMSUBMITTING_ERROR", "UNNOSCHEMSUBMITTING"), + NoDevServer(true, "NODEVSERVER_TEAM", "NODEVSERVER_PERMA", "NODEVSERVER_UNTIL", "UNNODEVSERVER_ERROR", "UNNODEVSERVER"); + + private final boolean needsAdmin; + private final String teamMessage; + private final String playerMessagePerma; + private final String playerMessageUntil; + private final String usageNotPunished; + private final String unpunishmentMessage; + } +} diff --git a/SpigotCore_Main/src/de/steamwar/sql/Statement.java b/SpigotCore_Main/src/de/steamwar/sql/Statement.java new file mode 100644 index 0000000..db75983 --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/sql/Statement.java @@ -0,0 +1,130 @@ +package de.steamwar.sql; + +import de.steamwar.core.Core; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; + +public class Statement { + + private static final List statements = new ArrayList<>(); + + private static Connection con; + private static String url; + private static String user; + private static String password; + + public static void connect(String url, String user, String password) { + Statement.url = url; + Statement.user = user; + Statement.password = password; + try { + con = DriverManager.getConnection(url + "?autoReconnect=true&useServerPrepStmts=true", user, password); + } catch (SQLException e) { + throw new SecurityException("Could not start SQL-Connection", e); + } + } + + private static void reset() { + close(); + connect(url, user, password); + try { + for (Statement statement : statements) { + statement.init(); + } + } catch (SQLException e) { + throw new SecurityException("Could not reprepare SQL statements", e); + } + } + + public static void close() { + synchronized (statements) { + for (Statement statement : statements) { + try { + statement.st.close(); + } catch (SQLException e) { + Core.getInstance().getLogger().log(Level.INFO, "Could not close statement", e); + } + } + + try { + con.close(); + } catch (SQLException e) { + Core.getInstance().getLogger().log(Level.INFO, "Could not close SQL connection", e); + } + } + } + + public static boolean connectionStable() { + try { + return !con.isClosed(); + } catch (SQLException e) { + return false; + } + } + + private final String sql; + private PreparedStatement st; + + public Statement(String sql) { + this.sql = sql; + statements.add(this); + try { + init(); + } catch (SQLException e) { + throw new SecurityException("Could not init SQL statement", e); + } + } + + private void init() throws SQLException { + st = con.prepareStatement(sql); + } + + public T select(ResultSetUser user, Object... objects) { + synchronized (statements) { + return prepare(() -> { + ResultSet rs = st.executeQuery(); + T result = user.use(rs); + rs.close(); + return result; + }, objects); + } + } + + public void update(Object... objects) { + synchronized (statements) { + prepare(st::executeUpdate, objects); + } + } + + private T prepare(SQLRunnable runnable, Object... objects) { + try { + setObjects(objects); + return runnable.run(); + } catch (SQLException e) { + reset(); + throw new SecurityException("Could not execute SQL statement", e); + } + } + + private void setObjects(Object... objects) throws SQLException { + for (int i = 0; i < objects.length; i++) { + st.setObject(i + 1, objects[i]); + } + } + + public interface ResultSetUser { + T use(ResultSet rs) throws SQLException; + } + + private interface SQLRunnable { + T run() throws SQLException; + } + +} -- 2.39.5 From c1a4a91bb9ca6b6ed47031bb9ddbefe644369dcf Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 16 Dec 2021 17:27:08 +0100 Subject: [PATCH 2/4] Bugfixes --- SpigotCore_Main/src/SpigotCore.properties | 86 ++++++++---- .../src/de/steamwar/sql/Punishment.java | 8 +- .../src/de/steamwar/sql/Statement.java | 130 ------------------ 3 files changed, 62 insertions(+), 162 deletions(-) delete mode 100644 SpigotCore_Main/src/de/steamwar/sql/Statement.java diff --git a/SpigotCore_Main/src/SpigotCore.properties b/SpigotCore_Main/src/SpigotCore.properties index 28628df..b22cee3 100644 --- a/SpigotCore_Main/src/SpigotCore.properties +++ b/SpigotCore_Main/src/SpigotCore.properties @@ -17,47 +17,77 @@ # along with this program. If not, see . # -SCHEM_SELECTOR_TITLE={0} auswählen: {1} -SCHEM_SELECTOR_BACK=§eZurück -SCHEM_SELECTOR_DIR=§9Ordner -SCHEM_SELECTOR_RANK=§8Rang {0} -SCHEM_SELECTOR_OWN=§7Eigene Schematics -SCHEM_SELECTOR_PUB=§7Public Schematics -SCHEM_SELECTOR_SEL_DIR=§7Ordner auswählen -SCHEM_SELECTOR_NEW_DIR=§7Neuer Ordner -SCHEM_SELECTOR_FILTER=§7Filter -SCHEM_SELECTOR_SORTING=§7Sortierung -SCHEM_SELECTOR_SORTING_CURRENT=§7Aktuell: §e{0} +SCHEM_SELECTOR_TITLE={0} ausw�hlen: {1} +SCHEM_SELECTOR_BACK=�eZur�ck +SCHEM_SELECTOR_DIR=�9Ordner +SCHEM_SELECTOR_RANK=�8Rang {0} +SCHEM_SELECTOR_OWN=�7Eigene Schematics +SCHEM_SELECTOR_PUB=�7Public Schematics +SCHEM_SELECTOR_SEL_DIR=�7Ordner ausw�hlen +SCHEM_SELECTOR_NEW_DIR=�7Neuer Ordner +SCHEM_SELECTOR_FILTER=�7Filter +SCHEM_SELECTOR_SORTING=�7Sortierung +SCHEM_SELECTOR_SORTING_CURRENT=�7Aktuell: �e{0} SCHEM_SELECTOR_SORTING_NAME=Name SCHEM_SELECTOR_SORTING_TYPE=Schematic-Typ SCHEM_SELECTOR_SORTING_UPDATE=Letztes Update -SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0} +SCHEM_SELECTOR_SORTING_DIRECTION=�7Richtung: �e{0} SCHEM_SELECTOR_SORTING_ASC=Aufsteigend SCHEM_SELECTOR_SORTING_DSC=Absteigend -SCHEM_SELECTOR_ITEM_NAME=§e{0} -SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0} -SCHEM_SELECTOR_ITEM_REPLACE=§e{0}§7 -SCHEM_SELECTOR_ITEM_LORE_TYPE=§7{0} +SCHEM_SELECTOR_ITEM_NAME=�e{0} +SCHEM_SELECTOR_ITEM_NAME_FILTER=�7{0} +SCHEM_SELECTOR_ITEM_REPLACE=�e{0}�7 +SCHEM_SELECTOR_ITEM_LORE_TYPE=�7{0} SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen SCHEM_SELECTOR_FILTER_TITLE=Filter SCHEM_SELECTOR_FILTER_ENTER_NAME=Name eingeben -SCHEM_SELECTOR_FILTER_NAME=§7Nach Namen suchen... -SCHEM_SELECTOR_FILTER_NAME_SEARCH=§7Suchbegriff: §e{0} +SCHEM_SELECTOR_FILTER_NAME=�7Nach Namen suchen... +SCHEM_SELECTOR_FILTER_NAME_SEARCH=�7Suchbegriff: �e{0} SCHEM_SELECTOR_FILTER_ENTER_OWNER=Besitzer eingeben -SCHEM_SELECTOR_FILTER_OWNER=§7Nach Besitzer suchen... -SCHEM_SELECTOR_FILTER_OWNER_SEARCH=§7Besitzer: §e{0} -SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ wählen... -SCHEM_SELECTOR_FILTER_TYPE=§7Nach Typ filtern... -SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Typ: §e{0} -SCHEM_SELECTOR_FILTER_MAT=§7Nach Item filtern... -SCHEM_SELECTOR_FILTER_MAT_SEARCH=§7Item: §e{0} -SCHEM_SELECTOR_CANCEL=§eAbbrechen -SCHEM_SELECTOR_GO=§eSuchen... +SCHEM_SELECTOR_FILTER_OWNER=�7Nach Besitzer suchen... +SCHEM_SELECTOR_FILTER_OWNER_SEARCH=�7Besitzer: �e{0} +SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ w�hlen... +SCHEM_SELECTOR_FILTER_TYPE=�7Nach Typ filtern... +SCHEM_SELECTOR_FILTER_TYPE_SEARCH=�7Typ: �e{0} +SCHEM_SELECTOR_FILTER_MAT=�7Nach Item filtern... +SCHEM_SELECTOR_FILTER_MAT_SEARCH=�7Item: �e{0} +SCHEM_SELECTOR_CANCEL=�eAbbrechen +SCHEM_SELECTOR_GO=�eSuchen... SCHEM_SELECTOR_SCHEMATIC=Schematic SCHEM_SELECTOR_DIRECTORY=Ordner SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Ordner -MATERIAL_SELECTOR_TITLE=Material auswählen \ No newline at end of file +MATERIAL_SELECTOR_TITLE=Material ausw�hlen + +BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4} +BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0} +BAN_UNTIL=§7Du bist §ebis zum {0} §e§lgebannt§8. §7Grund§8: §e{1} +UNBAN_ERROR=§cDer Spieler ist nicht gebannt. +UNBAN=§7Du hast §e{0} §e§lentbannt. + +MUTE_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgemuted§8. §7Grund§8: §f{4} +MUTE_PERMA=§7Du bist §epermanent §e§lgemuted§8. §7Grund§8: §e{0} +MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1} +UNMUTE_ERROR=§cDer Spieler ist nicht gemuted. +UNMUTE=§7Du hast §e{0} §e§lentmuted. + +NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMSHARING_ERROR=§cDer Spieler ist nicht vom Verteilen von Schematics ausgeschlossen. +UNNOSCHEMSHARING=§e{0} §7darf nun wieder §e§lSchematics verteilen§8. + +NOSCHEMSUBMITTING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematiceinsenden ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMSUBMITTING_PERMA=§7Du bist §epermanent §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMSUBMITTING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lEinsenden von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMSUBMITTING_ERROR=§cDer Spieler ist nicht vom Einsenden von Schematics ausgeschlossen. +UNNOSCHEMSUBMITTING=§e{0} §7darf nun wieder §e§lSchematis einsenden§8. + +NODEVSERVER_TEAM={0} §e{1} §7hat §e{2} §7mit Grund §f{4}§7 zu generft und hat daher §e§lDevserververbot §7erhalten§8, §e{3} +NODEVSERVER_PERMA=§7Du bist §epermanent §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{0} +NODEVSERVER_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lDevserver §7ausgeschlossen§8. §7Grund§8: §e{1} +UNNODEVSERVER_ERROR=§cDer Spieler ist nicht vom Devserver ausgeschlossen. +UNNODEVSERVER=§e{0} §7darf nun wieder dem §e§lDevserver beitreten§8. \ No newline at end of file diff --git a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java index 19b0296..70caaed 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java @@ -30,10 +30,10 @@ import java.util.*; public class Punishment { - private static final Statement getPunishment = new Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1"); - private static final Statement getPunishments = new Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)"); - private static final Statement getAllPunishments = new Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC"); - private static final Statement insert = new Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)"); + private static final SQL.Statement getPunishment = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1"); + private static final SQL.Statement getPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)"); + private static final SQL.Statement getAllPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC"); + private static final SQL.Statement insert = new SQL.Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)"); public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) { return getPunishment.select(rs -> { diff --git a/SpigotCore_Main/src/de/steamwar/sql/Statement.java b/SpigotCore_Main/src/de/steamwar/sql/Statement.java deleted file mode 100644 index db75983..0000000 --- a/SpigotCore_Main/src/de/steamwar/sql/Statement.java +++ /dev/null @@ -1,130 +0,0 @@ -package de.steamwar.sql; - -import de.steamwar.core.Core; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; - -public class Statement { - - private static final List statements = new ArrayList<>(); - - private static Connection con; - private static String url; - private static String user; - private static String password; - - public static void connect(String url, String user, String password) { - Statement.url = url; - Statement.user = user; - Statement.password = password; - try { - con = DriverManager.getConnection(url + "?autoReconnect=true&useServerPrepStmts=true", user, password); - } catch (SQLException e) { - throw new SecurityException("Could not start SQL-Connection", e); - } - } - - private static void reset() { - close(); - connect(url, user, password); - try { - for (Statement statement : statements) { - statement.init(); - } - } catch (SQLException e) { - throw new SecurityException("Could not reprepare SQL statements", e); - } - } - - public static void close() { - synchronized (statements) { - for (Statement statement : statements) { - try { - statement.st.close(); - } catch (SQLException e) { - Core.getInstance().getLogger().log(Level.INFO, "Could not close statement", e); - } - } - - try { - con.close(); - } catch (SQLException e) { - Core.getInstance().getLogger().log(Level.INFO, "Could not close SQL connection", e); - } - } - } - - public static boolean connectionStable() { - try { - return !con.isClosed(); - } catch (SQLException e) { - return false; - } - } - - private final String sql; - private PreparedStatement st; - - public Statement(String sql) { - this.sql = sql; - statements.add(this); - try { - init(); - } catch (SQLException e) { - throw new SecurityException("Could not init SQL statement", e); - } - } - - private void init() throws SQLException { - st = con.prepareStatement(sql); - } - - public T select(ResultSetUser user, Object... objects) { - synchronized (statements) { - return prepare(() -> { - ResultSet rs = st.executeQuery(); - T result = user.use(rs); - rs.close(); - return result; - }, objects); - } - } - - public void update(Object... objects) { - synchronized (statements) { - prepare(st::executeUpdate, objects); - } - } - - private T prepare(SQLRunnable runnable, Object... objects) { - try { - setObjects(objects); - return runnable.run(); - } catch (SQLException e) { - reset(); - throw new SecurityException("Could not execute SQL statement", e); - } - } - - private void setObjects(Object... objects) throws SQLException { - for (int i = 0; i < objects.length; i++) { - st.setObject(i + 1, objects[i]); - } - } - - public interface ResultSetUser { - T use(ResultSet rs) throws SQLException; - } - - private interface SQLRunnable { - T run() throws SQLException; - } - -} -- 2.39.5 From da8b27d5ff7871f0efd5091e60a0cf3a9640883f Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 16 Dec 2021 17:40:01 +0100 Subject: [PATCH 3/4] UTF-8 + Bugfixes --- SpigotCore_Main/src/SpigotCore.properties | 62 ++++++++++--------- .../src/de/steamwar/sql/Punishment.java | 14 ----- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/SpigotCore_Main/src/SpigotCore.properties b/SpigotCore_Main/src/SpigotCore.properties index b22cee3..acb3749 100644 --- a/SpigotCore_Main/src/SpigotCore.properties +++ b/SpigotCore_Main/src/SpigotCore.properties @@ -17,50 +17,50 @@ # along with this program. If not, see . # -SCHEM_SELECTOR_TITLE={0} ausw�hlen: {1} -SCHEM_SELECTOR_BACK=�eZur�ck -SCHEM_SELECTOR_DIR=�9Ordner -SCHEM_SELECTOR_RANK=�8Rang {0} -SCHEM_SELECTOR_OWN=�7Eigene Schematics -SCHEM_SELECTOR_PUB=�7Public Schematics -SCHEM_SELECTOR_SEL_DIR=�7Ordner ausw�hlen -SCHEM_SELECTOR_NEW_DIR=�7Neuer Ordner -SCHEM_SELECTOR_FILTER=�7Filter -SCHEM_SELECTOR_SORTING=�7Sortierung -SCHEM_SELECTOR_SORTING_CURRENT=�7Aktuell: �e{0} +SCHEM_SELECTOR_TITLE={0} auswählen: {1} +SCHEM_SELECTOR_BACK=§eZurück +SCHEM_SELECTOR_DIR=§9Ordner +SCHEM_SELECTOR_RANK=§8Rang {0} +SCHEM_SELECTOR_OWN=§7Eigene Schematics +SCHEM_SELECTOR_PUB=§7Public Schematics +SCHEM_SELECTOR_SEL_DIR=§7Ordner auswählen +SCHEM_SELECTOR_NEW_DIR=§7Neuer Ordner +SCHEM_SELECTOR_FILTER=§7Filter +SCHEM_SELECTOR_SORTING=§7Sortierung +SCHEM_SELECTOR_SORTING_CURRENT=§7Aktuell: §e{0} SCHEM_SELECTOR_SORTING_NAME=Name SCHEM_SELECTOR_SORTING_TYPE=Schematic-Typ SCHEM_SELECTOR_SORTING_UPDATE=Letztes Update -SCHEM_SELECTOR_SORTING_DIRECTION=�7Richtung: �e{0} +SCHEM_SELECTOR_SORTING_DIRECTION=§7Richtung: §e{0} SCHEM_SELECTOR_SORTING_ASC=Aufsteigend SCHEM_SELECTOR_SORTING_DSC=Absteigend -SCHEM_SELECTOR_ITEM_NAME=�e{0} -SCHEM_SELECTOR_ITEM_NAME_FILTER=�7{0} -SCHEM_SELECTOR_ITEM_REPLACE=�e{0}�7 -SCHEM_SELECTOR_ITEM_LORE_TYPE=�7{0} +SCHEM_SELECTOR_ITEM_NAME=§e{0} +SCHEM_SELECTOR_ITEM_NAME_FILTER=§7{0} +SCHEM_SELECTOR_ITEM_REPLACE=§e{0}§7 +SCHEM_SELECTOR_ITEM_LORE_TYPE=§7{0} SCHEM_SELECTOR_CREATE_DIR_TITLE=Ordner erstellen SCHEM_SELECTOR_FILTER_TITLE=Filter SCHEM_SELECTOR_FILTER_ENTER_NAME=Name eingeben -SCHEM_SELECTOR_FILTER_NAME=�7Nach Namen suchen... -SCHEM_SELECTOR_FILTER_NAME_SEARCH=�7Suchbegriff: �e{0} +SCHEM_SELECTOR_FILTER_NAME=§7Nach Namen suchen... +SCHEM_SELECTOR_FILTER_NAME_SEARCH=§7Suchbegriff: §e{0} SCHEM_SELECTOR_FILTER_ENTER_OWNER=Besitzer eingeben -SCHEM_SELECTOR_FILTER_OWNER=�7Nach Besitzer suchen... -SCHEM_SELECTOR_FILTER_OWNER_SEARCH=�7Besitzer: �e{0} -SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ w�hlen... -SCHEM_SELECTOR_FILTER_TYPE=�7Nach Typ filtern... -SCHEM_SELECTOR_FILTER_TYPE_SEARCH=�7Typ: �e{0} -SCHEM_SELECTOR_FILTER_MAT=�7Nach Item filtern... -SCHEM_SELECTOR_FILTER_MAT_SEARCH=�7Item: �e{0} -SCHEM_SELECTOR_CANCEL=�eAbbrechen -SCHEM_SELECTOR_GO=�eSuchen... +SCHEM_SELECTOR_FILTER_OWNER=§7Nach Besitzer suchen... +SCHEM_SELECTOR_FILTER_OWNER_SEARCH=§7Besitzer: §e{0} +SCHEM_SELECTOR_FILTER_SEL_TYPE=Typ wählen... +SCHEM_SELECTOR_FILTER_TYPE=§7Nach Typ filtern... +SCHEM_SELECTOR_FILTER_TYPE_SEARCH=§7Typ: §e{0} +SCHEM_SELECTOR_FILTER_MAT=§7Nach Item filtern... +SCHEM_SELECTOR_FILTER_MAT_SEARCH=§7Item: §e{0} +SCHEM_SELECTOR_CANCEL=§eAbbrechen +SCHEM_SELECTOR_GO=§eSuchen... SCHEM_SELECTOR_SCHEMATIC=Schematic SCHEM_SELECTOR_DIRECTORY=Ordner SCHEM_SELECTOR_SCHEMATIC_NODE=Schematic/Ordner -MATERIAL_SELECTOR_TITLE=Material ausw�hlen +MATERIAL_SELECTOR_TITLE=Material auswählen BAN_TEAM={0} §e{1} §7wurde von §e{2} {3} §e§lgebannt§8. §7Grund§8: §f{4} BAN_PERMA=§7Du bist §epermanent §e§lgebannt§8. §7Grund§8: §e{0} @@ -74,6 +74,12 @@ MUTE_UNTIL=§7Du bist §ebis zum {0} §e§lgemuted§8. §7Grund§8: §e{1} UNMUTE_ERROR=§cDer Spieler ist nicht gemuted. UNMUTE=§7Du hast §e{0} §e§lentmuted. +NOSCHEMRECEIVING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicerhalten ausgeschlossen§8. §7Grund§8: §f{4} +NOSCHEMRECEIVING_PERMA=§7Du bist §epermanent §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{0} +NOSCHEMRECEIVING_UNTIL=§7Du bist §ebis zum {0} §7vom Erhalten von §e§lSchematics ausgeschlossen§8. §7Grund§8: §e{1} +UNNOSCHEMRECEIVING_ERROR=§cDer Spieler ist nicht vom Erhalten von Schematics ausgeschlossen. +UNNOSCHEMRECEIVING=§e{0} §7darf nun wieder §e§lSchematics erhalten§8. + NOSCHEMSHARING_TEAM={0} §e{1} §7wurde von §e{2} {3} §7vom §e§lSchematicverteilen ausgeschlossen§8. §7Grund§8: §f{4} NOSCHEMSHARING_PERMA=§7Du bist §epermanent §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{0} NOSCHEMSHARING_UNTIL=§7Du bist §ebis zum {0} §7vom §e§lVerteilen von Schematics§7 ausgeschlossen§8. §7Grund§8: §e{1} diff --git a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java index 70caaed..6c97fa4 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java @@ -52,20 +52,6 @@ public class Punishment { }, user); } - public static List getAllPunishmentsOfPlayer(int user) { - return getAllPunishments.select(rs -> { - List punishments = new ArrayList<>(); - while (rs.next()) - punishments.add(new Punishment(rs)); - return punishments; - }, user); - } - - public static Punishment createPunishment(int user, int executor, PunishmentType type, String reason, Timestamp endTime, boolean perma) { - insert.update(user, executor, type.name(), reason, endTime, perma); - return getPunishmentOfPlayer(user, type); - } - private final Timestamp startTime; private Timestamp endTime; private final PunishmentType type; -- 2.39.5 From e18d8c4868d8dce05ed6fbeb5cb591960ab8ab40 Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Thu, 16 Dec 2021 17:49:45 +0100 Subject: [PATCH 4/4] Removed Unused Statements --- SpigotCore_Main/src/de/steamwar/sql/Punishment.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java index 6c97fa4..0e2bc5b 100644 --- a/SpigotCore_Main/src/de/steamwar/sql/Punishment.java +++ b/SpigotCore_Main/src/de/steamwar/sql/Punishment.java @@ -32,8 +32,6 @@ public class Punishment { private static final SQL.Statement getPunishment = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? AND Type = ? ORDER BY PunishmentId DESC LIMIT 1"); private static final SQL.Statement getPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE PunishmentId IN (SELECT MAX(PunishmentId) FROM Punishments WHERE UserId = ? GROUP BY Type)"); - private static final SQL.Statement getAllPunishments = new SQL.Statement("SELECT * FROM Punishments WHERE UserId = ? ORDER BY `PunishmentId` DESC"); - private static final SQL.Statement insert = new SQL.Statement("INSERT INTO Punishments (UserId, Punisher, Type, Reason, EndTime, Perma) VALUES (?, ?, ?, ?, ?, ?)"); public static Punishment getPunishmentOfPlayer(int user, PunishmentType type) { return getPunishment.select(rs -> { -- 2.39.5