refactors, code style fixes, rpeventing events from firing when not needed

This commit is contained in:
2023-06-22 18:41:16 +02:00
parent 3919b0f44b
commit d859fd0aaa
14 changed files with 153 additions and 119 deletions
@@ -3,20 +3,18 @@ package me.youhavetrouble.preventstabby.hooks;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.youhavetrouble.preventstabby.PreventStabby;
import me.youhavetrouble.preventstabby.util.PluginMessages;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import java.time.Instant;
import java.util.UUID;
public class PlacoholderApiHook extends PlaceholderExpansion {
public class PlaceholderApiHook extends PlaceholderExpansion {
private final PreventStabby plugin;
private final LegacyComponentSerializer legacyComponentSerializer;
public PlacoholderApiHook(PreventStabby preventStabby) {
public PlaceholderApiHook(PreventStabby preventStabby) {
plugin = preventStabby;
this.legacyComponentSerializer = LegacyComponentSerializer.legacyAmpersand();
}
@@ -12,7 +12,7 @@ import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import org.bukkit.Bukkit;
import me.youhavetrouble.preventstabby.PreventStabby;
import org.bukkit.entity.Player;
public class WorldGuardHook {
@@ -25,7 +25,7 @@ public class WorldGuardHook {
Class.forName("com.sk89q.worldguard.protection.flags.registry.FlagRegistry");
WorldGuardPlugin worldGuardPlugin = WorldGuardPlugin.inst();
if (WorldGuard.getInstance() == null || worldGuardPlugin == null) return;
Bukkit.getLogger().info("[PreventStabby] Hooking into WorldGuard");
PreventStabby.getPlugin().getLogger().info("[PreventStabby] Hooking into WorldGuard");
flagRegistry = WorldGuard.getInstance().getFlagRegistry();
createForcePvpFlag();
} catch (NoClassDefFoundError | ClassNotFoundException ignored) {
@@ -44,7 +44,7 @@ public class WorldGuardHook {
if (existing instanceof StateFlag) {
FORCE_PVP_FLAG = (StateFlag) existing;
} else {
Bukkit.getLogger().severe("[PreventStabby] There is a conflict between flag names!");
PreventStabby.getPlugin().getLogger().severe("[PreventStabby] There is a conflict between flag names!");
}
}
}