cn.nukkit.plugin.PluginManager Java Examples

The following examples show how to use cn.nukkit.plugin.PluginManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InjectorPermissionMap.java    From LuckPerms with MIT License 6 votes vote down vote up
private LuckPermsPermissionMap 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 LuckPermsPermissionMap && ((LuckPermsPermissionMap) map).plugin == this.plugin) {
        return null;
    }

    //noinspection unchecked
    Map<String, Permission> castedMap = (Map<String, Permission>) map;

    // make a new map & inject it
    LuckPermsPermissionMap newMap = new LuckPermsPermissionMap(this.plugin, castedMap);
    PERMISSIONS_FIELD.set(pluginManager, newMap);
    return newMap;
}
 
Example #2
Source File: InjectorSubscriptionMap.java    From LuckPerms with MIT License 6 votes vote down vote up
private LuckPermsSubscriptionMap 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 LuckPermsSubscriptionMap) {
        if (((LuckPermsSubscriptionMap) map).plugin == this.plugin) {
            return null;
        }

        map = ((LuckPermsSubscriptionMap) map).detach();
    }

    //noinspection unchecked
    Map<String, Set<Permissible>> castedMap = (Map<String, Set<Permissible>>) map;

    // make a new subscription map & inject it
    LuckPermsSubscriptionMap newMap = new LuckPermsSubscriptionMap(this.plugin, castedMap);
    PERM_SUBS_FIELD.set(pluginManager, newMap);
    return newMap;
}
 
Example #3
Source File: InjectorDefaultsMap.java    From LuckPerms with MIT License 5 votes vote down vote up
private LuckPermsDefaultsMap 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 LuckPermsDefaultsMap.DefaultPermissionSet && ((LuckPermsDefaultsMap.DefaultPermissionSet) opMap).parent.plugin == this.plugin) {
        if (nonOpMap instanceof LuckPermsDefaultsMap.DefaultPermissionSet && ((LuckPermsDefaultsMap.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
    LuckPermsDefaultsMap newMap = new LuckPermsDefaultsMap(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;
}
 
Example #4
Source File: InjectorPermissionMap.java    From LuckPerms with MIT License 5 votes vote down vote up
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 LuckPermsPermissionMap) {
            LuckPermsPermissionMap lpMap = (LuckPermsPermissionMap) map;
            PERMISSIONS_FIELD.set(pluginManager, new HashMap<>(lpMap));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: InjectorSubscriptionMap.java    From LuckPerms with MIT License 5 votes vote down vote up
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 LuckPermsSubscriptionMap) {
            LuckPermsSubscriptionMap lpMap = (LuckPermsSubscriptionMap) map;
            PERM_SUBS_FIELD.set(pluginManager, lpMap.detach());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #6
Source File: Server.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public PluginManager getPluginManager() {
    return this.pluginManager;
}
 
Example #7
Source File: Server.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public PluginManager getPluginManager() {
    return this.pluginManager;
}
 
Example #8
Source File: Server.java    From Jupiter with GNU General Public License v3.0 2 votes vote down vote up
/**
 * プラグインマネージャを取得します。
 * <br>
 * <br>[Itsuのメモ: イベント登録]
 * <br>(Listenerインターフェースを実装/PluginBaseクラスを継承している場合)
 * <br>
 * <br>{@code this.getLogger().getPluginManager().registerEvents(this, this);}
 * @return PluginManager
 * @see PluginManager#registerEvents(cn.nukkit.event.Listener, Plugin)
 */
public PluginManager getPluginManager() {
    return this.pluginManager;
}