Skip to content

Commit

Permalink
rework database
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier committed Dec 31, 2024
1 parent 1a41607 commit a2fcef7
Show file tree
Hide file tree
Showing 4 changed files with 608 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/minevalley/core/api/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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.StatementBuilder;
import minevalley.core.api.discord.EmbeddedMessage;
import minevalley.core.api.discord.Webhook;
import minevalley.core.api.economy.BankAccount;
Expand Down Expand Up @@ -55,6 +56,7 @@
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 org.jetbrains.annotations.Contract;

Expand Down Expand Up @@ -174,6 +176,11 @@ public static BukkitTask runAsyncTaskPeriodically(long delay, long period, @Nonn
return server.runAsyncTaskPeriodically(delay, period, task);
}

@Nonnull
public static StatementBuilder prepareSQL(@Nonnull @Language("SQL") String sql) {
return server.prepareSQL(sql);
}

/**
* Registers an event listener.
*
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/minevalley/core/api/CoreServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +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.StatementBuilder;
import minevalley.core.api.discord.EmbeddedMessage;
import minevalley.core.api.discord.Webhook;
import minevalley.core.api.economy.BankAccount;
Expand Down Expand Up @@ -51,6 +52,7 @@
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;
Expand Down Expand Up @@ -80,6 +82,9 @@ public interface CoreServer {
@Nonnull
BukkitTask runAsyncTaskPeriodically(long delay, long period, @Nonnull Runnable runnable) throws IllegalArgumentException;

@Nonnull
StatementBuilder prepareSQL(@Nonnull @Language("SQL") String sql);

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;
Expand Down
207 changes: 207 additions & 0 deletions src/main/java/minevalley/core/api/database/ColumnType.java
Original file line number Diff line number Diff line change
@@ -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 {

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code BIT}.
*/
BIT(-7),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code TINYINT}.
*/
TINYINT(-6),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code SMALLINT}.
*/
SMALLINT(5),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code INTEGER}.
*/
INTEGER(4),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code BIGINT}.
*/
BIGINT(-5),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code FLOAT}.
*/
FLOAT(6),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code REAL}.
*/
REAL(7),


/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code DOUBLE}.
*/
DOUBLE(8),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code NUMERIC}.
*/
NUMERIC(2),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code DECIMAL}.
*/
DECIMAL(3),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code CHAR}.
*/
CHAR(1),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code VARCHAR}.
*/
VARCHAR(12),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code LONGVARCHAR}.
*/
LONGVARCHAR(-1),


/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code DATE}.
*/
DATE(91),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code TIME}.
*/
TIME(92),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code TIMESTAMP}.
*/
TIMESTAMP(93),


/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code BINARY}.
*/
BINARY(-2),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code VARBINARY}.
*/
VARBINARY(-3),

/**
* <P>The constant in the Java programming language, sometimes referred
* to as a type code, that identifies the generic SQL type
* {@code LONGVARBINARY}.
*/
LONGVARBINARY(-4),

/**
* <P>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;
}
Loading

0 comments on commit a2fcef7

Please sign in to comment.