Java Code Examples for org.bukkit.permissions.PermissibleBase#clearPermissions()
The following examples show how to use
org.bukkit.permissions.PermissibleBase#clearPermissions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissibleInjector.java From LuckPerms with MIT License | 5 votes |
/** * 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); }
Example 2
Source File: BPPermissible.java From BungeePerms with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void clearPermissions() { if (oldPermissible instanceof PermissibleBase) { PermissibleBase base = (PermissibleBase) oldPermissible; base.clearPermissions(); } }