mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 03:25:19 +01:00
Warn users with multiple permissions plugins installed (#3006)
This commit is contained in:
parent
931d61e2ed
commit
71896a75bf
@ -305,7 +305,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
this.bootstrap.getScheduler().executeSync(() -> {
|
||||
try {
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this);
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
PermissibleInjector.inject(player, lpPermissible, getLogger());
|
||||
} catch (Throwable t) {
|
||||
getLogger().severe("Exception thrown when setting up permissions for " +
|
||||
player.getUniqueId() + " - " + player.getName(), t);
|
||||
|
@ -26,6 +26,7 @@
|
||||
package me.lucko.luckperms.bukkit.inject.permissible;
|
||||
|
||||
import me.lucko.luckperms.bukkit.util.CraftBukkitImplementation;
|
||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
@ -84,9 +85,10 @@ public final class PermissibleInjector {
|
||||
*
|
||||
* @param player the player to inject into
|
||||
* @param newPermissible the permissible to inject
|
||||
* @param logger the plugin logger
|
||||
* @throws Exception propagates any exceptions which were thrown during injection
|
||||
*/
|
||||
public static void inject(Player player, LuckPermsPermissible newPermissible) throws Exception {
|
||||
public static void inject(Player player, LuckPermsPermissible newPermissible, PluginLogger logger) throws Exception {
|
||||
|
||||
// get the existing PermissibleBase held by the player
|
||||
PermissibleBase oldPermissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
||||
@ -96,6 +98,15 @@ public final class PermissibleInjector {
|
||||
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
|
||||
}
|
||||
|
||||
Class<? extends PermissibleBase> oldClass = oldPermissible.getClass();
|
||||
if (!PermissibleBase.class.equals(oldClass)) {
|
||||
logger.warn("Player " + player.getName() + " already has a custom permissible (" + oldClass.getName() + ")!\n" +
|
||||
"This is probably because you have multiple permission plugins installed.\n" +
|
||||
"Please make sure that LuckPerms is the only permission plugin installed on your server!\n" +
|
||||
"(unless you're performing a migration, in which case, just remember to remove your old " +
|
||||
"permission plugin once you're done!)");
|
||||
}
|
||||
|
||||
// Move attachments over from the old permissible
|
||||
|
||||
//noinspection unchecked
|
||||
@ -151,4 +162,24 @@ public final class PermissibleInjector {
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkInjected(Player player, PluginLogger logger) {
|
||||
PermissibleBase permissibleBase;
|
||||
try {
|
||||
permissibleBase = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
|
||||
} catch (IllegalAccessException e) {
|
||||
return; // ignore
|
||||
}
|
||||
|
||||
if (permissibleBase instanceof LuckPermsPermissible) {
|
||||
return; // all gucci
|
||||
}
|
||||
|
||||
Class<? extends PermissibleBase> clazz = permissibleBase.getClass();
|
||||
logger.warn("Player " + player.getName() + " has a non-LuckPerms permissible (" + clazz.getName() + ")!\n" +
|
||||
"This is probably because you have multiple permission plugins installed.\n" +
|
||||
"Please make sure that LuckPerms is the only permission plugin installed on your server!\n" +
|
||||
"(unless you're performing a migration, in which case, just remember to remove your old " +
|
||||
"permission plugin once you're done!)");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
||||
LuckPermsPermissible lpPermissible = new LuckPermsPermissible(player, user, this.plugin);
|
||||
|
||||
// Inject into the player
|
||||
PermissibleInjector.inject(player, lpPermissible);
|
||||
PermissibleInjector.inject(player, lpPermissible, this.plugin.getLogger());
|
||||
|
||||
} catch (Throwable t) {
|
||||
this.plugin.getLogger().warn("Exception thrown when setting up permissions for " +
|
||||
@ -230,6 +230,8 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
||||
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "");
|
||||
}
|
||||
}
|
||||
|
||||
PermissibleInjector.checkInjected(e.getPlayer(), this.plugin.getLogger());
|
||||
}
|
||||
|
||||
// Wait until the last priority to unload, so plugins can still perform permission checks on this event
|
||||
|
Loading…
Reference in New Issue
Block a user