From 6a0aa894105d31bedc6ed8412fafe70e482d1da9 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Wed, 28 Oct 2020 21:10:47 -0500 Subject: [PATCH] idk what i did this should probably be reverted --- src/main/java/me/totalfreedom/plex/Plex.java | 17 +++++++---------- .../java/me/totalfreedom/plex/PlexBase.java | 6 ++++++ .../plex/command/PlexCommand.java | 16 ++++++++++++++++ .../totalfreedom/plex/config/MainConfig.java | 5 ++--- .../{listeners => listener}/ChatListener.java | 3 +-- .../PlayerListener.java | 2 +- .../plex/storage/SQLConnection.java | 19 +++++++++---------- src/main/resources/config.yml | 14 +++----------- src/main/resources/plugin.yml | 6 +++++- 9 files changed, 50 insertions(+), 38 deletions(-) create mode 100644 src/main/java/me/totalfreedom/plex/PlexBase.java create mode 100644 src/main/java/me/totalfreedom/plex/command/PlexCommand.java rename src/main/java/me/totalfreedom/plex/{listeners => listener}/ChatListener.java (91%) rename src/main/java/me/totalfreedom/plex/{listeners => listener}/PlayerListener.java (99%) diff --git a/src/main/java/me/totalfreedom/plex/Plex.java b/src/main/java/me/totalfreedom/plex/Plex.java index 9810b51..7ddfbe7 100644 --- a/src/main/java/me/totalfreedom/plex/Plex.java +++ b/src/main/java/me/totalfreedom/plex/Plex.java @@ -1,13 +1,13 @@ package me.totalfreedom.plex; -import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; import me.totalfreedom.plex.cache.MongoPlayerData; import me.totalfreedom.plex.cache.SQLPlayerData; +import me.totalfreedom.plex.command.PlexCommand; import me.totalfreedom.plex.config.MainConfig; -import me.totalfreedom.plex.listeners.ChatListener; -import me.totalfreedom.plex.listeners.PlayerListener; +import me.totalfreedom.plex.listener.ChatListener; +import me.totalfreedom.plex.listener.PlayerListener; import me.totalfreedom.plex.rank.RankManager; import me.totalfreedom.plex.storage.MongoConnection; import me.totalfreedom.plex.storage.RedisConnection; @@ -21,11 +21,8 @@ import org.bukkit.plugin.java.JavaPlugin; @Setter public class Plex extends JavaPlugin { - @Setter(AccessLevel.NONE) - private static Plex plugin; - + public static Plex plugin; public MainConfig config; - private StorageType storageType = StorageType.SQLITE; private SQLConnection sqlConnection; @@ -46,9 +43,7 @@ public class Plex extends JavaPlugin public void onLoad() { plugin = this; - config = new MainConfig(this); - saveResource("database.db", false); sqlConnection = new SQLConnection(); @@ -95,12 +90,14 @@ public class Plex extends JavaPlugin rankManager.generateDefaultRanks(); rankManager.importDefaultRanks(); PlexLog.log("Rank Manager initialized"); + + getCommand("plex").setExecutor(new PlexCommand()); + } @Override public void onDisable() { - config.save(); /*if (redisConnection.getJedis().isConnected()) { PlexLog.log("Disabling Redis/Jedis. No memory leaks in this Anarchy server !"); diff --git a/src/main/java/me/totalfreedom/plex/PlexBase.java b/src/main/java/me/totalfreedom/plex/PlexBase.java new file mode 100644 index 0000000..9878637 --- /dev/null +++ b/src/main/java/me/totalfreedom/plex/PlexBase.java @@ -0,0 +1,6 @@ +package me.totalfreedom.plex; + +public class PlexBase +{ + protected static Plex plugin = Plex.plugin; +} diff --git a/src/main/java/me/totalfreedom/plex/command/PlexCommand.java b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java new file mode 100644 index 0000000..7e5bf95 --- /dev/null +++ b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java @@ -0,0 +1,16 @@ +package me.totalfreedom.plex.command; + +import me.totalfreedom.plex.PlexBase; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +public class PlexCommand extends PlexBase implements CommandExecutor +{ + @Override + public boolean onCommand(CommandSender sender, Command message, String s, String[] args) + { + sender.sendMessage(plugin.config.getString("server.test")); + return true; + } +} diff --git a/src/main/java/me/totalfreedom/plex/config/MainConfig.java b/src/main/java/me/totalfreedom/plex/config/MainConfig.java index 413f001..b77c7fe 100644 --- a/src/main/java/me/totalfreedom/plex/config/MainConfig.java +++ b/src/main/java/me/totalfreedom/plex/config/MainConfig.java @@ -6,9 +6,8 @@ import org.bukkit.configuration.file.YamlConfiguration; public class MainConfig extends YamlConfiguration { - private static MainConfig config; - private final Plex plugin; - private final File file; + private Plex plugin; + private File file; public MainConfig(Plex plugin) { diff --git a/src/main/java/me/totalfreedom/plex/listeners/ChatListener.java b/src/main/java/me/totalfreedom/plex/listener/ChatListener.java similarity index 91% rename from src/main/java/me/totalfreedom/plex/listeners/ChatListener.java rename to src/main/java/me/totalfreedom/plex/listener/ChatListener.java index f83f432..8447b22 100644 --- a/src/main/java/me/totalfreedom/plex/listeners/ChatListener.java +++ b/src/main/java/me/totalfreedom/plex/listener/ChatListener.java @@ -1,9 +1,8 @@ -package me.totalfreedom.plex.listeners; +package me.totalfreedom.plex.listener; import me.totalfreedom.plex.Plex; import me.totalfreedom.plex.cache.PlayerCache; import me.totalfreedom.plex.player.PlexPlayer; -import me.totalfreedom.plex.rank.RankManager; import net.md_5.bungee.api.ChatColor; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/java/me/totalfreedom/plex/listeners/PlayerListener.java b/src/main/java/me/totalfreedom/plex/listener/PlayerListener.java similarity index 99% rename from src/main/java/me/totalfreedom/plex/listeners/PlayerListener.java rename to src/main/java/me/totalfreedom/plex/listener/PlayerListener.java index 0a31d32..aa7f8cd 100644 --- a/src/main/java/me/totalfreedom/plex/listeners/PlayerListener.java +++ b/src/main/java/me/totalfreedom/plex/listener/PlayerListener.java @@ -1,4 +1,4 @@ -package me.totalfreedom.plex.listeners; +package me.totalfreedom.plex.listener; import java.util.Arrays; import me.totalfreedom.plex.Plex; diff --git a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java index d3eb221..aff84cc 100644 --- a/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java +++ b/src/main/java/me/totalfreedom/plex/storage/SQLConnection.java @@ -5,11 +5,10 @@ import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import me.totalfreedom.plex.Plex; +import me.totalfreedom.plex.PlexBase; -public class SQLConnection +public class SQLConnection extends PlexBase { - private final Plex plugin = Plex.get(); - private Connection connection; public Connection getCon() @@ -25,7 +24,7 @@ public class SQLConnection if (plugin.config.getString("data.central.storage").equalsIgnoreCase("sqlite")) { connection = DriverManager.getConnection("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath()); - Plex.get().setStorageType(StorageType.SQLITE); + plugin.setStorageType(StorageType.SQLITE); } else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mysql")) { @@ -45,12 +44,12 @@ public class SQLConnection connection.prepareStatement("CREATE TABLE IF NOT EXISTS `players` (\n" + "\t`uuid` VARCHAR(46),\n" + "\t`name` VARCHAR(18),\n" + - "\t`login_msg` VARCHAR(256),\n" + - "\t`prefix` VARCHAR(30),\n" + - "\t`rank` VARCHAR(256),\n" + - "\t`ips` VARCHAR(65535),\n" + - "\t`coins` BIGINT,\n" + - "\tPRIMARY KEY (`uuid`)\n" + + "\t`login_msg` VARCHAR,\n" + + "\t`prefix` VARCHAR,\n" + + "\t`rank` VARCHAR,\n" + + "\t`ips` VARCHAR,\n" + + "\t`coins` INT\n" + + //"\tPRIMARY KEY (`uuid`)\n" + ");").execute(); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9ccedcb..2944693 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,15 +1,7 @@ -# -------------------------------# -# # -# P L E X # -# # -# -------------------------------# +# Plex Configuration File -# ------------------------------ # -# # -# You can use MySQL, MongoDB # -# or SQLite for the data # -# type # -# -------------------------------# +server: + test: "test string" data: central: diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 17982c6..c839e8a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,4 +2,8 @@ name: ${project.name} version: ${project.version} author: Telesphoreo main: me.totalfreedom.plex.Plex -api-version: 1.16 \ No newline at end of file +api-version: 1.16 +commands: + plex: + description: Test + usage: / \ No newline at end of file