Fire PermRefreshEvent in sponge too

This commit is contained in:
Luck 2016-08-20 16:26:32 +01:00
parent 4aa753515d
commit 6fc00976a0
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -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,6 +48,7 @@ class SpongeUser extends User {
@Override
public void refreshPermissions() {
plugin.doSync(() -> {
Optional<Player> p = plugin.getGame().getServer().getPlayer(plugin.getUuidCache().getExternalUUID(getUuid()));
if (!p.isPresent()) return;
@ -59,5 +62,7 @@ class SpongeUser extends 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)));
});
}
}