mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-02 02:47:11 +00:00
Make sure all WorldEdit files are in the plugins/WorldEdit folder
This commit is contained in:
parent
a4895cbd5d
commit
73dbbbac9a
@ -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 {
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author zml2008
|
||||
*/
|
||||
public class SpoutConfiguration extends YAMLConfiguration {
|
||||
private final WorldEditPlugin plugin;
|
||||
public SpoutConfiguration(YAMLProcessor config, WorldEditPlugin plugin) {
|
||||
super(config, plugin.getLogger());
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorkingDirectory() {
|
||||
return plugin.getDataFolder();
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditPlayerListener implements Listener {
|
||||
public class WorldEditListener implements Listener {
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
@ -61,7 +61,7 @@ public class WorldEditPlayerListener implements Listener {
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditPlayerListener(WorldEditPlugin plugin) {
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
@ -49,10 +49,6 @@ import java.util.zip.ZipEntry;
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
/**
|
||||
* WorldEdit messages get sent here.
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
@ -80,7 +76,7 @@ public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
final String pluginYmlVersion = getDescription().getVersion();
|
||||
final String manifestVersion = WorldEdit.getVersion();
|
||||
|
||||
logger.info("WorldEdit " + pluginYmlVersion + " enabled.");
|
||||
getLogger().info("WorldEdit " + pluginYmlVersion + " enabled.");
|
||||
if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
|
||||
}
|
||||
@ -93,7 +89,7 @@ public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new YAMLConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), logger);
|
||||
config = new SpoutConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
|
||||
// Load the configuration
|
||||
loadConfiguration();
|
||||
@ -136,7 +132,7 @@ public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
* Register the events used by WorldEdit.
|
||||
*/
|
||||
protected void registerEvents() {
|
||||
getGame().getEventManager().registerEvents(new WorldEditPlayerListener(this), this);
|
||||
getGame().getEventManager().registerEvents(new WorldEditListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,7 +151,7 @@ public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
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;
|
||||
@ -168,22 +164,19 @@ public class WorldEditPlugin extends CommonPlugin implements Named {
|
||||
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 {
|
||||
try {
|
||||
if (input != null) {
|
||||
input.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
input.close();
|
||||
} catch (IOException ignore) {}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.LogFormat;
|
||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.FileHandler;
|
||||
@ -105,7 +106,8 @@ public class YAMLConfiguration extends LocalConfiguration {
|
||||
String logFile = config.getString("logging.file", "");
|
||||
if (!logFile.equals("")) {
|
||||
try {
|
||||
logFileHandler = new FileHandler(logFile, true);
|
||||
logFileHandler = new FileHandler(new File(getWorkingDirectory(),
|
||||
logFile).getAbsolutePath(), true);
|
||||
logFileHandler.setFormatter(new LogFormat());
|
||||
logger.addHandler(logFileHandler);
|
||||
} catch (IOException e) {
|
||||
|
Loading…
Reference in New Issue
Block a user