Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-05 19:10:07 +01:00
Fix command logging.
No seriously, was the previous code even supposed to work?
Dieser Commit ist enthalten in:
Ursprung
6c189c4ff9
Commit
79802bd4b9
@ -90,6 +90,7 @@ public abstract class LocalConfiguration {
|
|||||||
public int maxSuperPickaxeSize = 5;
|
public int maxSuperPickaxeSize = 5;
|
||||||
public int maxBrushRadius = 6;
|
public int maxBrushRadius = 6;
|
||||||
public boolean logCommands = false;
|
public boolean logCommands = false;
|
||||||
|
public String logFile = "";
|
||||||
public boolean registerHelp = true; // what is the point of this, it's not even used
|
public boolean registerHelp = true; // what is the point of this, it's not even used
|
||||||
public int wandItem = ItemID.WOOD_AXE;
|
public int wandItem = ItemID.WOOD_AXE;
|
||||||
public boolean superPickaxeDrop = true;
|
public boolean superPickaxeDrop = true;
|
||||||
|
@ -32,6 +32,8 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.logging.FileHandler;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ public class WorldEdit {
|
|||||||
* Logger for debugging.
|
* Logger for debugging.
|
||||||
*/
|
*/
|
||||||
public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
public static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||||
|
public final Logger commandLogger = Logger.getLogger("Minecraft.WorldEdit.CommandLogger");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the current instance of this class, for static access
|
* Holds the current instance of this class, for static access
|
||||||
@ -168,6 +171,19 @@ public class WorldEdit {
|
|||||||
this.server = server;
|
this.server = server;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
|
|
||||||
|
if (!config.logFile.equals("")) {
|
||||||
|
try {
|
||||||
|
FileHandler logFileHandler;
|
||||||
|
logFileHandler = new FileHandler(new File(config.getWorkingDirectory(),
|
||||||
|
config.logFile).getAbsolutePath(), true);
|
||||||
|
logFileHandler.setFormatter(new LogFormat());
|
||||||
|
commandLogger.addHandler(logFileHandler);
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.log(Level.WARNING, "Could not use command log file " + config.logFile + ": "
|
||||||
|
+ e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
commands = new CommandsManager<LocalPlayer>() {
|
commands = new CommandsManager<LocalPlayer>() {
|
||||||
@Override
|
@Override
|
||||||
protected void checkPermission(LocalPlayer player, Method method) throws CommandException {
|
protected void checkPermission(LocalPlayer player, Method method) throws CommandException {
|
||||||
@ -235,7 +251,7 @@ public class WorldEdit {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.info(msg);
|
commandLogger.info(msg);
|
||||||
}
|
}
|
||||||
super.invokeMethod(parent, args, player, method, instance, methodArgs, level);
|
super.invokeMethod(parent, args, player, method, instance, methodArgs, level);
|
||||||
}
|
}
|
||||||
|
@ -25,18 +25,31 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
import java.util.logging.Handler;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
|
||||||
import com.sk89q.wepif.PermissionsResolverManager;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.sk89q.worldedit.*;
|
|
||||||
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
|
import com.sk89q.wepif.PermissionsResolverManager;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.IncompleteRegionException;
|
||||||
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.WorldEditOperation;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.bags.BlockBag;
|
||||||
import com.sk89q.worldedit.bukkit.selections.*;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
import com.sk89q.worldedit.regions.*;
|
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||||
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
|
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for Bukkit.
|
* Plugin for Bukkit.
|
||||||
@ -71,6 +84,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called on plugin enable.
|
* Called on plugin enable.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
final String pluginYmlVersion = getDescription().getVersion();
|
final String pluginYmlVersion = getDescription().getVersion();
|
||||||
final String manifestVersion = WorldEdit.getVersion();
|
final String manifestVersion = WorldEdit.getVersion();
|
||||||
@ -110,6 +124,7 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* Called on plugin disable.
|
* Called on plugin disable.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
for (Player player : getServer().getOnlinePlayers()) {
|
for (Player player : getServer().getOnlinePlayers()) {
|
||||||
LocalPlayer lPlayer = wrapPlayer(player);
|
LocalPlayer lPlayer = wrapPlayer(player);
|
||||||
@ -118,6 +133,9 @@ public class WorldEditPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
controller.clearSessions();
|
controller.clearSessions();
|
||||||
|
for (Handler h : controller.commandLogger.getHandlers()) {
|
||||||
|
h.close();
|
||||||
|
}
|
||||||
config.unload();
|
config.unload();
|
||||||
server.unregisterCommands();
|
server.unregisterCommands();
|
||||||
this.getServer().getScheduler().cancelTasks(this);
|
this.getServer().getScheduler().cancelTasks(this);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.commands;
|
||||||
|
|
||||||
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -7,6 +9,7 @@ import java.util.Set;
|
|||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.BiomeType;
|
import com.sk89q.worldedit.BiomeType;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
@ -124,6 +127,7 @@ public class BiomeCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.biome.set")
|
@CommandPermissions("worldedit.biome.set")
|
||||||
public void setBiome(CommandContext args, LocalSession session, LocalPlayer player,
|
public void setBiome(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
@ -151,6 +151,7 @@ public class RegionCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.region.center")
|
@CommandPermissions("worldedit.region.center")
|
||||||
public void center(CommandContext args, LocalSession session, LocalPlayer player,
|
public void center(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
@ -19,12 +19,16 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.commands;
|
||||||
|
|
||||||
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
@ -66,6 +70,7 @@ public class SnapshotUtilCommands {
|
|||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
|
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
@ -19,18 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.util;
|
package com.sk89q.worldedit.util;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
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 java.util.logging.Logger;
|
||||||
|
|
||||||
import com.sk89q.util.yaml.YAMLProcessor;
|
import com.sk89q.util.yaml.YAMLProcessor;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.LogFormat;
|
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,7 +36,6 @@ import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
|||||||
public class YAMLConfiguration extends LocalConfiguration {
|
public class YAMLConfiguration extends LocalConfiguration {
|
||||||
protected final YAMLProcessor config;
|
protected final YAMLProcessor config;
|
||||||
protected final Logger logger;
|
protected final Logger logger;
|
||||||
private FileHandler logFileHandler;
|
|
||||||
|
|
||||||
public YAMLConfiguration(YAMLProcessor config, Logger logger) {
|
public YAMLConfiguration(YAMLProcessor config, Logger logger) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@ -60,30 +54,45 @@ public class YAMLConfiguration extends LocalConfiguration {
|
|||||||
|
|
||||||
profile = config.getBoolean("debug", profile);
|
profile = config.getBoolean("debug", profile);
|
||||||
wandItem = config.getInt("wand-item", wandItem);
|
wandItem = config.getInt("wand-item", wandItem);
|
||||||
|
|
||||||
defaultChangeLimit = Math.max(-1, config.getInt(
|
defaultChangeLimit = Math.max(-1, config.getInt(
|
||||||
"limits.max-blocks-changed.default", defaultChangeLimit));
|
"limits.max-blocks-changed.default", defaultChangeLimit));
|
||||||
maxChangeLimit = Math.max(-1,
|
maxChangeLimit = Math.max(-1,
|
||||||
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
|
config.getInt("limits.max-blocks-changed.maximum", maxChangeLimit));
|
||||||
|
|
||||||
defaultMaxPolygonalPoints = Math.max(-1,
|
defaultMaxPolygonalPoints = Math.max(-1,
|
||||||
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
|
config.getInt("limits.max-polygonal-points.default", defaultMaxPolygonalPoints));
|
||||||
maxPolygonalPoints = Math.max(-1,
|
maxPolygonalPoints = Math.max(-1,
|
||||||
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
|
config.getInt("limits.max-polygonal-points.maximum", maxPolygonalPoints));
|
||||||
|
|
||||||
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
|
maxRadius = Math.max(-1, config.getInt("limits.max-radius", maxRadius));
|
||||||
|
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
||||||
maxSuperPickaxeSize = Math.max(1, config.getInt(
|
maxSuperPickaxeSize = Math.max(1, config.getInt(
|
||||||
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
|
"limits.max-super-pickaxe-size", maxSuperPickaxeSize));
|
||||||
|
|
||||||
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
|
butcherDefaultRadius = Math.max(-1, config.getInt("limits.butcher-radius.default", butcherDefaultRadius));
|
||||||
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
|
butcherMaxRadius = Math.max(-1, config.getInt("limits.butcher-radius.maximum", butcherMaxRadius));
|
||||||
|
|
||||||
|
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
||||||
|
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
|
||||||
|
|
||||||
|
allowExtraDataValues = config.getBoolean("limits.allow-extra-data-values", false);
|
||||||
|
|
||||||
|
|
||||||
registerHelp = config.getBoolean("register-help", true);
|
registerHelp = config.getBoolean("register-help", true);
|
||||||
logCommands = config.getBoolean("logging.log-commands", logCommands);
|
logCommands = config.getBoolean("logging.log-commands", logCommands);
|
||||||
|
logFile = config.getString("logging.file", logFile);
|
||||||
|
|
||||||
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
|
superPickaxeDrop = config.getBoolean("super-pickaxe.drop-items",
|
||||||
superPickaxeDrop);
|
superPickaxeDrop);
|
||||||
superPickaxeManyDrop = config.getBoolean(
|
superPickaxeManyDrop = config.getBoolean(
|
||||||
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
|
"super-pickaxe.many-drop-items", superPickaxeManyDrop);
|
||||||
|
|
||||||
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
|
noDoubleSlash = config.getBoolean("no-double-slash", noDoubleSlash);
|
||||||
|
|
||||||
useInventory = config.getBoolean("use-inventory.enable", useInventory);
|
useInventory = config.getBoolean("use-inventory.enable", useInventory);
|
||||||
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
|
||||||
useInventoryOverride);
|
useInventoryOverride);
|
||||||
maxBrushRadius = config.getInt("limits.max-brush-radius", maxBrushRadius);
|
|
||||||
|
|
||||||
navigationWand = config.getInt("navigation-wand.item", navigationWand);
|
navigationWand = config.getInt("navigation-wand.item", navigationWand);
|
||||||
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);
|
||||||
@ -94,13 +103,6 @@ public class YAMLConfiguration extends LocalConfiguration {
|
|||||||
saveDir = config.getString("saving.dir", saveDir);
|
saveDir = config.getString("saving.dir", saveDir);
|
||||||
|
|
||||||
allowSymlinks = config.getBoolean("files.allow-symbolic-links", false);
|
allowSymlinks = config.getBoolean("files.allow-symbolic-links", false);
|
||||||
|
|
||||||
disallowedBlocks = new HashSet<Integer>(config.getIntList("limits.disallowed-blocks", null));
|
|
||||||
|
|
||||||
allowedDataCycleBlocks = new HashSet<Integer>(config.getIntList("limits.allowed-data-cycle-blocks", null));
|
|
||||||
|
|
||||||
allowExtraDataValues = config.getBoolean("limits.allow-extra-data-values", false);
|
|
||||||
|
|
||||||
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
LocalSession.MAX_HISTORY_SIZE = Math.max(0, config.getInt("history.size", 15));
|
||||||
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
LocalSession.EXPIRATION_GRACE = config.getInt("history.expiration", 10) * 60 * 1000;
|
||||||
|
|
||||||
@ -112,27 +114,8 @@ public class YAMLConfiguration extends LocalConfiguration {
|
|||||||
String type = config.getString("shell-save-type", "").trim();
|
String type = config.getString("shell-save-type", "").trim();
|
||||||
shellSaveType = type.equals("") ? null : type;
|
shellSaveType = type.equals("") ? null : type;
|
||||||
|
|
||||||
String logFile = config.getString("logging.file", "");
|
|
||||||
if (!logFile.equals("")) {
|
|
||||||
try {
|
|
||||||
logFileHandler = new FileHandler(new File(getWorkingDirectory(),
|
|
||||||
logFile).getAbsolutePath(), true);
|
|
||||||
logFileHandler.setFormatter(new LogFormat());
|
|
||||||
logger.addHandler(logFileHandler);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.log(Level.WARNING, "Could not use log file " + logFile + ": "
|
|
||||||
+ e.getMessage());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (Handler handler : logger.getHandlers()) {
|
|
||||||
logger.removeHandler(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unload() {
|
public void unload() {
|
||||||
if (logFileHandler != null) {
|
|
||||||
logFileHandler.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren