check if rsp is null

This commit is contained in:
Taah 2022-05-10 23:06:56 -07:00
parent b78f71c238
commit ebfba89994
3 changed files with 16 additions and 1 deletions

View File

@ -19,6 +19,10 @@ public class VaultHook
{ {
if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) return null; if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) return null;
RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class); RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
if (rsp == null)
{
return null;
}
CHAT = rsp.getProvider(); CHAT = rsp.getProvider();
return CHAT; return CHAT;
} }
@ -27,6 +31,10 @@ public class VaultHook
{ {
if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) return null; if (!Bukkit.getPluginManager().isPluginEnabled("Vault")) return null;
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class); RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
if (rsp == null)
{
return null;
}
PERMISSIONS = rsp.getProvider(); PERMISSIONS = rsp.getProvider();
return PERMISSIONS; return PERMISSIONS;
} }

View File

@ -3,7 +3,6 @@ package dev.plex.permission.handler;
import dev.plex.api.permission.IPermissionHandler; import dev.plex.api.permission.IPermissionHandler;
import dev.plex.hook.VaultHook; import dev.plex.hook.VaultHook;
import lombok.Getter; import lombok.Getter;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -19,6 +18,10 @@ public class VaultPermissionHandler implements IPermissionHandler
{ {
return IPermissionHandler.super.hasPermission(player, permission); return IPermissionHandler.super.hasPermission(player, permission);
} }
if (VaultHook.getPermission() == null)
{
return IPermissionHandler.super.hasPermission(player, permission);
}
return VaultHook.getPermission().playerHas(null, player, permission); return VaultHook.getPermission().playerHas(null, player, permission);
} }

View File

@ -119,6 +119,10 @@ public class RankManager
} }
if (Bukkit.getServer().getPluginManager().isPluginEnabled("Vault") && Plex.get().getSystem().equalsIgnoreCase("permissions")) if (Bukkit.getServer().getPluginManager().isPluginEnabled("Vault") && Plex.get().getSystem().equalsIgnoreCase("permissions"))
{ {
if (VaultHook.getChat() == null || VaultHook.getPermission() == null)
{
return null;
}
Player bukkitPlayer = Bukkit.getPlayer(player.getUuid()); Player bukkitPlayer = Bukkit.getPlayer(player.getUuid());
String group = VaultHook.getPermission().getPrimaryGroup(bukkitPlayer); String group = VaultHook.getPermission().getPrimaryGroup(bukkitPlayer);
String vaultPrefix = VaultHook.getChat().getGroupPrefix(bukkitPlayer.getWorld(), group); String vaultPrefix = VaultHook.getChat().getGroupPrefix(bukkitPlayer.getWorld(), group);