mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Make sure all WorldEdit files are in the plugins/WorldEdit folder
This commit is contained in:
@ -21,23 +21,54 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* YAMLConfiguration but with setting for no op permissions.
|
||||
* YAMLConfiguration but with setting for no op permissions and plugin root data folder
|
||||
*/
|
||||
public class BukkitConfiguration extends YAMLConfiguration {
|
||||
|
||||
public boolean noOpPermissions = false;
|
||||
private final WorldEditPlugin plugin;
|
||||
|
||||
public BukkitConfiguration(YAMLProcessor config, Logger logger) {
|
||||
super(config, logger);
|
||||
public BukkitConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||
super(config, plugin.getLogger());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
||||
migrateLegacyFolders();
|
||||
}
|
||||
|
||||
private void migrateLegacyFolders() {
|
||||
migrate(scriptsDir, "craftscripts");
|
||||
migrate(saveDir, "schematics");
|
||||
migrate("drawings", "draw.js images");
|
||||
}
|
||||
|
||||
private void migrate(String file, String name) {
|
||||
File fromDir = new File(".", file);
|
||||
File toDir = new File(getWorkingDirectory(), file);
|
||||
if (fromDir.exists() & !toDir.exists()) {
|
||||
try {
|
||||
FileUtils.moveDirectory(fromDir, toDir);
|
||||
plugin.getLogger().info("Migrated " + name + " folder '" + file +
|
||||
"' from server root to plugin data folder." );
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("Error while migrating " + name + " folder: " +
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDirectory() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
@ -53,11 +52,6 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
*/
|
||||
public static final String CUI_PLUGIN_CHANNEL = "WECUI";
|
||||
|
||||
/**
|
||||
* WorldEdit messages get sent here.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
@ -100,7 +94,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), logger);
|
||||
config = new BukkitConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
PermissionsResolverManager.initialize(this);
|
||||
|
||||
// Load the configuration
|
||||
@ -161,7 +155,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} catch (IOException e) {
|
||||
logger.severe(getDescription().getName() + ": Unable to read default configuration: " + name);
|
||||
getLogger().severe("Unable to read default configuration: " + name);
|
||||
}
|
||||
if (input != null) {
|
||||
FileOutputStream output = null;
|
||||
@ -174,8 +168,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
logger.info(getDescription().getName()
|
||||
+ ": Default configuration file written: " + name);
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
Reference in New Issue
Block a user