diff --git a/src/main/java/minevalley/core/api/CoreServer.java b/src/main/java/minevalley/core/api/CoreServer.java index 44e6ff16..4b6eb23a 100644 --- a/src/main/java/minevalley/core/api/CoreServer.java +++ b/src/main/java/minevalley/core/api/CoreServer.java @@ -4,10 +4,7 @@ import minevalley.core.api.armorstand.FakeArmorStand; import minevalley.core.api.corporations.Group; import minevalley.core.api.corporations.companies.*; -import minevalley.core.api.database.DatabaseEntry; -import minevalley.core.api.database.DatabaseEntryCollection; -import minevalley.core.api.database.DatabaseTable; -import minevalley.core.api.database.Value; +import minevalley.core.api.database.StatementBuilder; import minevalley.core.api.discord.EmbeddedMessage; import minevalley.core.api.discord.Webhook; import minevalley.core.api.economy.BankAccount; @@ -55,11 +52,13 @@ import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; import org.bukkit.util.Vector; +import org.intellij.lang.annotations.Language; import org.jetbrains.annotations.ApiStatus; import javax.annotation.Nonnegative; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.sql.SQLException; import java.time.DayOfWeek; import java.util.List; import java.util.UUID; @@ -84,6 +83,11 @@ public interface CoreServer { @Nonnull BukkitTask runAsyncTaskPeriodically(long delay, long period, @Nonnull Runnable runnable) throws IllegalArgumentException; + @Nonnull + StatementBuilder prepareSQL(@Nonnull @Language("SQL") String sql, boolean retrieveGeneratedKeys) throws SQLException; + + int generateUniqueId(@Nonnull String table, @Nonnull String column, int amountOfChars) throws IllegalArgumentException, SQLException; + void registerListener(@Nonnull Class extends Event> cls, @Nonnull EventListener extends Event> listener) throws IllegalArgumentException; void unregisterListener(@Nonnull Class extends Event> cls, @Nonnull EventListener extends Event> listener) throws IllegalArgumentException; @@ -111,20 +115,6 @@ public interface CoreServer { void sendDebug(@Nonnull DebugType type, @Nonnull String message); - DatabaseEntry getDatabaseEntry(String tableName, Value searchValue); - - DatabaseEntry getDatabaseEntryAnd(String tableName, Value... searchValues); - - DatabaseEntry getDatabaseEntryOr(String tableName, Value... searchValues); - - DatabaseEntryCollection getDatabaseEntryCollection(String tableName, Value searchValue); - - DatabaseEntryCollection getDatabaseEntryCollectionAnd(String tableName, Value... searchValues); - - DatabaseEntryCollection getDatabaseEntryCollectionOr(String tableName, Value... searchValues); - - DatabaseTable getDatabaseTable(String tableName); - void setSetting(@Nonnull String key, @Nonnull String value) throws IllegalArgumentException; String getSetting(String key); diff --git a/src/main/java/minevalley/core/api/database/ColumnType.java b/src/main/java/minevalley/core/api/database/ColumnType.java new file mode 100644 index 00000000..5ec19c1f --- /dev/null +++ b/src/main/java/minevalley/core/api/database/ColumnType.java @@ -0,0 +1,207 @@ +package minevalley.core.api.database; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum ColumnType { + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code BIT}. + */ + BIT(-7), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code TINYINT}. + */ + TINYINT(-6), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code SMALLINT}. + */ + SMALLINT(5), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code INTEGER}. + */ + INTEGER(4), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code BIGINT}. + */ + BIGINT(-5), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code FLOAT}. + */ + FLOAT(6), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code REAL}. + */ + REAL(7), + + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code DOUBLE}. + */ + DOUBLE(8), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code NUMERIC}. + */ + NUMERIC(2), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code DECIMAL}. + */ + DECIMAL(3), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code CHAR}. + */ + CHAR(1), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code VARCHAR}. + */ + VARCHAR(12), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code LONGVARCHAR}. + */ + LONGVARCHAR(-1), + + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code DATE}. + */ + DATE(91), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code TIME}. + */ + TIME(92), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code TIMESTAMP}. + */ + TIMESTAMP(93), + + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code BINARY}. + */ + BINARY(-2), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code VARBINARY}. + */ + VARBINARY(-3), + + /** + *
The constant in the Java programming language, sometimes referred + * to as a type code, that identifies the generic SQL type + * {@code LONGVARBINARY}. + */ + LONGVARBINARY(-4), + + /** + *
The constant in the Java programming language
+ * that identifies the generic SQL value
+ * {@code NULL}.
+ */
+ NULL(0),
+
+ /**
+ * The constant in the Java programming language that indicates
+ * that the SQL type is database-specific and
+ * gets mapped to a Java object that can be accessed via
+ * the methods {@code getObject} and {@code setObject}.
+ */
+ OTHER(1111),
+
+ /**
+ * The constant in the Java programming language, sometimes referred to
+ * as a type code, that identifies the generic SQL type
+ * {@code DISTINCT}.
+ *
+ * @since 1.2
+ */
+ DISTINCT(2001),
+
+
+ /**
+ * The constant in the Java programming language, sometimes referred to
+ * as a type code, that identifies the generic SQL type {@code BOOLEAN}.
+ *
+ * @since 1.4
+ */
+ BOOLEAN(16),
+
+ /**
+ * The constant in the Java programming language, sometimes referred to
+ * as a type code, that identifies the generic SQL type {@code REF CURSOR}.
+ *
+ * @since 1.8
+ */
+ REF_CURSOR(2012),
+
+ /**
+ * The constant in the Java programming language, sometimes referred to
+ * as a type code, that identifies the generic SQL type
+ * {@code TIME WITH TIMEZONE}.
+ *
+ * @since 1.8
+ */
+ TIME_WITH_TIMEZONE(2013),
+
+ /**
+ * The constant in the Java programming language, sometimes referred to
+ * as a type code, that identifies the generic SQL type
+ * {@code TIMESTAMP WITH TIMEZONE}.
+ *
+ * @since 1.8
+ */
+ TIMESTAMP_WITH_TIMEZONE(2014);
+
+ private final int type;
+}
diff --git a/src/main/java/minevalley/core/api/database/DatabaseEntry.java b/src/main/java/minevalley/core/api/database/DatabaseEntry.java
deleted file mode 100644
index f93a8a09..00000000
--- a/src/main/java/minevalley/core/api/database/DatabaseEntry.java
+++ /dev/null
@@ -1,134 +0,0 @@
-package minevalley.core.api.database;
-
-import minevalley.core.api.Registrant;
-import org.bukkit.Location;
-import org.bukkit.block.Block;
-import org.bukkit.inventory.ItemStack;
-
-import java.sql.Array;
-
-public interface DatabaseEntry {
-
- /**
- * Removes the specific database entry from the table.
- */
- void remove();
-
- /**
- * Checks if the database-entry exists.
- *
- * @return true if the selected database entry exists in the table
- */
- boolean exists();
-
- /**
- * Changes a value of the selected entry.
- *
- * @param value value object with the column and the new value
- */
- void changeValue(Value value);
-
- /**
- * Gets the string at the given column.
- *
- * @param column name of the column
- * @return string at given column from the selected database entry
- */
- String getString(String column);
-
- /**
- * Gets the integer at the given column.
- *
- * @param column name of the column
- * @return integer at given column from the selected database entry
- */
- int getInteger(String column);
-
- /**
- * Gets the boolean at the given column.
- *
- * @param column name of the column
- * @return boolean at given column from the selected database entry
- */
- boolean getBoolean(String column);
-
- /**
- * Gets the double at the given column.
- *
- * @param column name of the column
- * @return double at given column from the selected database entry
- */
- double getDouble(String column);
-
- /**
- * Gets the float at the given column.
- *
- * @param column name of the column
- * @return float at given column from the selected database entry
- */
- float getFloat(String column);
-
- /**
- * Gets the long at the given column.
- *
- * @param column name of the column
- * @return long at given column from the selected database entry
- */
- long getLong(String column);
-
- /**
- * Gets the byte at the given column.
- *
- * @param column name of the column
- * @return byte at given column from the selected database entry
- */
- byte getByte(String column);
-
- /**
- * Gets the array at the given column.
- *
- * @param column name of the column
- * @return array at given column from the selected database entry
- */
- Array getArray(String column);
-
- /**
- * Gets the location at the given column (with pitch & yaw).
- *
- * @param column name of the column
- * @return location at given column from the selected database entry
- */
- Location getLocation(String column);
-
- /**
- * Gets the block at the given column.
- *
- * @param column name of the column
- * @return block at given column from the selected database entry
- */
- Block getBlock(String column);
-
- /**
- * Gets the registrant at the given column.
- *
- * @param column name of the column
- * @return registrant at given column from the selected database entry
- */
- Registrant getRegistrant(String column);
-
- /**
- * Gets the itemstack at the given column.
- *
- * @param column name of the column
- * @return itemstack at given column from the selected database entry
- */
- ItemStack getItemStack(String column);
-
- /**
- * Gets the itemstack[] at the given column.
- *
- * @param column name of the column
- * @return itemstack[] at given column from the selected database entry
- */
- ItemStack[] getItemStacks(String column);
-}
\ No newline at end of file
diff --git a/src/main/java/minevalley/core/api/database/DatabaseEntryCollection.java b/src/main/java/minevalley/core/api/database/DatabaseEntryCollection.java
deleted file mode 100644
index 327c7196..00000000
--- a/src/main/java/minevalley/core/api/database/DatabaseEntryCollection.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package minevalley.core.api.database;
-
-import java.util.List;
-
-public interface DatabaseEntryCollection {
-
- /**
- * Gets a list of all entries in this collection.
- *
- * @return list of database entries
- */
- List You can call {@link StatementBuilder#executeUpdate()} or {@link StatementBuilder#executeQuery()} multiple times with or without changing parameters in between.
+ * Use {@link StatementBuilder#unwrap()} to get the underlying {@link PreparedStatement} object if you need to use a method that is not covered by this interface.
+ * The following code snippet demonstrates a possible way to use this interface:
+ *
+ * Note: Even though JDBC handles untyped {@code NULL} values pretty well, it is mandatory to provide the {@link ColumnType} of the parameter.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param type the {@link ColumnType} of the parameter
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setNull(int parameterIndex, @Nonnull ColumnType type) throws IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@code boolean} value.
+ * Representation: {@code boolean} values are converted to SQL {@code BIT} values Representation: {@code byte} values are converted to SQL {@code TINYINT} values Representation: {@code short} values are converted to SQL {@code SMALLINT} values Representation: {@code int} values are converted to SQL {@code INTEGER} values Representation: {@code long} values are converted to SQL {@code BIGINT} values Representation: {@code float} values are converted to SQL {@code FLOAT} values Representation: {@code double} values are converted to SQL {@code DOUBLE} values Representation: {@link BigDecimal} values are converted to SQL {@code DECIMAL} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param bd the {@link BigDecimal} value to set.
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code bd} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setBigDecimal(int parameterIndex, @Nonnull BigDecimal bd) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link String} value.
+ * Representation: {@link String} values are converted to SQL {@code VARCHAR} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param s the {@link String} value to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code s} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setString(int parameterIndex, @Nonnull String s) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@code byte} array.
+ * Representation: {@code byte} arrays are converted to SQL {@code VARBINARY} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param bytes the {@code byte} array to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code bytes} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setBytes(int parameterIndex, @Nonnull byte[] bytes) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link Date} value.
+ * Representation: {@link Date} values are converted to SQL {@code DATE} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param date the {@link Date} value to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code date} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setDate(int parameterIndex, @Nonnull Date date) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link Time} value.
+ * Representation: {@link Time} values are converted to SQL {@code TIME} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param time the {@link Time} value to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code time} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setTime(int parameterIndex, @Nonnull Time time) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link Timestamp} value.
+ * Representation: {@link Timestamp} values are converted to SQL {@code TIMESTAMP} values
+ * Note: This method is not meant to handle {@code NULL} values. Use {@link StatementBuilder#setNull(int, ColumnType)} instead.
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param timestamp the {@link Timestamp} value to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code timestamp} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setTimestamp(int parameterIndex, @Nonnull Timestamp timestamp) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link Object} value.
+ *
+ * Note:
+ *
+ * Note:
+ *
+ * Note: This method should be used for queries that do not return a result set.
+ *
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs
+ */
+ @Contract(pure = true)
+ void executeUpdate() throws IllegalStateException, SQLException;
+
+ /**
+ * Executes the SQL query that has been built so far asynchronously.
+ *
+ * Note: This method should be used for queries that do not return a result set.
+ *
+ * @return a {@link CompletableFuture} that will be completed once the query has been executed
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ */
+ @Nonnull
+ @Contract(pure = true)
+ CompletableFuture
+ * Note: This method should be used for queries that do not return a result set.
+ *
+ * @return the generated key
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder} or this statement builder is not supposed to retrieve generated keys
+ * @throws SQLException if a database access error occurs
+ */
+ @Contract(pure = true)
+ int executeUpdateAndRetrieveKey() throws IllegalStateException, SQLException;
+
+ /**
+ * Executes the SQL query that has been built so far and retrieves the generated key asynchronously.
+ *
+ * Note: This method should be used for queries that do not return a result set.
+ *
+ * @return a {@link CompletableFuture} that will be completed once the query has been executed and the key has been retrieved
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder} or this statement builder is not supposed to retrieve generated keys
+ */
+ @Nonnull
+ @Contract(pure = true)
+ CompletableFuture
+ * Note: This method should be used for queries that return a result set.
+ *
+ * @return the result set
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or the query does not return a result set
+ */
+ @Nonnull
+ @Contract(pure = true)
+ ResultSet executeQuery() throws IllegalStateException, SQLException;
+
+ /**
+ * Executes the SQL query that has been built so far and returns the result set asynchronously.
+ *
+ * Note: This method should be used for queries that return a result set.
+ *
+ * @return a {@link CompletableFuture} that will be completed once the query has been executed and the result set has been retrieved
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ */
+ @Nonnull
+ @Contract(pure = true)
+ CompletableFuture
+ * Note:
+ *
+ * {@code
+ * Core.prepareSQL("UPDATE team SET note = ? WHERE unique_id = ?")
+ * .setString(1, "Coolest boss ever")
+ * .setString(2, "e0ae458e-214c-409e-ad6d-4091a6719bb0")
+ * .executeUpdate();
+ * }
+ *
+ *
+ * @see Core#prepareSQL(String)
+ * @see PreparedStatement
+ * @see ResultSet
+ */
+@SuppressWarnings("unused")
+public interface StatementBuilder extends AutoCloseable {
+
+ /**
+ * Gets the SQL code that will be executed when calling one of the {@code execute} methods.
+ *
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ */
+ @Nonnull
+ @Contract(pure = true)
+ String getSQL() throws IllegalStateException;
+
+ /**
+ * Sets the SQL code that will be executed when calling one of the {@code execute} methods.
+ *
+ * @param sql the SQL code to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code sql} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ */
+ @Nonnull
+ @Contract("_ -> this")
+ StatementBuilder setSQL(@Nonnull @Language("SQL") String sql) throws IllegalArgumentException, IllegalStateException;
+
+ /**
+ * Sets the parameter at the given index to SQL {@code NULL}.
+ *
+ *
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param obj the {@link Object} value to set
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code obj} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _ -> this")
+ StatementBuilder setObject(int parameterIndex, @Nonnull Object obj) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Sets the parameter at the given index to the given {@link Object} value.
+ *
+ *
+ *
+ * @param parameterIndex the index of the parameter to set, beginning with 1
+ * @param obj the {@link Object} value to set
+ * @param type the {@link ColumnType} of the parameter
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalArgumentException if {@code obj} is {@code null}
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs or if {@code parameterIndex} does not correspond to a parameter marker in the SQL statement
+ */
+ @Nonnull
+ @Contract("_, _, _ -> this")
+ StatementBuilder setObject(int parameterIndex, @Nonnull Object obj, @Nonnull ColumnType type) throws IllegalArgumentException, IllegalStateException, SQLException;
+
+ /**
+ * Clears all parameters that have been set so far.
+ *
+ * @return this {@code StatementBuilder} object
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ * @throws SQLException if a database access error occurs
+ */
+ @Nonnull
+ @Contract("-> this")
+ StatementBuilder clearParameters() throws IllegalStateException, SQLException;
+
+ /**
+ * Executes the SQL query that has been built so far.
+ *
+ *
+ *
+ * @return a copy of the underlying {@link PreparedStatement} object
+ * @throws IllegalStateException if this method is called on a closed {@code StatementBuilder}
+ */
+ @Nonnull
+ @Contract(pure = true)
+ PreparedStatement unwrap() throws IllegalStateException;
+
+ /**
+ * Closes the {@code StatementBuilder} and releases any resources it holds.
+ *
+ * @throws SQLException if a database access error occurs
+ */
+ @Override
+ void close() throws SQLException;
+}
\ No newline at end of file
diff --git a/src/main/java/minevalley/core/api/database/Value.java b/src/main/java/minevalley/core/api/database/Value.java
deleted file mode 100644
index 880c2315..00000000
--- a/src/main/java/minevalley/core/api/database/Value.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package minevalley.core.api.database;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-@Getter
-@AllArgsConstructor
-public final class Value {
-
- private final String column;
- private final Object value;
-}
\ No newline at end of file
diff --git a/src/main/java/minevalley/core/api/events/StatisticCreateEvent.java b/src/main/java/minevalley/core/api/events/StatisticCreateEvent.java
index 734c7a79..d63ac323 100644
--- a/src/main/java/minevalley/core/api/events/StatisticCreateEvent.java
+++ b/src/main/java/minevalley/core/api/events/StatisticCreateEvent.java
@@ -1,26 +1,20 @@
package minevalley.core.api.events;
import lombok.RequiredArgsConstructor;
-import minevalley.core.api.database.DatabaseEntry;
-import minevalley.core.api.database.Value;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@RequiredArgsConstructor
public class StatisticCreateEvent extends Event {
- public static final HandlerList HANDLER_LIST = new HandlerList();
+ // TODO 29.12.2024: recently removed DatabaseEntry object due to rework of database util might not work anymore (StatisticCreateEvent)
- private final DatabaseEntry entry;
+ public static final HandlerList HANDLER_LIST = new HandlerList();
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
- public void setStatistic(String key, double value) {
- entry.changeValue(new Value(key, value));
- }
-
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
diff --git a/src/main/java/minevalley/core/api/users/OnTimeHandler.java b/src/main/java/minevalley/core/api/users/OnTimeHandler.java
index 3fd9351d..3d0d9e63 100644
--- a/src/main/java/minevalley/core/api/users/OnTimeHandler.java
+++ b/src/main/java/minevalley/core/api/users/OnTimeHandler.java
@@ -1,7 +1,6 @@
package minevalley.core.api.users;
import lombok.Setter;
-import minevalley.core.api.database.Value;
import java.time.LocalDate;
import java.util.Map;