mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 21:29:47 +01:00
Fix CME in Bukkit refreshAutoOp
cc @Exloki
This commit is contained in:
parent
2ccffc6e6d
commit
e5c4b710f6
@ -266,7 +266,7 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
getApiProvider().getEventBus().subscribe(UserDataRecalculateEvent.class, event -> {
|
||||
User user = ApiUser.cast(event.getUser());
|
||||
Optional<Player> player = getBootstrap().getPlayer(user.getUuid());
|
||||
player.ifPresent(this::refreshAutoOp);
|
||||
player.ifPresent(p -> refreshAutoOp(p, false));
|
||||
});
|
||||
}
|
||||
|
||||
@ -324,16 +324,25 @@ public class LPBukkitPlugin extends AbstractLuckPermsPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshAutoOp(Player player) {
|
||||
public void refreshAutoOp(Player player, boolean callerIsSync) {
|
||||
if (getConfiguration().get(ConfigKeys.AUTO_OP)) {
|
||||
User user = getUserManager().getIfLoaded(player.getUniqueId());
|
||||
if (user == null) {
|
||||
player.setOp(false);
|
||||
if (callerIsSync) {
|
||||
player.setOp(false);
|
||||
} else {
|
||||
this.bootstrap.getScheduler().executeSync(() -> player.setOp(false));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Boolean> permData = user.getCachedData().getPermissionData(this.contextManager.getApplicableContexts(player)).getImmutableBacking();
|
||||
player.setOp(permData.getOrDefault("luckperms.autoop", false));
|
||||
boolean value = permData.getOrDefault("luckperms.autoop", false);
|
||||
if (callerIsSync) {
|
||||
player.setOp(value);
|
||||
} else {
|
||||
this.bootstrap.getScheduler().executeSync(() -> player.setOp(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
|
||||
return;
|
||||
}
|
||||
|
||||
this.plugin.refreshAutoOp(player);
|
||||
this.plugin.refreshAutoOp(player, true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
|
@ -95,7 +95,7 @@ public class BukkitPlatformListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWorldChange(PlayerChangedWorldEvent e) {
|
||||
this.plugin.getContextManager().invalidateCache(e.getPlayer());
|
||||
this.plugin.refreshAutoOp(e.getPlayer());
|
||||
this.plugin.refreshAutoOp(e.getPlayer(), true);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user