@Override public void enable() { config = configure(new LocalConfiguration()); File helpFile = new File(CommandBook.inst().getDataFolder(), config.helpFile); if (!helpFile.getParentFile().exists() || !helpFile.getParentFile().isDirectory()) helpFile.getParentFile().mkdirs(); if (!helpFile.exists() || !helpFile.isFile()) try { helpFile.createNewFile(); } catch (IOException ignored) {} help = new YAMLProcessor(helpFile, true, YAMLFormat.EXTENDED); reloadMessages(); registerCommands(HelpCommands.class); }
@Override public void enable() { CommandBook.server().getScheduler().scheduleSyncRepeatingTask(CommandBook.inst(), this, CHECK_FREQUENCY, CHECK_FREQUENCY); CommandBook.registerEvents(this); registerCommands(Commands.class); sessionsDir = new File(CommandBook.inst().getDataFolder(), "sessions"); if (!sessionsDir.exists()) { sessionsDir.mkdirs(); } }
@Override public void enable() { spawns = new WrappedSpawnManager(new File(CommandBook.inst().getDataFolder(), "spawns.yml")); config = configure(new LocalConfiguration()); registerCommands(Commands.class); CommandBook.registerEvents(this); }
/** * Loads the configuration. */ @Override public YAMLProcessor createConfiguration() { final File configFile = new File(getDataFolder(), "config.yml"); YAMLProcessor config = new YAMLProcessor(configFile, true, YAMLFormat.EXTENDED); YAMLProcessor comments = new DefaultsFileYAMLProcessor("config-comments.yml", false); try { if (!configFile.exists()) { configFile.getParentFile().mkdirs(); configFile.createNewFile(); } config.load(); comments.load(); } catch (Exception e) { getLogger().log(Level.WARNING, "Error loading configuration: ", e); } for (Map.Entry<String, Object> e : comments.getMap().entrySet()) { if (e.getValue() != null) { config.setComment(e.getKey(), e.getValue().toString()); } } // Migrate the old configuration, if we need to final String result = new LegacyCommandBookConfigurationMigrator(configFile, config).migrate(); if (result != null) { logger().severe("Error migrating CommandBook configuration: " + result); } return config; }
@EventHandler public void onJoin(PlayerJoinEvent event) { MidiJingleSequencer sequencer; try { File file = new File(CommandBook.inst().getDataFolder(), "intro.mid"); if (file.exists()) { sequencer = new MidiJingleSequencer(file, false); getJingleNoteManager().play(event.getPlayer().getName(), sequencer); } } catch (MidiUnavailableException e) { CommandBook.logger().log(Level.WARNING, "Failed to access MIDI: " + e.getMessage()); } catch (InvalidMidiDataException e) { CommandBook.logger().log(Level.WARNING, "Failed to read intro MIDI file: " + e.getMessage()); } catch (FileNotFoundException ignored) { } catch (IOException e) { CommandBook.logger().log(Level.WARNING, "Failed to read intro MIDI file: " + e.getMessage()); } }
@Override public void enable() { CommandBook.inst().createDefaultConfiguration("kits.txt"); // Setup kits kits = new FlatFileKitsManager(new File(CommandBook.inst().getDataFolder(), "kits.txt")); kits.load(); CommandBook.server().getScheduler().scheduleAsyncRepeatingTask( CommandBook.inst(), new GarbageCollector(this), GarbageCollector.CHECK_FREQUENCY, GarbageCollector.CHECK_FREQUENCY); registerCommands(Commands.class); CommandBook.registerEvents(this); }
public void registerComponentLoaders() { final File configDir = new File(getDataFolder(), "config/"); componentManager.addComponentLoader(new StaticComponentLoader(getLogger(), configDir, new SessionComponent()) { @Override final File classesDir = new File(getDataFolder(), dir); if (!classesDir.exists() || !classesDir.isDirectory()) { classesDir.mkdirs(); final File classesDir = new File(getDataFolder(), dir); if (!classesDir.exists() || !classesDir.isDirectory()) { classesDir.mkdirs();
@Override public void enable() { config = configure(new LocalConfiguration()); // Setup the ban database bans = new CSVBanDatabase(CommandBook.inst().getDataFolder()); bans.load(); CommandBook.registerEvents(this); registerCommands(Commands.class); }
@Override public void enable() { LocalConfiguration config = configure(new LocalConfiguration()); LocationManagerFactory<LocationManager<NamedLocation>> warpsFactory = new FlatFileLocationsManager.LocationsFactory(CommandBook.inst().getDataFolder(), name + "s"); manager = new RootLocationManager<NamedLocation>(warpsFactory, config.perWorld); CommandBook.registerEvents(new WorldListener()); }
new File(CommandBook.inst().getDataFolder(), "midi/" + filename), new File(CommandBook.inst().getDataFolder(), "midi/" + filename + ".mid"), new File(CommandBook.inst().getDataFolder(), "midi/" + filename + ".midi"), new File("midi", filename), new File("midi", filename + ".mid"),
MidiJingleSequencer sequencer = new MidiJingleSequencer(new File(CommandBook.inst().getDataFolder(), "intro.mid"), false); for (Player player : targets) { getJingleNoteManager().play(player.getName(), sequencer);