Search in sources :

Example 1 with ActionFactoryFactory

use of fr.neatmonster.nocheatplus.actions.ActionFactoryFactory in project NoCheatPlus by NoCheatPlus.

the class NoCheatPlus method getActionFactoryFactory.

@Override
public ActionFactoryFactory getActionFactoryFactory() {
    ActionFactoryFactory factory = getGenericInstance(ActionFactoryFactory.class);
    if (factory == null) {
        setActionFactoryFactory(null);
        factory = getGenericInstance(ActionFactoryFactory.class);
    }
    return factory;
}
Also used : ActionFactoryFactory(fr.neatmonster.nocheatplus.actions.ActionFactoryFactory)

Example 2 with ActionFactoryFactory

use of fr.neatmonster.nocheatplus.actions.ActionFactoryFactory in project NoCheatPlus by NoCheatPlus.

the class NoCheatPlus method setActionFactoryFactory.

@Override
public ActionFactoryFactory setActionFactoryFactory(ActionFactoryFactory actionFactoryFactory) {
    if (actionFactoryFactory == null) {
        actionFactoryFactory = new ActionFactoryFactory() {

            @Override
            public final ActionFactory newActionFactory(final Map<String, Object> library) {
                return new ActionFactory(library);
            }
        };
    }
    final ActionFactoryFactory previous = registerGenericInstance(ActionFactoryFactory.class, actionFactoryFactory);
    // Use lazy resetting.
    final IWorldDataManager worldMan = NCPAPIProvider.getNoCheatPlusAPI().getWorldDataManager();
    final Iterator<Entry<String, IWorldData>> it = worldMan.getWorldDataIterator();
    while (it.hasNext()) {
        final ConfigFile config = it.next().getValue().getRawConfiguration();
        config.setActionFactory(actionFactoryFactory);
    }
    // (Removing cached configurations and update are to be called externally.)
    return previous;
}
Also used : CommandProtectionEntry(fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEntry) Entry(java.util.Map.Entry) IWorldDataManager(fr.neatmonster.nocheatplus.worlds.IWorldDataManager) ConfigFile(fr.neatmonster.nocheatplus.config.ConfigFile) ActionFactoryFactory(fr.neatmonster.nocheatplus.actions.ActionFactoryFactory) ActionFactory(fr.neatmonster.nocheatplus.actions.ActionFactory)

Aggregations

ActionFactoryFactory (fr.neatmonster.nocheatplus.actions.ActionFactoryFactory)2 ActionFactory (fr.neatmonster.nocheatplus.actions.ActionFactory)1 ConfigFile (fr.neatmonster.nocheatplus.config.ConfigFile)1 CommandProtectionEntry (fr.neatmonster.nocheatplus.permissions.PermissionUtil.CommandProtectionEntry)1 IWorldDataManager (fr.neatmonster.nocheatplus.worlds.IWorldDataManager)1 Entry (java.util.Map.Entry)1