Skip to content

Commit

Permalink
Bug fix hooks and remove vault hook
Browse files Browse the repository at this point in the history
  • Loading branch information
jonagamerpro1234 committed Nov 9, 2022
1 parent 8e95a49 commit 7b95c6a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-jdk14:1.7.25" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-io:commons-io:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.vdurmont:emoji-java:5.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20170516" level="project" />
Expand Down Expand Up @@ -89,5 +88,6 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: org.checkerframework:checker-qual:3.14.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.essentialsx:EssentialsXDiscord:2.19.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:discord-webhooks:0.5.6" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.12.0" level="project" />
</component>
</module>
7 changes: 6 additions & 1 deletion CustomJoinAndQuitMessagesOld/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</parent>

<artifactId>CustomJoinAndQuitMessagesOld</artifactId>
<version>1.7.6-b1</version>
<version>1.7.6-beta.1</version>

<properties>
<java.version>11</java.version>
Expand Down Expand Up @@ -221,6 +221,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class CustomJoinAndQuitMessages extends JavaPlugin {
public String version = this.jss.getVersion();
private Map<String, Lang> 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;
Expand Down Expand Up @@ -69,7 +69,9 @@ public void onEnable() {

groupsFile.saveDefaultConfig();
groupsFile.create();

hooksManager.load();

setupEvents();
setupCommands();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand All @@ -40,10 +38,6 @@ private void initHooks(IHook @NotNull ... hooks) {
}
}

public CustomJoinAndQuitMessages getPlugin() {
return plugin;
}

public DiscordSRVHHook getDiscordSRVHHook() {
return discordSRVHHook;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -30,43 +25,24 @@ 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...");
}

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

@SuppressWarnings("deprecation")
public class Util {

private final static String prefix = getPrefix();

public static @NotNull String setLine(String color) {
Expand Down

0 comments on commit 7b95c6a

Please sign in to comment.