diff --git a/CustomJoinAndQuitMessagesOld/CustomJoinAndQuitMessagesOld.iml b/CustomJoinAndQuitMessagesOld/CustomJoinAndQuitMessagesOld.iml index 3788c2e..f9cdb8a 100644 --- a/CustomJoinAndQuitMessagesOld/CustomJoinAndQuitMessagesOld.iml +++ b/CustomJoinAndQuitMessagesOld/CustomJoinAndQuitMessagesOld.iml @@ -51,7 +51,6 @@ - @@ -89,5 +88,6 @@ + \ No newline at end of file diff --git a/CustomJoinAndQuitMessagesOld/pom.xml b/CustomJoinAndQuitMessagesOld/pom.xml index c166c5e..5910e10 100644 --- a/CustomJoinAndQuitMessagesOld/pom.xml +++ b/CustomJoinAndQuitMessagesOld/pom.xml @@ -9,7 +9,7 @@ CustomJoinAndQuitMessagesOld - 1.7.6-b1 + 1.7.6-beta.1 11 @@ -221,6 +221,11 @@ + + org.apache.commons + commons-lang3 + 3.12.0 + \ No newline at end of file diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java index 088d6ab..3868d35 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/CustomJoinAndQuitMessages.java @@ -27,7 +27,7 @@ public class CustomJoinAndQuitMessages extends JavaPlugin { public String version = this.jss.getVersion(); private Map availableLangs = new HashMap<>(); private final ConfigFile configFile = new ConfigFile(this, "config.yml"); - private final HookManager hooksManager = new HookManager(this); + private final HookManager hooksManager = new HookManager(); private final PreConfigLoader preConfigLoader = new PreConfigLoader(this); private String updateVersion; private boolean useLegacyConfig = false; @@ -69,7 +69,9 @@ public void onEnable() { groupsFile.saveDefaultConfig(); groupsFile.create(); + hooksManager.load(); + setupEvents(); setupCommands(); diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/PreConfigLoader.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/PreConfigLoader.java index 3fdf18b..ed2e936 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/PreConfigLoader.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/config/PreConfigLoader.java @@ -23,19 +23,19 @@ public void loadConfig() { try { //Other - Settings.update = config.getString("Config.Update").equals("true"); + Settings.update = Objects.equals(config.getString("Config.Update"), "true"); Settings.c_type = config.getString("Config.Type"); - Settings.is_Group_Display = config.getString("Config.Type").equalsIgnoreCase("group"); + Settings.is_Group_Display = Objects.requireNonNull(config.getString("Config.Type")).equalsIgnoreCase("group"); //Join - Settings.join = config.getString("Join.Enabled").equals("true"); + Settings.join = Objects.equals(config.getString("Join.Enabled"), "true"); Settings.join_message = config.getString("Join.Text"); Settings.join_type = config.getString("Join.Type"); - Settings.firstjoin = config.getString("Join.First-Join.Enabled").equals("true"); + Settings.firstjoin = Objects.equals(config.getString("Join.First-Join.Enabled"), "true"); Settings.join_message_first = config.getString("Join.First-Join.Text"); - Settings.join_actionbar = config.getString("Join.ActionBar.Enabled").equals("true"); + Settings.join_actionbar = Objects.equals(config.getString("Join.ActionBar.Enabled"), "true"); Settings.join_message_actionbar_text = config.getString("Join.ActionBar.Text"); Settings.join_message_title_title = config.getString("Join.Title.Title"); @@ -45,34 +45,34 @@ public void loadConfig() { Settings.join_title_stay = config.getInt("Join.Title.Stay"); Settings.join_title_fadeout = config.getInt("Join.Title.FadeOut"); - Settings.join_sound = config.getString("Join.Sound.Enabled").equals("true"); + Settings.join_sound = Objects.equals(config.getString("Join.Sound.Enabled"), "true"); Settings.join_sound_name = config.getString("Join.Sound.Name"); Settings.join_sound_pitch = Float.parseFloat(Objects.requireNonNull(config.getString("Join.Sound.Pitch"))); Settings.join_sound_vol = config.getInt("Join.Sound.Volume"); //Quit - Settings.quit = config.getString("Quit.Enabled").equals("true"); + Settings.quit = Objects.equals(config.getString("Quit.Enabled"), "true"); Settings.quit_type = config.getString("Quit.Type"); Settings.quit_message = config.getString("Quit.Text"); //Welcome - Settings.welcome = config.getString("Welcome.Enabled").equals("true"); + Settings.welcome = Objects.equals(config.getString("Welcome.Enabled"), "true"); Settings.list_welcome = config.getStringList("Welcome.Text"); //Hooks - Settings.hook_discordsrv = config.getString("Hooks.DiscordSRV.Enabled").equals("true"); + Settings.hook_discordsrv = Objects.equals(config.getString("Hooks.DiscordSRV.Enabled"), "true"); Settings.hook_discordsrv_channelid = config.getString("Hooks.DiscordSRV.Channel-ID"); - Settings.hook_essentialsDiscord = config.getString("Hooks.EssentialsDiscord.Enabled").equals("true"); + Settings.hook_essentialsDiscord = Objects.equals(config.getString("Hooks.EssentialsDiscord.Enabled"), "true"); Settings.hook_essentialsDiscord_channelid = config.getString("Hooks.EssentialsDiscord.Channel-ID"); - Settings.hook_essentialsDiscord_use_default_channel = config.getString("Hooks.EssentialsDiscord.Use-Default-Channel").equals("true"); + Settings.hook_essentialsDiscord_use_default_channel = config.getBoolean("Hooks.EssentialsDiscord.Use-Default-Channel"); - Settings.hook_luckperms = config.getBoolean("Hooks. LuckPerms.Enabled"); - Settings.hook_luckperms_autoUpdate_group = config.getString("Hooks.LuckPerms.AutoUpdateGroup.Enabled").equals("true"); + Settings.hook_luckperms = config.getBoolean("Hooks.LuckPerms.Enabled"); + Settings.hook_luckperms_autoUpdate_group = config.getBoolean("Hooks.LuckPerms.AutoUpdateGroup.Enabled"); Settings.hook_luckperms_autoUpdate_group_tick = config.getLong("Hooks.LuckPerms.AutoUpdateGroup.Tick"); - Settings.hook_essentials = config.getString("Hooks.Essentials.Enabled").equals("true"); - Settings.hook_essentials_hideplayervanish = config.getString("Hooks.Essentials.HidePlayerIsVanish").equals("true"); + Settings.hook_essentials = Objects.equals(config.getString("Hooks.Essentials.Enabled"), "true"); + Settings.hook_essentials_hideplayervanish = config.getBoolean("Hooks.Essentials.HidePlayerIsVanish"); } catch (Exception e) { Logger.error("&cThere was an error loading the &b[PreConfigLoader]&7, please reload the plugin"); diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/HookManager.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/HookManager.java index de1df20..050c520 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/HookManager.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/HookManager.java @@ -7,14 +7,12 @@ public class HookManager { private static HookManager instance; - private final CustomJoinAndQuitMessages plugin; private final DiscordSRVHHook discordSRVHHook = new DiscordSRVHHook(this); private final EssentialsXDiscordHook essentialsXDiscordHook = new EssentialsXDiscordHook(this); private final EssentialsXHook essentialsXHook = new EssentialsXHook(this); - private final LuckPermsHook luckPermsHook = new LuckPermsHook(this); + private final LuckPermsHook luckPermsHook = new LuckPermsHook(); - public HookManager(CustomJoinAndQuitMessages plugin) { - this.plugin = plugin; + public HookManager() { instance = this; } @@ -31,7 +29,7 @@ public void load() { new DiscordSRVHHook(this), new EssentialsXDiscordHook(this), new EssentialsXHook(this), - new LuckPermsHook(this)); + luckPermsHook); } private void initHooks(IHook @NotNull ... hooks) { @@ -40,10 +38,6 @@ private void initHooks(IHook @NotNull ... hooks) { } } - public CustomJoinAndQuitMessages getPlugin() { - return plugin; - } - public DiscordSRVHHook getDiscordSRVHHook() { return discordSRVHHook; } diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/LuckPermsHook.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/LuckPermsHook.java index dc2f90d..2151419 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/LuckPermsHook.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/hook/LuckPermsHook.java @@ -8,18 +8,13 @@ import net.luckperms.api.LuckPerms; import net.luckperms.api.LuckPermsProvider; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; public class LuckPermsHook implements IHook { - private final HookManager hookManager; private boolean isEnabled; - public LuckPermsHook(HookManager hookManager) { - this.hookManager = hookManager; - } @Contract(pure = true) public static @NotNull LuckPerms getApi() { @@ -30,16 +25,19 @@ public void setup() { if (!Bukkit.getPluginManager().isPluginEnabled("LuckPerms")) { Logger.warning("&eLuckPerms not enabled! - Disable Features..."); this.isEnabled = false; + System.out.println("Cjm Softdepend: Luckperms false - check plugin installed in plugin folder"); return; } if (!Settings.hook_luckperms) { this.isEnabled = false; + System.out.println("Cjm Softdepend: Luckperms false - Hook Enabled in config"); Logger.warning("&eLuckPerms not enabled! - Disable Features..."); return; } this.isEnabled = true; + System.out.println("Cjm Softdepend: Luckperms true - The plugin has successfully loaded the dependency"); Util.sendColorMessage(EventUtils.getStaticConsoleSender(), Util.getPrefix() + "&aLoading LuckPerms features..."); } @@ -47,26 +45,4 @@ public boolean isEnabled() { return isEnabled; } - public boolean isGroup(Player player, String name) { - LuckPerms api = LuckPermsProvider.get(); - String group = api.getUserManager().getUser(player.getName()).getPrimaryGroup(); - boolean a = false; - if (name.equals(group)) { - a = true; - } - return a; - } - - public String getGroup(Player player) { - if (player != null) { - Logger.debug("Player: N/A"); - } - LuckPerms api = LuckPermsProvider.get(); - String group = api.getUserManager().getUser(player.getName()).getPrimaryGroup(); - return group; - } - - public HookManager getHookManager() { - return hookManager; - } } diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/listener/JoinListener.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/listener/JoinListener.java index af8ea36..a47e801 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/listener/JoinListener.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/listener/JoinListener.java @@ -54,6 +54,8 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) { PlayerManager playerManager = new PlayerManager(); playerManager.createPlayer(p, tempGroup); + Util.sendColorMessage(p, Util.getPrefix() + " &eLuckPermHook is: " + luckPermsHook.isEnabled()); + if (Settings.c_type.equalsIgnoreCase("group")){ if (luckPermsHook.isEnabled()) { if (!playerManager.getGroup(p).equalsIgnoreCase(Objects.requireNonNull(LuckPermsHook.getApi(). @@ -75,7 +77,6 @@ public void onJoinListener(@NotNull PlayerJoinEvent e) { Util.sendColorMessage(p, Util.getVar(p, text)); } - if (essentialsXHook.isEnabled()) { if (Settings.hook_essentials_hideplayervanish) { if (essentialsXHook.isVanish(p)) { diff --git a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java index 74aebd6..0a06fb6 100644 --- a/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java +++ b/CustomJoinAndQuitMessagesOld/src/main/java/jss/customjoinandquitmessages/utils/Util.java @@ -19,7 +19,6 @@ @SuppressWarnings("deprecation") public class Util { - private final static String prefix = getPrefix(); public static @NotNull String setLine(String color) {