use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorDefaultsMap method uninject.
public static void uninject() {
try {
Objects.requireNonNull(OP_DEFAULT_PERMISSIONS_FIELD, "OP_DEFAULT_PERMISSIONS_FIELD");
Objects.requireNonNull(NON_OP_DEFAULT_PERMISSIONS_FIELD, "NON_OP_DEFAULT_PERMISSIONS_FIELD");
PluginManager pluginManager = Server.getInstance().getPluginManager();
{
Object map = OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
if (map instanceof LPDefaultsMap.DefaultPermissionSet) {
LPDefaultsMap.DefaultPermissionSet lpMap = (LPDefaultsMap.DefaultPermissionSet) map;
OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
}
}
{
Object map = NON_OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
if (map instanceof LPDefaultsMap.DefaultPermissionSet) {
LPDefaultsMap.DefaultPermissionSet lpMap = (LPDefaultsMap.DefaultPermissionSet) map;
NON_OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorDefaultsMap method inject.
private LPDefaultsMap inject() throws Exception {
Objects.requireNonNull(OP_DEFAULT_PERMISSIONS_FIELD, "OP_DEFAULT_PERMISSIONS_FIELD");
Objects.requireNonNull(NON_OP_DEFAULT_PERMISSIONS_FIELD, "NON_OP_DEFAULT_PERMISSIONS_FIELD");
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
Object opMap = OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
Object nonOpMap = NON_OP_DEFAULT_PERMISSIONS_FIELD.get(pluginManager);
if (opMap instanceof LPDefaultsMap.DefaultPermissionSet && ((LPDefaultsMap.DefaultPermissionSet) opMap).parent.plugin == this.plugin) {
if (nonOpMap instanceof LPDefaultsMap.DefaultPermissionSet && ((LPDefaultsMap.DefaultPermissionSet) nonOpMap).parent.plugin == this.plugin) {
return null;
}
}
// noinspection unchecked
Map<String, Permission> castedOpMap = (Map<String, Permission>) opMap;
// noinspection unchecked
Map<String, Permission> castedNonOpMap = (Map<String, Permission>) nonOpMap;
// make a new map & inject it
LPDefaultsMap newMap = new LPDefaultsMap(this.plugin, ImmutableMap.of(true, castedOpMap, false, castedNonOpMap));
OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, newMap.getOpPermissions());
NON_OP_DEFAULT_PERMISSIONS_FIELD.set(pluginManager, newMap.getNonOpPermissions());
return newMap;
}
use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorPermissionMap method uninject.
public static void uninject() {
try {
Objects.requireNonNull(PERMISSIONS_FIELD, "PERMISSIONS_FIELD");
PluginManager pluginManager = Server.getInstance().getPluginManager();
Object map = PERMISSIONS_FIELD.get(pluginManager);
if (map instanceof LPPermissionMap) {
LPPermissionMap lpMap = (LPPermissionMap) map;
PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
}
} catch (Exception e) {
e.printStackTrace();
}
}
use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorPermissionMap method inject.
private LPPermissionMap inject() throws Exception {
Objects.requireNonNull(PERMISSIONS_FIELD, "PERMISSIONS_FIELD");
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
Object map = PERMISSIONS_FIELD.get(pluginManager);
if (map instanceof LPPermissionMap && ((LPPermissionMap) map).plugin == this.plugin) {
return null;
}
// noinspection unchecked
Map<String, Permission> castedMap = (Map<String, Permission>) map;
// make a new map & inject it
LPPermissionMap newMap = new LPPermissionMap(this.plugin, castedMap);
PERMISSIONS_FIELD.set(pluginManager, newMap);
return newMap;
}
use of cn.nukkit.plugin.PluginManager in project LuckPerms by lucko.
the class InjectorSubscriptionMap method uninject.
public static void uninject() {
try {
Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
PluginManager pluginManager = Server.getInstance().getPluginManager();
Object map = PERM_SUBS_FIELD.get(pluginManager);
if (map instanceof LPSubscriptionMap) {
LPSubscriptionMap lpMap = (LPSubscriptionMap) map;
PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations