下面列出了org.bukkit.permissions.PermissibleBase#clearPermissions ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Injects a {@link LuckPermsPermissible} into a {@link Player}.
*
* @param player the player to inject into
* @param newPermissible the permissible to inject
* @throws Exception propagates any exceptions which were thrown during injection
*/
public static void inject(Player player, LuckPermsPermissible newPermissible) throws Exception {
// get the existing PermissibleBase held by the player
PermissibleBase oldPermissible = (PermissibleBase) HUMAN_ENTITY_PERMISSIBLE_FIELD.get(player);
// seems we have already injected into this player.
if (oldPermissible instanceof LuckPermsPermissible) {
throw new IllegalStateException("LPPermissible already injected into player " + player.toString());
}
// Move attachments over from the old permissible
//noinspection unchecked
List<PermissionAttachment> attachments = (List<PermissionAttachment>) PERMISSIBLE_BASE_ATTACHMENTS_FIELD.get(oldPermissible);
newPermissible.convertAndAddAttachments(attachments);
attachments.clear();
oldPermissible.clearPermissions();
// Setup the new permissible
newPermissible.getActive().set(true);
newPermissible.setOldPermissible(oldPermissible);
// inject the new instance
HUMAN_ENTITY_PERMISSIBLE_FIELD.set(player, newPermissible);
}
@Override
public synchronized void clearPermissions()
{
if (oldPermissible instanceof PermissibleBase)
{
PermissibleBase base = (PermissibleBase) oldPermissible;
base.clearPermissions();
}
}