From bfadbc9340a772b905d02f627e9b330aa3b49237 Mon Sep 17 00:00:00 2001 From: thmsdy Date: Fri, 13 Mar 2020 02:22:39 -0500 Subject: [PATCH] Block badge commands if MySQL is disabled --- pom.xml | 2 +- src/main/java/com/fpghoti/fpchatx/FPChat.java | 9 ++++++--- .../fpchatx/command/commands/BadgeClearCommand.java | 7 +++++++ .../fpchatx/command/commands/BadgeEquipCommand.java | 5 +++++ .../fpchatx/command/commands/BadgeListCommand.java | 6 ++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 4fdc86f..f90e2d5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 FPChatX FPChatX - 1.0.5-BETA + 1.0.6-BETA spigot-repo diff --git a/src/main/java/com/fpghoti/fpchatx/FPChat.java b/src/main/java/com/fpghoti/fpchatx/FPChat.java index 39e0546..522c7e9 100644 --- a/src/main/java/com/fpghoti/fpchatx/FPChat.java +++ b/src/main/java/com/fpghoti/fpchatx/FPChat.java @@ -64,7 +64,7 @@ public class FPChat extends JavaPlugin { private BukkitTask refresh = null; private PlayerListener listener = null; private PlayerCache cache; - + public void onEnable() { plugin = this; VaultUtil vault = new VaultUtil(this); @@ -115,7 +115,10 @@ public class FPChat extends JavaPlugin { refresh.cancel(); } - sql.disconnect(); + if(config.mySQLEnabled()) { + sql.disconnect(); + } + for(FPlayer p : FPlayer.getPlayers()) { p.cleanup(); } @@ -185,7 +188,7 @@ public class FPChat extends JavaPlugin { public MainConfig getMainConfig() { return this.config; } - + public PlayerCache getPlayerCache() { return this.cache; } diff --git a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeClearCommand.java b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeClearCommand.java index ab5ffc0..39a3135 100644 --- a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeClearCommand.java +++ b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeClearCommand.java @@ -31,6 +31,13 @@ public class BadgeClearCommand extends Commands { FPlayer.errMsg(null, "This command is for players only."); return; } + + + if(!plugin.getMainConfig().mySQLEnabled()) { + FPlayer.errMsg(null, "MySQL is not enabled."); + return; + } + FPlayer p = FPlayer.getPlayer((Player)sender); BadgeSet.setBadge(p, 1, 0); BadgeSet.setBadge(p, 2, 0); diff --git a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeEquipCommand.java b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeEquipCommand.java index 95c9cf4..ace7aa4 100644 --- a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeEquipCommand.java +++ b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeEquipCommand.java @@ -35,6 +35,11 @@ public class BadgeEquipCommand extends Commands { return; } + if(!plugin.getMainConfig().mySQLEnabled()) { + FPlayer.errMsg(null, "MySQL is not enabled."); + return; + } + FPlayer p = FPlayer.getPlayer((Player)sender); if(Util.isDigit(args[0]) && Util.isDigit(args[1])){ diff --git a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeListCommand.java b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeListCommand.java index 5074d42..2b8db8e 100644 --- a/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeListCommand.java +++ b/src/main/java/com/fpghoti/fpchatx/command/commands/BadgeListCommand.java @@ -32,6 +32,12 @@ public class BadgeListCommand extends Commands { FPlayer.errMsg(null, "This command is for players only."); return; } + + if(!plugin.getMainConfig().mySQLEnabled()) { + FPlayer.errMsg(null, "MySQL is not enabled."); + return; + } + FPlayer p = FPlayer.getPlayer((Player)sender); if(args.length == 0 || !Util.isDigit(args[0])){ BadgeList.badgeList(p, 1);