/** * Get the current configuration. * * <p>If no platform has been registered yet, then a default configuration * will be returned.</p> * * @return the configuration */ public LocalConfiguration getConfiguration() { return queryCapability(Capability.CONFIGURATION).getConfiguration(); }
void register(Platform platform) { log.log(Level.FINE, "Registering commands with " + platform.getClass().getCanonicalName()); LocalConfiguration config = platform.getConfiguration(); boolean logging = config.logCommands; String path = config.logFile; // Register log if (!logging || path.isEmpty()) { dynamicHandler.setHandler(null); commandLog.setLevel(Level.OFF); } else { File file = new File(config.getWorkingDirectory(), path); commandLog.setLevel(Level.ALL); log.log(Level.INFO, "Logging WorldEdit commands to " + file.getAbsolutePath()); try { dynamicHandler.setHandler(new FileHandler(file.getAbsolutePath(), true)); } catch (IOException e) { log.log(Level.WARNING, "Could not use command log file " + path + ": " + e.getMessage()); } dynamicHandler.setFormatter(new LogFormat(config.logFormat)); } platform.registerCommands(dispatcher); }
/** * Choose preferred platforms and perform necessary initialization. */ private synchronized void choosePreferred() { for (Capability capability : Capability.values()) { Platform preferred = findMostPreferred(capability); if (preferred != null) { preferences.put(capability, preferred); capability.initialize(this, preferred); } } // Fire configuration event if (preferences.containsKey(Capability.CONFIGURATION) && configured.compareAndSet(false, true)) { worldEdit.getEventBus().post(new ConfigurationLoadEvent(queryCapability(Capability.CONFIGURATION).getConfiguration())); } }
@Before public void setup() { Platform mockPlat = Mockito.mock(Platform.class); Mockito.when(mockPlat.getConfiguration()).thenReturn(new LocalConfiguration() { @Override public void load() { } }); WorldEdit.getInstance().getPlatformManager().register(mockPlat); }
@Command( aliases = { "reload" }, usage = "", desc = "Reload configuration", min = 0, max = 0 ) @CommandPermissions("worldedit.reload") public void reload(Actor actor) throws WorldEditException { we.getPlatformManager().queryCapability(Capability.CONFIGURATION).reload(); we.getEventBus().post(new ConfigurationLoadEvent(we.getPlatformManager().queryCapability(Capability.CONFIGURATION).getConfiguration())); actor.print("Configuration reloaded!"); }