mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
Fire PermRefreshEvent in sponge too
This commit is contained in:
parent
4aa753515d
commit
6fc00976a0
@ -23,6 +23,8 @@
|
||||
package me.lucko.luckperms.users;
|
||||
|
||||
import me.lucko.luckperms.LPSpongePlugin;
|
||||
import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent;
|
||||
import me.lucko.luckperms.api.implementation.internal.UserLink;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
import org.spongepowered.api.util.Tristate;
|
||||
|
||||
@ -46,18 +48,21 @@ class SpongeUser extends User {
|
||||
|
||||
@Override
|
||||
public void refreshPermissions() {
|
||||
Optional<Player> p = plugin.getGame().getServer().getPlayer(plugin.getUuidCache().getExternalUUID(getUuid()));
|
||||
if (!p.isPresent()) return;
|
||||
plugin.doSync(() -> {
|
||||
Optional<Player> p = plugin.getGame().getServer().getPlayer(plugin.getUuidCache().getExternalUUID(getUuid()));
|
||||
if (!p.isPresent()) return;
|
||||
|
||||
final Player player = p.get();
|
||||
final Player player = p.get();
|
||||
|
||||
// Clear existing permissions
|
||||
player.getSubjectData().clearParents();
|
||||
player.getSubjectData().clearPermissions();
|
||||
// Clear existing permissions
|
||||
player.getSubjectData().clearParents();
|
||||
player.getSubjectData().clearPermissions();
|
||||
|
||||
// Re-add all defined permissions for the user
|
||||
final String world = player.getWorld().getName();
|
||||
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), world, null);
|
||||
local.entrySet().forEach(e -> player.getSubjectData().setPermission(Collections.emptySet(), e.getKey(), Tristate.fromBoolean(e.getValue())));
|
||||
// Re-add all defined permissions for the user
|
||||
final String world = player.getWorld().getName();
|
||||
Map<String, Boolean> local = getLocalPermissions(getPlugin().getConfiguration().getServer(), world, null);
|
||||
local.entrySet().forEach(e -> player.getSubjectData().setPermission(Collections.emptySet(), e.getKey(), Tristate.fromBoolean(e.getValue())));
|
||||
plugin.getApiProvider().fireEventAsync(new UserPermissionRefreshEvent(new UserLink(this)));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user