2011-01-16 21:19:29 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
|
|
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
|
|
|
*
|
|
|
|
* 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.bukkit;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.logging.FileHandler;
|
|
|
|
import java.util.logging.Handler;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
import org.bukkit.util.config.Configuration;
|
|
|
|
import com.sk89q.worldedit.LocalConfiguration;
|
2011-02-19 05:57:43 +00:00
|
|
|
import com.sk89q.worldedit.LocalSession;
|
2011-01-16 21:19:29 +00:00
|
|
|
import com.sk89q.worldedit.LogFormat;
|
|
|
|
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
|
|
|
|
|
|
|
public class BukkitConfiguration extends LocalConfiguration {
|
|
|
|
private Configuration config;
|
|
|
|
private Logger logger;
|
2011-05-08 04:57:08 +00:00
|
|
|
private FileHandler logFileHandler;
|
2011-01-16 21:19:29 +00:00
|
|
|
|
2011-02-19 09:25:08 +00:00
|
|
|
public boolean noOpPermissions = false;
|
|
|
|
|
2011-01-16 21:19:29 +00:00
|
|
|
public BukkitConfiguration(Configuration config, Logger logger) {
|
|
|
|
this.config = config;
|
|
|
|
this.logger = logger;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void load() {
|
2011-01-31 08:58:29 +00:00
|
|
|
showFirstUseVersion = false;
|
|
|
|
|
2011-01-16 21:19:29 +00:00
|
|
|
profile = config.getBoolean("debug", profile);
|
|
|
|
wandItem = config.getInt("wand-item", wandItem);
|
|
|
|
defaultChangeLimit = Math.max(-1, config.getInt(
|
|
|
|
"limits.max-blocks-changed.default", defaultChangeLimit));
|
|
|
|
maxChangeLimit = Math.max(-1,
|
|
|
|
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
|
|
|
|
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
|
|
|
|
maxSuperPickaxeSize = Math.max(1, config.getInt(
|
|
|
|
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
|
|
|
|
registerHelp = true;
|
2011-01-27 17:07:50 +00:00
|
|
|
logCommands = config.getBoolean("logging.log-commands", logCommands);
|
2011-01-16 21:19:29 +00:00
|
|
|
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
|
|
|
|
superPickaxeDrop);
|
|
|
|
superPickaxeManyDrop = config.getBoolean(
|
|
|
|
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
|
|
|
|
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
|
|
|
|
useInventory = config.getBoolean("use-inventory.enable", useInventory);
|
|
|
|
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
|
|
|
useInventoryOverride);
|
|
|
|
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
2011-01-19 10:49:20 +00:00
|
|
|
|
|
|
|
navigationWand = config.getInt("navigation-wand.item", navigationWand);
|
|
|
|
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
2011-01-16 21:19:29 +00:00
|
|
|
|
2011-01-22 21:34:05 +00:00
|
|
|
scriptTimeout = config.getInt("scripting.timeout", scriptTimeout);
|
2011-01-29 18:14:04 +00:00
|
|
|
scriptsDir = config.getString("scripting.dir", scriptsDir);
|
|
|
|
|
|
|
|
saveDir = config.getString("saving.dir", saveDir);
|
2011-01-22 21:34:05 +00:00
|
|
|
|
2011-01-16 21:36:36 +00:00
|
|
|
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
2011-01-16 21:19:29 +00:00
|
|
|
|
2011-01-30 06:07:56 +00:00
|
|
|
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
|
2011-02-19 09:25:08 +00:00
|
|
|
|
|
|
|
noOpPermissions = config.getBoolean("no-op-permissions", false);
|
2011-01-30 06:07:56 +00:00
|
|
|
|
2011-05-29 15:06:32 +00:00
|
|
|
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
2011-05-02 00:37:05 +00:00
|
|
|
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
2011-02-19 05:57:43 +00:00
|
|
|
|
2011-01-16 21:36:36 +00:00
|
|
|
String snapshotsDir = config.getString("snapshots.directory", "");
|
2011-08-05 10:29:49 +00:00
|
|
|
if (!snapshotsDir.isEmpty()){
|
2011-01-16 21:19:29 +00:00
|
|
|
snapshotRepo = new SnapshotRepository(snapshotsDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
String type = config.getString("shell-save-type", "").trim();
|
|
|
|
shellSaveType = type.equals("") ? null : type;
|
|
|
|
|
|
|
|
String logFile = config.getString("logging.file", "");
|
|
|
|
if (!logFile.equals("")) {
|
|
|
|
try {
|
2011-05-08 04:57:08 +00:00
|
|
|
logFileHandler = new FileHandler(logFile, true);
|
|
|
|
logFileHandler.setFormatter(new LogFormat());
|
|
|
|
logger.addHandler(logFileHandler);
|
2011-01-16 21:19:29 +00:00
|
|
|
} catch (IOException e) {
|
|
|
|
logger.log(Level.WARNING, "Could not use log file " + logFile + ": "
|
|
|
|
+ e.getMessage());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (Handler handler : logger.getHandlers()) {
|
|
|
|
logger.removeHandler(handler);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-05-08 04:57:08 +00:00
|
|
|
|
|
|
|
public void unload() {
|
|
|
|
if (logFileHandler != null) {
|
|
|
|
logFileHandler.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-16 21:19:29 +00:00
|
|
|
}
|