void saveObject(T object, File directory, String fileName) {
- if (directory.mkdirs()) {
- log.info("Creating data folders...");
- }
- try (FileWriter writer = new FileWriter(new File(directory, fileName + ".json"))) {
- writer.write(GSON.toJson(object));
- } catch (IOException e) {
- log.warning("Failed to save object: " + e.getMessage());
- }
- }
-
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/MySQLTemplate.java b/src/main/java/de/codeblocksmc/codelib/MySQLTemplate.java
deleted file mode 100644
index 108ccfe..0000000
--- a/src/main/java/de/codeblocksmc/codelib/MySQLTemplate.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package de.codeblocksmc.codelib;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.util.logging.Logger;
-
-
-/**
- * Template class for creating MySQL connections.
- * This class provides methods for connecting to a MySQL database and checking the connection status.
- * It works in conjunction with {@link Logger} for logging any issues or errors during the connection process.
- * This is commonly used in Bukkit and Paper plugins for logging database-related activities.
- *
- * @author JustCody
- * @version 1.0
- */
-@Deprecated(forRemoval = true)
-public class MySQLTemplate {
-
- // The connection object to the MySQL database
- public Connection conn;
-
- // Logger for logging messages related to the connection
- public final Logger log;
-
- // MySQL connection details
- private final String host;
- private final int port;
- private final String database;
- private final String user;
- private final String password;
-
- /**
- * Constructor for initializing the MySQL connection template.
- *
- * @param log {@link Logger} of the plugin, typically used to log connection issues.
- * @param host Hostname of the MySQL server (e.g., "localhost").
- * @param port Port of the MySQL server. Default is 3306.
- * @param database Name of the MySQL database to connect to.
- * @param user Username to authenticate with the MySQL server.
- * @param password Password for the given username.
- */
- public MySQLTemplate(Logger log, String host, int port, String database, String user, String password) {
- this.log = log;
- this.host = host;
- this.port = port;
- this.database = database;
- this.user = user;
- this.password = password;
- }
-
- /**
- * Establishes a connection to the MySQL server and creates a {@link Connection} object.
- * This method loads the MySQL JDBC driver, attempts to connect to the database,
- * and logs any exceptions if the connection fails.
- */
- public void connect() {
- final String DB_NAME = "jdbc:mysql://"+host+":"+port+"/"+database+"?useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true";
-
- try {
- // Load MySQL JDBC driver class
- Class.forName("com.mysql.cj.jdbc.Driver");
-
- // Establish a connection using the provided connection details
- conn = DriverManager.getConnection(DB_NAME, user, password);
-
- } catch (Exception ex) {
- // Log any exception that occurs during the connection process
- log.warning("MySQL connection failed: " + ex.getMessage());
- }
- }
-
- /**
- * Checks the current MySQL connection to verify if it is still open and valid.
- * If the connection is closed or null, this method will attempt to reconnect using {@link MySQLTemplate#connect()}.
- */
- public void checkConnection() {
- try {
- if (conn == null || conn.isClosed()) {
- // Attempt to reconnect if the connection is null or closed
- connect();
- }
- } catch (SQLException e) {
- // Log any exceptions encountered while checking the connection status
- log.warning("MySQL connection check failed: " + e.getMessage());
- }
- }
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/MySQLTemplateVelocity.java b/src/main/java/de/codeblocksmc/codelib/MySQLTemplateVelocity.java
deleted file mode 100644
index 557b7a2..0000000
--- a/src/main/java/de/codeblocksmc/codelib/MySQLTemplateVelocity.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package de.codeblocksmc.codelib;
-
-import org.slf4j.Logger;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-
-
-/**
- * Template class for creating MySQL connections
- */
-@Deprecated(forRemoval = true)
-public class MySQLTemplateVelocity {
-
- public Connection conn;
- public final Logger log;
-
- private final String host;
- private final int port;
- private final String database;
- private final String user;
- private final String password;
-
- /**
- *
- * @param log {@link Logger} of the Plugin
- * @param host Hostname
- * @param port Port of the server. Default: 3306
- * @param database Database name
- * @param user Username
- * @param password Password
- */
- public MySQLTemplateVelocity(Logger log, String host, int port, String database, String user, String password) {
- this.log = log;
- this.host = host;
- this.port = port;
- this.database = database;
- this.user = user;
- this.password = password;
- }
-
- /**
- * Connects to the MySQL server and creates a {@link Connection} object
- */
- public void connect() {
- final String DB_NAME = "jdbc:mysql://"+host+":"+port+"/"+database+"?useJDBCCompliantTimezoneShift=true&useLeg" +
- "acyDatetimeCode=false&serverTimezone=UTC&autoReconnect=true";
-
- try {
- Class.forName("com.mysql.cj.jdbc.Driver"); //Gets the driver class
-
- conn = DriverManager.getConnection(DB_NAME, user, password); //Gets a connection to the database using the details you provided.
-
- }
- catch(Exception ex) {
- log.warn(ex.getMessage());
- }
- }
-
- /**
- * Checks if the connection is ok, otherwise it will try to {@link MySQLTemplate#connect()} to the server
- */
- public void checkConnection() {
- try {
- if (conn == null || conn.isClosed()) connect();
- } catch (SQLException e) {
- log.warn(e.getMessage());
- }
- }
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/PotionEffectWrapper.java b/src/main/java/de/codeblocksmc/codelib/PotionEffectWrapper.java
deleted file mode 100644
index 1eed5a8..0000000
--- a/src/main/java/de/codeblocksmc/codelib/PotionEffectWrapper.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package de.codeblocksmc.codelib;
-
-import lombok.Getter;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-
-@Getter
-@Deprecated(forRemoval = true)
-public class PotionEffectWrapper {
- private final String type;
- private final int duration;
- private final int amplifier;
-
- public PotionEffectWrapper(String type, int duration, int amplifier) {
- this.type = type;
- this.duration = duration;
- this.amplifier = amplifier;
- }
-
-
- public static PotionEffect fromWrapper(PotionEffectWrapper w) {
- return new PotionEffect(PotionEffectType.getByName(w.getType()), w.getDuration() * 20, w.getAmplifier());
- }
-
- public static PotionEffectWrapper fromBukkit(PotionEffect e) {
- return new PotionEffectWrapper(e.getType().getKey().getKey(), e.getDuration() / 20, e.getAmplifier());
- }
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/ServerConnector.java b/src/main/java/de/codeblocksmc/codelib/ServerConnector.java
deleted file mode 100644
index a830db3..0000000
--- a/src/main/java/de/codeblocksmc/codelib/ServerConnector.java
+++ /dev/null
@@ -1,121 +0,0 @@
-package de.codeblocksmc.codelib;
-
-import de.simonsator.partyandfriends.spigot.api.pafplayers.PAFPlayerManager;
-import de.simonsator.partyandfriends.spigot.api.party.PartyManager;
-import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
-import org.bukkit.entity.Player;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * This class handles the connection of players to available servers, taking into account party-related restrictions.
- * It ensures that players cannot join a game while being in a party, unless they are the party leader.
- * The class communicates with BungeeCord via the {@link BungeeChannelApi} to search for available servers and connect players.
- *
- * It also integrates with the PartyAndFriends plugin to check if the player is in a party and if they are the leader.
- * If the player is in a party but not the leader, they will not be able to join the server.
- *
- * This class operates asynchronously, querying the BungeeCord server list and checking for server availability.
- *
- * @author JustCody
- * @version 1.0
- */
-@Deprecated(forRemoval = true)
-public class ServerConnector {
-
- // Prefix that is used for messages sent to players
- private final String prefix;
-
- // The plugin instance used for API calls and scheduling tasks
- private final JavaPlugin plugin;
-
- /**
- * Factory method for creating a new {@link ServerConnector} instance.
- *
- * @param plugin The plugin instance that will be used for task scheduling and API calls.
- * @param prefix The prefix to be used in messages sent to players.
- * @return A new {@link ServerConnector} instance.
- */
- public static ServerConnector of(JavaPlugin plugin, String prefix) {
- return new ServerConnector(plugin, prefix);
- }
-
- /**
- * Constructor for initializing the ServerConnector with a plugin and message prefix.
- *
- * @param plugin The plugin instance that will be used for task scheduling and API calls.
- * @param prefix The prefix to be used in messages sent to players.
- */
- protected ServerConnector(JavaPlugin plugin, String prefix) {
- this.prefix = prefix;
- this.plugin = plugin;
- }
-
- /**
- * Attempts to connect a player to a server, checking for available servers that match the provided server name.
- * It checks if the player is in a party and ensures that they are the party leader before allowing the connection.
- *
- * The method will search for a server that is less than 30 players, and if found, it will connect the player to it.
- *
- * @param player The player to be connected.
- * @param servername The name of the server to connect to (partial match).
- */
- public void connect(Player player, String servername) {
- // Check if the player is in a party and not the leader
- if (PartyManager.getInstance().getParty(PAFPlayerManager.getInstance().getPlayer(player.getUniqueId())) != null &&
- !PartyManager.getInstance().getParty(PAFPlayerManager.getInstance().getPlayer(player.getUniqueId())).getLeader().equals(PAFPlayerManager.getInstance().getPlayer(player.getUniqueId()))) {
- player.sendMessage("§cSorry, you can't join a game while being in a party.");
- return;
- }
-
- // Notify the player that the search for a free server is starting
- player.sendMessage(prefix + "§aLooking for free server in §e" + servername + "§a...");
-
- // Get the BungeeChannelApi instance to interact with BungeeCord
- BungeeChannelApi api = BungeeChannelApi.of(plugin);
-
- // Run the connection task asynchronously
- new BukkitRunnable() {
-
- @Override
- public void run() {
- // Fetch the list of available servers
- api.getServers().whenComplete((result, error) -> {
- AtomicBoolean found = new AtomicBoolean(false);
-
- // Loop through the servers and check if one matches the specified servername
- for (String server : result) {
- if (!server.startsWith(servername)) continue;
-
- // Get the player count for the current server
- api.getPlayerCount(server).whenComplete((count, err) -> {
- // If the server has less than 30 players, connect the player
- if (count < 30) {
- api.connect(player, server);
- found.set(true);
- }
- });
- }
-
- // Notify the player if no free server was found after the search
- new BukkitRunnable() {
- @Override
- public void run() {
- try {
- if (!found.get()) {
- player.sendMessage(prefix + "§7We could not find a free server. Sorry for the inconvenience!");
- }
- } catch (Exception e) {
- // Handle any errors when notifying the player
- plugin.getLogger().warning(e.getMessage());
- }
- }
- }.runTaskLater(plugin, 5); // Delay to allow for the server search to complete
- });
- }
-
- }.runTaskLater(plugin, 0); // Run the task immediately
- }
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/TimeUtil.java b/src/main/java/de/codeblocksmc/codelib/TimeUtil.java
deleted file mode 100644
index aa5dfde..0000000
--- a/src/main/java/de/codeblocksmc/codelib/TimeUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package de.codeblocksmc.codelib;
-
-import java.time.LocalDateTime;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-@Deprecated(forRemoval = true)
-public class TimeUtil {
- public static LocalDateTime addTimeSpan(String timeSpan) {
- LocalDateTime now = LocalDateTime.now();
- return addTimeSpan(now, timeSpan);
- }
-
- public static LocalDateTime addTimeSpan(LocalDateTime dateTime, String timeSpan) {
- Pattern pattern = Pattern.compile("(\\d+)([yMwdhms])");
- Matcher matcher = pattern.matcher(timeSpan);
-
- while (matcher.find()) {
- int value = Integer.parseInt(matcher.group(1));
- char unit = matcher.group(2).charAt(0);
-
- switch (unit) {
- case 'y':
- dateTime = dateTime.plusYears(value);
- break;
- case 'M':
- dateTime = dateTime.plusMonths(value);
- break;
- case 'w':
- dateTime = dateTime.plusWeeks(value); // Wochen in Tage umrechnen
- break;
- case 'd':
- dateTime = dateTime.plusDays(value);
- break;
- case 'h':
- dateTime = dateTime.plusHours(value);
- break;
- case 'm':
- dateTime = dateTime.plusMinutes(value);
- break;
- case 's':
- dateTime = dateTime.plusSeconds(value);
- break;
- default:
- throw new IllegalArgumentException("Ungültige Zeitspanne: " + unit);
- }
- }
-
- return dateTime;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/de/codeblocksmc/codelib/api/CodeNick.java b/src/main/java/de/codeblocksmc/codelib/api/CodeNick.java
new file mode 100644
index 0000000..026d28a
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/CodeNick.java
@@ -0,0 +1,67 @@
+package de.codeblocksmc.codelib.api;
+
+import com.destroystokyo.paper.profile.PlayerProfile;
+import com.destroystokyo.paper.profile.ProfileProperty;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import net.kyori.adventure.text.Component;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.WeakHashMap;
+
+public class CodeNick {
+ private static final WeakHashMap instances = new WeakHashMap<>();
+
+ private SaveMethod saveMethod;
+
+ public synchronized static CodeNick of(Plugin plugin, SaveMethod method) {
+ CodeNick c = new CodeNick();
+ instances.put(plugin, c);
+ c.saving(method);
+ return c;
+ }
+
+ public CodeNick saving(SaveMethod method) {
+ saveMethod = method;
+ return this;
+ }
+
+ public boolean nickPlayer(Player player, String targetName) {
+ player.displayName(Component.text(targetName));
+
+ PlayerProfile playerProfile = player.getPlayerProfile();
+ try {
+ URL url_0 = new URL("https://api.mojang.com/users/profiles/minecraft/" + targetName);
+
+ InputStreamReader reader_0 = new InputStreamReader(url_0.openStream());
+
+ String uuid = JsonParser.parseReader(reader_0).getAsJsonObject().get("id").getAsString();
+
+ URL url_1 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid + "?unsigned=false");
+
+ InputStreamReader reader_1 = new InputStreamReader(url_1.openStream());
+
+ JsonObject properties = JsonParser.parseReader(reader_1).getAsJsonObject().get("properties").getAsJsonArray().get(0).getAsJsonObject();
+
+ String value = properties.get("value").getAsString();
+ String signature = properties.get("signature").getAsString();
+
+ playerProfile.setProperty(new ProfileProperty("textures", value, signature));
+ player.setPlayerProfile(playerProfile);
+
+ return true;
+ } catch (IllegalStateException | IOException | NullPointerException ignored) {
+ return false;
+ }
+ }
+
+ public enum SaveMethod {
+ INTERNAL,
+ MYSQL,
+ SQLITE
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/codeblocksmc/codelib/chat/AdvancedTabCompleter.java b/src/main/java/de/codeblocksmc/codelib/api/chat/AdvancedTabCompleter.java
similarity index 95%
rename from src/main/java/de/codeblocksmc/codelib/chat/AdvancedTabCompleter.java
rename to src/main/java/de/codeblocksmc/codelib/api/chat/AdvancedTabCompleter.java
index 386efb8..253790b 100644
--- a/src/main/java/de/codeblocksmc/codelib/chat/AdvancedTabCompleter.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/chat/AdvancedTabCompleter.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.chat;
+package de.codeblocksmc.codelib.api.chat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/de/codeblocksmc/codelib/chat/ChatUtil.java b/src/main/java/de/codeblocksmc/codelib/api/chat/ChatUtil.java
similarity index 97%
rename from src/main/java/de/codeblocksmc/codelib/chat/ChatUtil.java
rename to src/main/java/de/codeblocksmc/codelib/api/chat/ChatUtil.java
index e1af18a..cc6c64b 100644
--- a/src/main/java/de/codeblocksmc/codelib/chat/ChatUtil.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/chat/ChatUtil.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.chat;
+package de.codeblocksmc.codelib.api.chat;
public class ChatUtil {
public static String getColorCode(int level) {
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLib.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLib.java
new file mode 100644
index 0000000..cd450b0
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLib.java
@@ -0,0 +1,26 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+
+import lombok.Getter;
+import org.bukkit.plugin.Plugin;
+
+import java.util.WeakHashMap;
+
+public class DBLib {
+ private static WeakHashMap instances = new WeakHashMap<>();
+
+ @Getter
+ private DBLibConfig config;
+
+ public DBLib(DBLibConfig config) {
+ this.config = config;
+ }
+
+
+ public static synchronized DBLib of(Plugin plugin, DBLibConfig config) {
+ if (instances.containsKey(plugin)) return instances.get(plugin);
+ DBLib lib = new DBLib(config);
+ instances.put(plugin, lib);
+ return lib;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLibConfig.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLibConfig.java
new file mode 100644
index 0000000..aabdef3
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBLibConfig.java
@@ -0,0 +1,14 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+import lombok.Builder;
+
+@Builder
+public class DBLibConfig {
+ private StorageProvider provider;
+ private String host;
+ private int port;
+ private String username;
+ private String password;
+ private String databaseName;
+
+}
\ No newline at end of file
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/DBSchema.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBSchema.java
new file mode 100644
index 0000000..552ee6a
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBSchema.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+public class DBSchema {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/DBTable.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBTable.java
new file mode 100644
index 0000000..0a45cde
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/DBTable.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+public class DBTable {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/DatabaseObject.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/DatabaseObject.java
new file mode 100644
index 0000000..d32e7a3
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/DatabaseObject.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+public class DatabaseObject {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/StorageProvider.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/StorageProvider.java
new file mode 100644
index 0000000..08683dc
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/StorageProvider.java
@@ -0,0 +1,11 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+public enum StorageProvider {
+ MYSQL,
+ MARIADB,
+ MSSQL,
+ POSTGRESQL,
+ ORACLE_SQL,
+ H2,
+ SQLITE
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/api/databsae/TableColumn.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/TableColumn.java
new file mode 100644
index 0000000..3b3a845
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/TableColumn.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.databsae;
+
+public class TableColumn {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/databsae/MSSQLTemplate.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MSSQLTemplate.java
similarity index 94%
rename from src/main/java/de/codeblocksmc/codelib/databsae/MSSQLTemplate.java
rename to src/main/java/de/codeblocksmc/codelib/api/databsae/template/MSSQLTemplate.java
index cc7b197..5430b1f 100644
--- a/src/main/java/de/codeblocksmc/codelib/databsae/MSSQLTemplate.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MSSQLTemplate.java
@@ -1,5 +1,6 @@
-package de.codeblocksmc.codelib.databsae;
+package de.codeblocksmc.codelib.api.databsae.template;
+import de.codeblocksmc.codelib.api.databsae.DatabaseObject;
import lombok.Getter;
import java.sql.Connection;
diff --git a/src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplate.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplate.java
similarity index 96%
rename from src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplate.java
rename to src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplate.java
index 30e743f..0b0f8ab 100644
--- a/src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplate.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplate.java
@@ -1,4 +1,6 @@
-package de.codeblocksmc.codelib.databsae;
+package de.codeblocksmc.codelib.api.databsae.template;
+
+import de.codeblocksmc.codelib.api.databsae.DatabaseObject;
import java.sql.Connection;
import java.sql.DriverManager;
diff --git a/src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplateVelocity.java b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplateVelocity.java
similarity index 94%
rename from src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplateVelocity.java
rename to src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplateVelocity.java
index c61c630..a27025b 100644
--- a/src/main/java/de/codeblocksmc/codelib/databsae/MySQLTemplateVelocity.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/databsae/template/MySQLTemplateVelocity.java
@@ -1,5 +1,6 @@
-package de.codeblocksmc.codelib.databsae;
+package de.codeblocksmc.codelib.api.databsae.template;
+import de.codeblocksmc.codelib.api.databsae.DatabaseObject;
import org.slf4j.Logger;
import java.sql.Connection;
diff --git a/src/main/java/de/codeblocksmc/codelib/api/game/Game.java b/src/main/java/de/codeblocksmc/codelib/api/game/Game.java
new file mode 100644
index 0000000..192329b
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/game/Game.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.game;
+
+public class Game {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/locations/LocUtil.java b/src/main/java/de/codeblocksmc/codelib/api/locations/LocUtil.java
similarity index 99%
rename from src/main/java/de/codeblocksmc/codelib/locations/LocUtil.java
rename to src/main/java/de/codeblocksmc/codelib/api/locations/LocUtil.java
index ac11eb5..0a9baee 100644
--- a/src/main/java/de/codeblocksmc/codelib/locations/LocUtil.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/locations/LocUtil.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.locations;
+package de.codeblocksmc.codelib.api.locations;
import org.bukkit.Bukkit;
import org.bukkit.Location;
diff --git a/src/main/java/de/codeblocksmc/codelib/locations/LocationSection.java b/src/main/java/de/codeblocksmc/codelib/api/locations/LocationSection.java
similarity index 98%
rename from src/main/java/de/codeblocksmc/codelib/locations/LocationSection.java
rename to src/main/java/de/codeblocksmc/codelib/api/locations/LocationSection.java
index 5e86950..47e691e 100644
--- a/src/main/java/de/codeblocksmc/codelib/locations/LocationSection.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/locations/LocationSection.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.locations;
+package de.codeblocksmc.codelib.api.locations;
import lombok.Getter;
import org.bukkit.Location;
diff --git a/src/main/java/de/codeblocksmc/codelib/locations/LocationWrapper.java b/src/main/java/de/codeblocksmc/codelib/api/locations/LocationWrapper.java
similarity index 98%
rename from src/main/java/de/codeblocksmc/codelib/locations/LocationWrapper.java
rename to src/main/java/de/codeblocksmc/codelib/api/locations/LocationWrapper.java
index d161785..b2733c7 100644
--- a/src/main/java/de/codeblocksmc/codelib/locations/LocationWrapper.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/locations/LocationWrapper.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.locations;
+package de.codeblocksmc.codelib.api.locations;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/de/codeblocksmc/codelib/api/spigot/CodeNick.java b/src/main/java/de/codeblocksmc/codelib/api/spigot/CodeNick.java
new file mode 100644
index 0000000..f56888c
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/spigot/CodeNick.java
@@ -0,0 +1,4 @@
+package de.codeblocksmc.codelib.api.spigot;
+
+public class CodeNick {
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/api/util/BungeeChannelApi.java b/src/main/java/de/codeblocksmc/codelib/api/util/BungeeChannelApi.java
new file mode 100644
index 0000000..0a719a9
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/api/util/BungeeChannelApi.java
@@ -0,0 +1,545 @@
+/**
+ * https://github.com/leonardosnt/bungeechannelapi
+ *
+ * Copyright (C) 2017 leonardosnt
+ * Licensed under the MIT License. See LICENSE file in the project root for full license information.
+ */
+
+package de.codeblocksmc.codelib.api.util;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayDeque;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Queue;
+import java.util.WeakHashMap;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiFunction;
+
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.messaging.Messenger;
+import org.bukkit.plugin.messaging.PluginMessageListener;
+
+import com.google.common.collect.Iterables;
+import com.google.common.io.ByteArrayDataInput;
+import com.google.common.io.ByteArrayDataOutput;
+import com.google.common.io.ByteStreams;
+
+/**
+ * Documentation copied from https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
+ *
+ * @author leonardosnt (leonrdsnt@gmail.com)
+ * @see https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
+ */
+public class BungeeChannelApi {
+
+ private static WeakHashMap registeredInstances = new WeakHashMap<>();
+
+ private final PluginMessageListener messageListener;
+ private final Plugin plugin;
+ private final Map>> callbackMap;
+
+ private Map forwardListeners;
+ private ForwardConsumer globalForwardListener;
+
+ /**
+ * Get or create new BungeeChannelApi instance
+ *
+ * @param plugin the plugin instance.
+ * @return the BungeeChannelApi instance for the {@code plugin}
+ * @throws NullPointerException if the {@code plugin} is {@code null}
+ */
+ public synchronized static BungeeChannelApi of(Plugin plugin) {
+ return registeredInstances.compute(plugin, (k, v) -> {
+ if (v == null) v = new BungeeChannelApi(plugin);
+ return v;
+ });
+ }
+
+ public BungeeChannelApi(Plugin plugin) {
+ this.plugin = Objects.requireNonNull(plugin, "plugin cannot be null");
+ this.callbackMap = new HashMap<>();
+
+ // Prevent dev's from registering multiple channel listeners,
+ // by unregistering the old instance.
+ synchronized (registeredInstances) {
+ registeredInstances.compute(plugin, (k, oldInstance) -> {
+ if (oldInstance != null) oldInstance.unregister();
+ return this;
+ });
+ }
+
+ this.messageListener = this::onPluginMessageReceived;
+
+ Messenger messenger = Bukkit.getServer().getMessenger();
+ messenger.registerOutgoingPluginChannel(plugin, "BungeeCord");
+ messenger.registerIncomingPluginChannel(plugin, "BungeeCord", messageListener);
+ }
+
+ /**
+ * Set a global listener for all 'forwarded' messages.
+ *
+ * @param globalListener the listener
+ * @see https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
+ */
+ public void registerForwardListener(ForwardConsumer globalListener) {
+ this.globalForwardListener = globalListener;
+ }
+
+ /**
+ * Set a listener for all 'forwarded' messages in a specific subchannel.
+ *
+ * @param channelName the subchannel name
+ * @param listener the listener
+ * @see https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
+ */
+ public void registerForwardListener(String channelName, ForwardConsumer listener) {
+ if (forwardListeners == null) {
+ forwardListeners = new HashMap<>();
+ }
+ synchronized (forwardListeners) {
+ forwardListeners.put(channelName, listener);
+ }
+ }
+
+ /**
+ * Get the amount of players on a certain server, or on ALL the servers.
+ *
+ * @param serverName the server name of the server to get the player count of, or ALL to get the global player count
+ * @return A {@link CompletableFuture} that, when completed, will return
+ * the amount of players on a certain server, or on ALL the servers.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture getPlayerCount(String serverName) {
+ Player player = getFirstPlayer();
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("PlayerCount-" + serverName, this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("PlayerCount");
+ output.writeUTF(serverName);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Get a list of players connected on a certain server, or on ALL the servers.
+ *
+ * @param serverName the name of the server to get the list of connected players, or ALL for global online player list
+ * @return A {@link CompletableFuture} that, when completed, will return a
+ * list of players connected on a certain server, or on ALL the servers.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture> getPlayerList(String serverName) {
+ Player player = getFirstPlayer();
+ CompletableFuture> future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("PlayerList-" + serverName, this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("PlayerList");
+ output.writeUTF(serverName);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Get a list of server name strings, as defined in BungeeCord's config.yml.
+ *
+ * @return A {@link CompletableFuture} that, when completed, will return a
+ * list of server name strings, as defined in BungeeCord's config.yml.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture> getServers() {
+ Player player = getFirstPlayer();
+ CompletableFuture> future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("GetServers", this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("GetServers");
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Connects a player to said subserver.
+ *
+ * @param player the player you want to teleport.
+ * @param serverName the name of server to connect to, as defined in BungeeCord config.yml.
+ */
+ public void connect(Player player, String serverName) {
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("Connect");
+ output.writeUTF(serverName);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ /**
+ * Connect a named player to said subserver.
+ *
+ * @param playerName name of the player to teleport.
+ * @param server name of server to connect to, as defined in BungeeCord config.yml.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public void connectOther(String playerName, String server) {
+ Player player = getFirstPlayer();
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+
+ output.writeUTF("ConnectOther");
+ output.writeUTF(playerName);
+ output.writeUTF(server);
+
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ /**
+ * Get the (real) IP of a player.
+ *
+ * @param player The player you wish to get the IP of.
+ * @return A {@link CompletableFuture} that, when completed, will return the (real) IP of {@code player}.
+ */
+ public CompletableFuture getIp(Player player) {
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("IP", this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("IP");
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Send a message (as in, a chat message) to the specified player.
+ *
+ * @param playerName the name of the player to send the chat message.
+ * @param message the message to send to the player.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public void sendMessage(String playerName, String message) {
+ Player player = getFirstPlayer();
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+
+ output.writeUTF("Message");
+ output.writeUTF(playerName);
+ output.writeUTF(message);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ /**
+ * Get this server's name, as defined in BungeeCord's config.yml
+ *
+ * @return A {@link CompletableFuture} that, when completed, will return
+ * the {@code server's} name, as defined in BungeeCord's config.yml.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture getServer() {
+ Player player = getFirstPlayer();
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("GetServer", this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("GetServer");
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Request the UUID of this player.
+ *
+ * @param player The player whose UUID you requested.
+ * @return A {@link CompletableFuture} that, when completed, will return the UUID of {@code player}.
+ */
+ public CompletableFuture getUUID(Player player) {
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("UUID", this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("UUID");
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Request the UUID of any player connected to the BungeeCord proxy.
+ *
+ * @param playerName the name of the player whose UUID you would like.
+ * @return A {@link CompletableFuture} that, when completed, will return the UUID of {@code playerName}.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture getUUID(String playerName) {
+ Player player = getFirstPlayer();
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("UUIDOther-" + playerName, this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("UUIDOther");
+ output.writeUTF(playerName);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Request the IP of any server on this proxy.
+ *
+ * @param serverName the name of the server.
+ * @return A {@link CompletableFuture} that, when completed, will return the requested ip.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public CompletableFuture getServerIp(String serverName) {
+ Player player = getFirstPlayer();
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("ServerIP-" + serverName, this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("ServerIP");
+ output.writeUTF(serverName);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ return future;
+ }
+
+ /**
+ * Kick any player on this proxy.
+ *
+ * @param playerName the name of the player.
+ * @param kickMessage the reason the player is kicked with.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public void kickPlayer(String playerName, String kickMessage) {
+ Player player = getFirstPlayer();
+ CompletableFuture future = new CompletableFuture<>();
+
+ synchronized (callbackMap) {
+ callbackMap.compute("KickPlayer", this.computeQueueValue(future));
+ }
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("KickPlayer");
+ output.writeUTF(playerName);
+ output.writeUTF(kickMessage);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ /**
+ * Send a custom plugin message to said server. This is one of the most useful channels ever.
+ * Remember, the sending and receiving server(s) need to have a player online.
+ *
+ * @param server the name of the server to send to,
+ * ALL to send to every server (except the one sending the plugin message),
+ * or ONLINE to send to every server that's online (except the one sending the plugin message).
+ *
+ * @param channelName Subchannel for plugin usage.
+ * @param data data to send.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public void forward(String server, String channelName, byte[] data) {
+ Player player = getFirstPlayer();
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("Forward");
+ output.writeUTF(server);
+ output.writeUTF(channelName);
+ output.writeShort(data.length);
+ output.write(data);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ /**
+ * Send a custom plugin message to specific player.
+ *
+ * @param playerName the name of the player to send to.
+ * @param channelName Subchannel for plugin usage.
+ * @param data data to send.
+ * @throws IllegalArgumentException if there is no players online.
+ */
+ public void forwardToPlayer(String playerName, String channelName, byte[] data) {
+ Player player = getFirstPlayer();
+
+ ByteArrayDataOutput output = ByteStreams.newDataOutput();
+ output.writeUTF("ForwardToPlayer");
+ output.writeUTF(playerName);
+ output.writeUTF(channelName);
+ output.writeShort(data.length);
+ output.write(data);
+ player.sendPluginMessage(this.plugin, "BungeeCord", output.toByteArray());
+ }
+
+ @SuppressWarnings("unchecked")
+ private void onPluginMessageReceived(String channel, Player player, byte[] message) {
+ if (!channel.equalsIgnoreCase("BungeeCord")) return;
+
+ ByteArrayDataInput input = ByteStreams.newDataInput(message);
+ String subchannel = input.readUTF();
+
+ synchronized (callbackMap) {
+ Queue> callbacks;
+
+ if (subchannel.equals("PlayerCount") || subchannel.equals("PlayerList") ||
+ subchannel.equals("UUIDOther") || subchannel.equals("ServerIP")) {
+ String identifier = input.readUTF(); // Server/player name
+ callbacks = callbackMap.get(subchannel + "-" + identifier);
+
+ if (callbacks == null || callbacks.isEmpty()) {
+ return;
+ }
+
+ CompletableFuture> callback = callbacks.poll();
+
+ try {
+ switch (subchannel) {
+ case "PlayerCount":
+ ((CompletableFuture) callback).complete(Integer.valueOf(input.readInt()));
+ break;
+
+ case "PlayerList":
+ ((CompletableFuture>) callback).complete(Arrays.asList(input.readUTF().split(", ")));
+ break;
+
+ case "UUIDOther":
+ ((CompletableFuture) callback).complete(input.readUTF());
+ break;
+
+ case "ServerIP": {
+ String ip = input.readUTF();
+ int port = input.readUnsignedShort();
+ ((CompletableFuture) callback).complete(new InetSocketAddress(ip, port));
+ break;
+ }
+ }
+ } catch(Exception ex) {
+ callback.completeExceptionally(ex);
+ }
+
+ return;
+ }
+
+ callbacks = callbackMap.get(subchannel);
+
+ if (callbacks == null) {
+ short dataLength = input.readShort();
+ byte[] data = new byte[dataLength];
+ input.readFully(data);
+
+ if (globalForwardListener != null) {
+ globalForwardListener.accept(subchannel, player, data);
+ }
+
+ if (forwardListeners != null) {
+ synchronized (forwardListeners) {
+ ForwardConsumer listener = forwardListeners.get(subchannel);
+ if (listener != null) {
+ listener.accept(subchannel, player, data);
+ }
+ }
+ }
+
+ return;
+ }
+
+ if (callbacks.isEmpty()) {
+ return;
+ }
+
+ final CompletableFuture> callback = callbacks.poll();
+
+ try {
+ switch (subchannel) {
+ case "GetServers":
+ ((CompletableFuture>) callback).complete(Arrays.asList(input.readUTF().split(", ")));
+ break;
+
+ case "GetServer":
+ case "UUID":
+ ((CompletableFuture) callback).complete(input.readUTF());
+ break;
+
+ case "IP": {
+ String ip = input.readUTF();
+ int port = input.readInt();
+ ((CompletableFuture) callback).complete(new InetSocketAddress(ip, port));
+ break;
+ }
+
+ default:
+ break;
+ }
+ } catch(Exception ex) {
+ callback.completeExceptionally(ex);
+ }
+ }
+ }
+
+ /**
+ * Unregister message channels.
+ */
+ public void unregister() {
+ Messenger messenger = Bukkit.getServer().getMessenger();
+ messenger.unregisterIncomingPluginChannel(plugin, "BungeeCord", messageListener);
+ messenger.unregisterOutgoingPluginChannel(plugin);
+ callbackMap.clear();
+ }
+
+ private BiFunction>, Queue>> computeQueueValue(CompletableFuture> queueValue) {
+ return (key, value) -> {
+ if (value == null) value = new ArrayDeque>();
+ value.add(queueValue);
+ return value;
+ };
+ }
+
+ private Player getFirstPlayer() {
+ /**
+ * if Bukkit Version < 1.7.10 then Bukkit.getOnlinePlayers() will return
+ * a Player[] otherwise it'll return a Collection extends Player>.
+ */
+ Player firstPlayer = getFirstPlayer0(Bukkit.getOnlinePlayers());
+
+ if (firstPlayer == null) {
+ throw new IllegalArgumentException("Bungee Messaging Api requires at least one player to be online.");
+ }
+
+ return firstPlayer;
+ }
+
+ @SuppressWarnings("unused")
+ private Player getFirstPlayer0(Player[] playerArray) {
+ return playerArray.length > 0 ? playerArray[0] : null;
+ }
+
+ private Player getFirstPlayer0(Collection extends Player> playerCollection) {
+ return Iterables.getFirst(playerCollection, null);
+ }
+
+ @FunctionalInterface
+ public interface ForwardConsumer {
+ void accept(String channel, Player player, byte[] data);
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/codeblocksmc/codelib/util/JSONFileHelper.java b/src/main/java/de/codeblocksmc/codelib/api/util/JSONFileHelper.java
similarity index 98%
rename from src/main/java/de/codeblocksmc/codelib/util/JSONFileHelper.java
rename to src/main/java/de/codeblocksmc/codelib/api/util/JSONFileHelper.java
index a0509ae..bde66f9 100644
--- a/src/main/java/de/codeblocksmc/codelib/util/JSONFileHelper.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/util/JSONFileHelper.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.util;
+package de.codeblocksmc.codelib.api.util;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
diff --git a/src/main/java/de/codeblocksmc/codelib/util/ServerConnector.java b/src/main/java/de/codeblocksmc/codelib/api/util/ServerConnector.java
similarity index 94%
rename from src/main/java/de/codeblocksmc/codelib/util/ServerConnector.java
rename to src/main/java/de/codeblocksmc/codelib/api/util/ServerConnector.java
index 217cbc2..5a90a6c 100644
--- a/src/main/java/de/codeblocksmc/codelib/util/ServerConnector.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/util/ServerConnector.java
@@ -1,18 +1,21 @@
-package de.codeblocksmc.codelib.util;
+package de.codeblocksmc.codelib.api.util;
import de.simonsator.partyandfriends.spigot.api.pafplayers.PAFPlayerManager;
import de.simonsator.partyandfriends.spigot.api.party.PartyManager;
-import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
+import org.checkerframework.checker.units.qual.UnknownUnits;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* This class handles the connection of players to available servers, taking into account party-related restrictions.
* It ensures that players cannot join a game while being in a party, unless they are the party leader.
- * The class communicates with BungeeCord via the {@link BungeeChannelApi} to search for available servers and connect players.
+ * The class communicates with BungeeCord via the {@link de.codeblocksmc.codelib.api.util.BungeeChannelApi} to search for available servers and connect players.
*
* It also integrates with the PartyAndFriends plugin to check if the player is in a party and if they are the leader.
* If the player is in a party but not the leader, they will not be able to join the server.
diff --git a/src/main/java/de/codeblocksmc/codelib/util/TimeUtil.java b/src/main/java/de/codeblocksmc/codelib/api/util/TimeUtil.java
similarity index 97%
rename from src/main/java/de/codeblocksmc/codelib/util/TimeUtil.java
rename to src/main/java/de/codeblocksmc/codelib/api/util/TimeUtil.java
index 9ad1a69..9a4a2da 100644
--- a/src/main/java/de/codeblocksmc/codelib/util/TimeUtil.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/util/TimeUtil.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.util;
+package de.codeblocksmc.codelib.api.util;
import java.time.LocalDateTime;
import java.util.regex.Matcher;
diff --git a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManCmd.java b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCmd.java
similarity index 96%
rename from src/main/java/de/codeblocksmc/codelib/worldman/WorldManCmd.java
rename to src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCmd.java
index c795f48..d812c44 100644
--- a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManCmd.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCmd.java
@@ -1,8 +1,6 @@
-package de.codeblocksmc.codelib.worldman;
+package de.codeblocksmc.codelib.api.worldman;
import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.block.data.type.TNT;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
diff --git a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManCom.java b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCom.java
similarity index 92%
rename from src/main/java/de/codeblocksmc/codelib/worldman/WorldManCom.java
rename to src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCom.java
index 29b4b13..1e3833f 100644
--- a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManCom.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManCom.java
@@ -1,6 +1,6 @@
-package de.codeblocksmc.codelib.worldman;
+package de.codeblocksmc.codelib.api.worldman;
-import de.codeblocksmc.codelib.AdvancedTabCompleter;
+import de.codeblocksmc.codelib.api.chat.AdvancedTabCompleter;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
diff --git a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManager.java b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManager.java
similarity index 93%
rename from src/main/java/de/codeblocksmc/codelib/worldman/WorldManager.java
rename to src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManager.java
index b9935a2..dc8dbf1 100644
--- a/src/main/java/de/codeblocksmc/codelib/worldman/WorldManager.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/worldman/WorldManager.java
@@ -1,6 +1,5 @@
-package de.codeblocksmc.codelib.worldman;
+package de.codeblocksmc.codelib.api.worldman;
-import de.codeblocksmc.codelib.locations.LocationWrapper;
import lombok.Getter;
import org.bukkit.*;
import org.bukkit.permissions.Permission;
diff --git a/src/main/java/de/codeblocksmc/codelib/wrapping/EnchantmentWrapper.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/EnchantmentWrapper.java
similarity index 96%
rename from src/main/java/de/codeblocksmc/codelib/wrapping/EnchantmentWrapper.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/EnchantmentWrapper.java
index d1b9c0c..cc47985 100644
--- a/src/main/java/de/codeblocksmc/codelib/wrapping/EnchantmentWrapper.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/EnchantmentWrapper.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.wrapping;
+package de.codeblocksmc.codelib.api.wrapping;
import lombok.Getter;
diff --git a/src/main/java/de/codeblocksmc/codelib/wrapping/GuiBuilder.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/GuiBuilder.java
similarity index 77%
rename from src/main/java/de/codeblocksmc/codelib/wrapping/GuiBuilder.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/GuiBuilder.java
index 05f0244..395b3dc 100644
--- a/src/main/java/de/codeblocksmc/codelib/wrapping/GuiBuilder.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/GuiBuilder.java
@@ -1,6 +1,5 @@
-package de.codeblocksmc.codelib.wrapping;
+package de.codeblocksmc.codelib.api.wrapping;
-import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -26,20 +25,6 @@ public class GuiBuilder {
* @throws IllegalArgumentException If rows are less than 1 or greater than 6.
*/
public GuiBuilder(String title, int rows) {
- if (rows < 1 || rows > 6) {
- throw new IllegalArgumentException("Rows must be between 1 and 6.");
- }
- this.inv = Bukkit.createInventory(null, rows * 9, Component.text(title));
- }
-
- /**
- * Creates a chest GUI with the specified title and rows.
- *
- * @param title Title of the inventory as a {@link Component}.
- * @param rows Number of rows (1-6, each row contains 9 slots).
- * @throws IllegalArgumentException If rows are less than 1 or greater than 6.
- */
- public GuiBuilder(Component title, int rows) {
if (rows < 1 || rows > 6) {
throw new IllegalArgumentException("Rows must be between 1 and 6.");
}
@@ -54,26 +39,13 @@ public GuiBuilder(Component title, int rows) {
* @throws IllegalArgumentException If the inventory type cannot be viewed.
*/
public GuiBuilder(InventoryType type, String title) {
- if (type == null) {
- throw new IllegalArgumentException("Inventory type cannot be null.");
- }
- this.inv = Bukkit.createInventory(null, type, Component.text(title));
- }
-
- /**
- * Creates a GUI with the specified {@link InventoryType} and title.
- *
- * @param type The inventory type.
- * @param title The title of the inventory as a {@link Component}.
- * @throws IllegalArgumentException If the inventory type cannot be viewed.
- */
- public GuiBuilder(InventoryType type, Component title) {
if (type == null) {
throw new IllegalArgumentException("Inventory type cannot be null.");
}
this.inv = Bukkit.createInventory(null, type, title);
}
+
/**
* Sets an item in the specified slot.
*
diff --git a/src/main/java/de/codeblocksmc/codelib/wrapping/ItemBuilder.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemBuilder.java
similarity index 99%
rename from src/main/java/de/codeblocksmc/codelib/wrapping/ItemBuilder.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemBuilder.java
index 9ced3f4..3ecfd22 100644
--- a/src/main/java/de/codeblocksmc/codelib/wrapping/ItemBuilder.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemBuilder.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.wrapping;
+package de.codeblocksmc.codelib.api.wrapping;
import com.destroystokyo.paper.profile.PlayerProfile;
import net.kyori.adventure.text.Component;
diff --git a/src/main/java/de/codeblocksmc/codelib/wrapping/ItemWrapper.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemWrapper.java
similarity index 97%
rename from src/main/java/de/codeblocksmc/codelib/wrapping/ItemWrapper.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemWrapper.java
index ec12408..2e23d45 100644
--- a/src/main/java/de/codeblocksmc/codelib/wrapping/ItemWrapper.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/ItemWrapper.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.wrapping;
+package de.codeblocksmc.codelib.api.wrapping;
import lombok.Getter;
import lombok.Setter;
diff --git a/src/main/java/de/codeblocksmc/codelib/wrapping/PotionEffectWrapper.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/PotionEffectWrapper.java
similarity index 94%
rename from src/main/java/de/codeblocksmc/codelib/wrapping/PotionEffectWrapper.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/PotionEffectWrapper.java
index 51428b2..4e4fbbf 100644
--- a/src/main/java/de/codeblocksmc/codelib/wrapping/PotionEffectWrapper.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/PotionEffectWrapper.java
@@ -1,4 +1,4 @@
-package de.codeblocksmc.codelib.wrapping;
+package de.codeblocksmc.codelib.api.wrapping;
import lombok.Getter;
import org.bukkit.potion.PotionEffect;
diff --git a/src/main/java/de/codeblocksmc/codelib/GuiBuilder.java b/src/main/java/de/codeblocksmc/codelib/api/wrapping/adventure/GuiBuilder.java
similarity index 97%
rename from src/main/java/de/codeblocksmc/codelib/GuiBuilder.java
rename to src/main/java/de/codeblocksmc/codelib/api/wrapping/adventure/GuiBuilder.java
index 590458d..afd570c 100644
--- a/src/main/java/de/codeblocksmc/codelib/GuiBuilder.java
+++ b/src/main/java/de/codeblocksmc/codelib/api/wrapping/adventure/GuiBuilder.java
@@ -1,5 +1,6 @@
-package de.codeblocksmc.codelib;
+package de.codeblocksmc.codelib.api.wrapping.adventure;
+import de.codeblocksmc.codelib.api.wrapping.ItemBuilder;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@@ -8,16 +9,13 @@
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import java.util.Arrays;
-import java.util.List;
-
/**
* Utility class for creating GUIs.
* Provides flexibility for different inventory types and layouts.
+ * Adds support for Adventure API Components
* @author JustCody
* @version 1.1
*/
-@Deprecated(forRemoval = true)
public class GuiBuilder {
private final Inventory inv;
diff --git a/src/main/java/de/codeblocksmc/codelib/caesar/CodeLibCaesarHook.java b/src/main/java/de/codeblocksmc/codelib/caesar/CodeLibCaesarHook.java
new file mode 100644
index 0000000..0a8ac80
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/caesar/CodeLibCaesarHook.java
@@ -0,0 +1,30 @@
+package de.codeblocksmc.codelib.caesar;
+
+import de.julianweinelt.caesar.plugin.CPlugin;
+
+public class CodeLibCaesarHook extends CPlugin {
+ @Override
+ public void onLoad() {
+
+ }
+
+ @Override
+ public void onEnable() {
+
+ }
+
+ @Override
+ public void onDisable() {
+
+ }
+
+ @Override
+ public void onDefineEvents() {
+
+ }
+
+ @Override
+ public void onCreateCommands() {
+
+ }
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/commands/CodeLibCommand.java b/src/main/java/de/codeblocksmc/codelib/commands/CodeLibCommand.java
new file mode 100644
index 0000000..45ab89d
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/commands/CodeLibCommand.java
@@ -0,0 +1,39 @@
+package de.codeblocksmc.codelib.commands;
+
+import de.codeblocksmc.codelib.api.chat.AdvancedTabCompleter;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.command.TabCompleter;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CodeLibCommand implements CommandExecutor {
+ @Override
+ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label,
+ @NotNull String[] args) {
+ if (args.length == 1) {
+
+ } else if (args.length == 2) {
+
+ } else if (args.length == 3) {
+
+ }
+ return false;
+ }
+
+
+ public static class Completer extends AdvancedTabCompleter implements TabCompleter {
+
+ @Override
+ public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd,
+ @NotNull String label, @NotNull String[] args) {
+ List completions = new ArrayList<>();
+
+ return completions;
+ }
+ }
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/databsae/DatabaseObject.java b/src/main/java/de/codeblocksmc/codelib/databsae/DatabaseObject.java
deleted file mode 100644
index eb40cc9..0000000
--- a/src/main/java/de/codeblocksmc/codelib/databsae/DatabaseObject.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package de.codeblocksmc.codelib.databsae;
-
-public class DatabaseObject {
-}
diff --git a/src/main/java/de/codeblocksmc/codelib/feature/Configuration.java b/src/main/java/de/codeblocksmc/codelib/feature/Configuration.java
new file mode 100644
index 0000000..fed31e9
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/feature/Configuration.java
@@ -0,0 +1,6 @@
+package de.codeblocksmc.codelib.feature;
+
+public class Configuration {
+ private int connectorMaxPlayers = 30;
+ private boolean usePartyAndFriends;
+}
diff --git a/src/main/java/de/codeblocksmc/codelib/feature/ServerSoftware.java b/src/main/java/de/codeblocksmc/codelib/feature/ServerSoftware.java
new file mode 100644
index 0000000..25f1efd
--- /dev/null
+++ b/src/main/java/de/codeblocksmc/codelib/feature/ServerSoftware.java
@@ -0,0 +1,12 @@
+package de.codeblocksmc.codelib.feature;
+
+public enum ServerSoftware {
+ BUNGEECORD,
+ WATERFALL,
+ VELOCITY,
+ SPIGOTMC,
+ CRAFT_BUKKIT,
+ PAPER,
+ PURPUR,
+ FOLIA
+}
\ No newline at end of file