@Override public File getWorkingDirectory() { return plugin.getDataFolder(); } }
/** * Create a default configuration file from the .jar. * * @param name the filename */ protected void createDefaultConfiguration(String name) { File actual = new File(getDataFolder(), name); if (!actual.exists()) { try (JarFile file = new JarFile(getFile())) { ZipEntry copy = file.getEntry("defaults/" + name); if (copy == null) throw new FileNotFoundException(); copyDefaultConfig(file.getInputStream(copy), actual, name); } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + name); } } }
private void loadConfig() { createDefaultConfiguration("config.yml"); // Create the default configuration file config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this); config.load(); }
/** * Called on plugin enable. */ @SuppressWarnings("AccessStaticViaInstance") @Override public void onEnable() { this.INSTANCE = this; //noinspection ResultOfMethodCallIgnored getDataFolder().mkdirs(); WorldEdit worldEdit = WorldEdit.getInstance(); // Setup platform server = new BukkitServerInterface(this, getServer()); worldEdit.getPlatformManager().register(server); loadAdapter(); // Need an adapter to work with special blocks with NBT data worldEdit.loadMappings(); loadConfig(); // Load configuration PermissionsResolverManager.initialize(this); // Setup permission resolver // Register CUI getServer().getMessenger().registerIncomingPluginChannel(this, CUI_PLUGIN_CHANNEL, new CUIChannelListener(this)); getServer().getMessenger().registerOutgoingPluginChannel(this, CUI_PLUGIN_CHANNEL); // Now we can register events getServer().getPluginManager().registerEvents(new WorldEditListener(this), this); // If we are on MCPC+/Cauldron, then Forge will have already loaded // Forge WorldEdit and there's (probably) not going to be any other // platforms to be worried about... at the current time of writing WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); // Enable metrics new Metrics(this); }
public PasteSchematicEvent(Instruction instruction) throws InstructionParseException { super(instruction); loc = instruction.getLocation(); we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"); File folder = new File(we.getDataFolder(), "schematics"); if (!folder.exists() || !folder.isDirectory()) { throw new InstructionParseException("Schematic folder does not exist"); } String schemName = instruction.next(); file = new File(folder, schemName + ".schematic"); if (!file.exists()) { throw new InstructionParseException("Schematic " + schemName + " does not exist"); } noAir = instruction.hasArgument("noair"); }