use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorSubscriptionMap method inject.
private LPSubscriptionMap inject() throws Exception {
Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
Object map = PERM_SUBS_FIELD.get(pluginManager);
if (map instanceof LPSubscriptionMap) {
if (((LPSubscriptionMap) map).plugin == this.plugin) {
return null;
}
map = ((LPSubscriptionMap) map).detach();
}
// noinspection unchecked
Map<String, Set<Permissible>> castedMap = (Map<String, Set<Permissible>>) map;
// make a new subscription map & inject it
LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);
PERM_SUBS_FIELD.set(pluginManager, newMap);
return newMap;
}
use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class LPNukkitPlugin method performFinalSetup.
@Override
protected void performFinalSetup() {
// register permissions
try {
PluginManager pm = this.bootstrap.getServer().getPluginManager();
PermissionDefault permDefault = getConfiguration().get(ConfigKeys.COMMANDS_ALLOW_OP) ? PermissionDefault.OP : PermissionDefault.FALSE;
for (CommandPermission p : CommandPermission.values()) {
pm.addPermission(new Permission(p.getPermission(), null, permDefault.toString()));
}
} catch (Exception e) {
// this throws an exception if the plugin is /reloaded, grr
}
if (!getConfiguration().get(ConfigKeys.OPS_ENABLED)) {
Config ops = this.bootstrap.getServer().getOps();
ops.getKeys(false).forEach(ops::remove);
}
// replace the temporary executor when the Nukkit one starts
this.bootstrap.getServer().getScheduler().scheduleTask(this.bootstrap, () -> this.bootstrap.getScheduler().setUseFallback(false), true);
// Load any online users (in the case of a reload)
for (Player player : this.bootstrap.getServer().getOnlinePlayers().values()) {
this.bootstrap.getScheduler().doAsync(() -> {
try {
User user = this.connectionListener.loadUser(player.getUniqueId(), player.getName());
if (user != null) {
this.bootstrap.getScheduler().doSync(() -> {
try {
LPPermissible lpPermissible = new LPPermissible(player, user, this);
PermissibleInjector.inject(player, lpPermissible);
} catch (Throwable t) {
t.printStackTrace();
}
});
}
} catch (Exception e) {
e.printStackTrace();
}
});
}
}
Aggregations