Fix CME in Bukkit refreshAutoOp

cc @Exloki
This commit is contained in:
Luck 2018-12-22 17:04:32 +00:00
parent 2ccffc6e6d
commit e5c4b710f6
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 15 additions and 6 deletions

View File

@ -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));
}
}
}

View File

@ -164,7 +164,7 @@ public class BukkitConnectionListener extends AbstractConnectionListener impleme
return;
}
this.plugin.refreshAutoOp(player);
this.plugin.refreshAutoOp(player, true);
}
@EventHandler(priority = EventPriority.MONITOR)

View File

@ -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);
}
}