mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 18:47:44 +01:00
Removed the block lag fix and cleaned up code.
This commit is contained in:
parent
84ccabdf34
commit
ffa38f9fd1
@ -21,15 +21,10 @@
|
|||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Handler;
|
|
||||||
import java.util.logging.ConsoleHandler;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.logging.FileHandler;
|
|
||||||
import com.sk89q.worldguard.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event listener for Hey0's server mod.
|
* Event listener for Hey0's server mod.
|
||||||
@ -72,7 +67,6 @@ public class WorldGuardListener extends PluginListener {
|
|||||||
private boolean disableAllFire;
|
private boolean disableAllFire;
|
||||||
private boolean simulateSponge;
|
private boolean simulateSponge;
|
||||||
private int spongeRadius;
|
private int spongeRadius;
|
||||||
private boolean blockLagFix;
|
|
||||||
private boolean itemDurability;
|
private boolean itemDurability;
|
||||||
private Set<Integer> fireNoSpreadBlocks;
|
private Set<Integer> fireNoSpreadBlocks;
|
||||||
private Set<Integer> allowedLavaSpreadOver;
|
private Set<Integer> allowedLavaSpreadOver;
|
||||||
@ -142,7 +136,6 @@ public void loadConfiguration() {
|
|||||||
classicWater = properties.getBoolean("classic-water", false);
|
classicWater = properties.getBoolean("classic-water", false);
|
||||||
simulateSponge = properties.getBoolean("simulate-sponge", false);
|
simulateSponge = properties.getBoolean("simulate-sponge", false);
|
||||||
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
|
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
|
||||||
blockLagFix = properties.getBoolean("block-lag-fix", false);
|
|
||||||
itemDurability = properties.getBoolean("item-durability", true);
|
itemDurability = properties.getBoolean("item-durability", true);
|
||||||
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
||||||
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
||||||
@ -171,18 +164,18 @@ public void loadConfiguration() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// First load the blacklist data from worldguard-blacklist.txt
|
// First load the blacklist data from worldguard-blacklist.txt
|
||||||
Blacklist blacklist = new Blacklist();
|
Blacklist blist = new Blacklist();
|
||||||
blacklist.load(new File("worldguard-blacklist.txt"));
|
blist.load(new File("worldguard-blacklist.txt"));
|
||||||
|
|
||||||
// If the blacklist is empty, then set the field to null
|
// If the blacklist is empty, then set the field to null
|
||||||
// and save some resources
|
// and save some resources
|
||||||
if (blacklist.isEmpty()) {
|
if (blist.isEmpty()) {
|
||||||
this.blacklist = null;
|
this.blacklist = null;
|
||||||
} else {
|
} else {
|
||||||
this.blacklist = blacklist;
|
this.blacklist = blist;
|
||||||
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
logger.log(Level.INFO, "WorldGuard: Blacklist loaded.");
|
||||||
|
|
||||||
BlacklistLogger blacklistLogger = blacklist.getLogger();
|
BlacklistLogger blacklistLogger = blist.getLogger();
|
||||||
|
|
||||||
if (logDatabase) {
|
if (logDatabase) {
|
||||||
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table));
|
blacklistLogger.addHandler(new DatabaseLoggerHandler(dsn, user, pass, table));
|
||||||
@ -235,6 +228,7 @@ public void loadConfiguration() {
|
|||||||
* @param user
|
* @param user
|
||||||
* @return kick reason. null if you don't want to kick the player.
|
* @return kick reason. null if you don't want to kick the player.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String onLoginChecks(String user) {
|
public String onLoginChecks(String user) {
|
||||||
if (enforceOneSession) {
|
if (enforceOneSession) {
|
||||||
for (Player player : etc.getServer().getPlayerList()) {
|
for (Player player : etc.getServer().getPlayerList()) {
|
||||||
@ -252,6 +246,7 @@ public String onLoginChecks(String user) {
|
|||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onLogin(Player player) {
|
public void onLogin(Player player) {
|
||||||
if (stopFireSpread) {
|
if (stopFireSpread) {
|
||||||
player.sendMessage(Colors.Yellow + "Fire spread is currently globally disabled.");
|
player.sendMessage(Colors.Yellow + "Fire spread is currently globally disabled.");
|
||||||
@ -266,6 +261,7 @@ public void onLogin(Player player) {
|
|||||||
* @param split
|
* @param split
|
||||||
* @return false if you want the command to be parsed.
|
* @return false if you want the command to be parsed.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onCommand(Player player, String[] split) {
|
public boolean onCommand(Player player, String[] split) {
|
||||||
if (split[0].equalsIgnoreCase("/stopfire") &&
|
if (split[0].equalsIgnoreCase("/stopfire") &&
|
||||||
player.canUseCommand("/stopfire")) {
|
player.canUseCommand("/stopfire")) {
|
||||||
@ -299,6 +295,7 @@ public boolean onCommand(Player player, String[] split) {
|
|||||||
* @param split
|
* @param split
|
||||||
* @return false if you want the command to be parsed.
|
* @return false if you want the command to be parsed.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onConsoleCommand(String[] split) {
|
public boolean onConsoleCommand(String[] split) {
|
||||||
if (split[0].equalsIgnoreCase("fire-stop")) {
|
if (split[0].equalsIgnoreCase("fire-stop")) {
|
||||||
if (!stopFireSpread) {
|
if (!stopFireSpread) {
|
||||||
@ -335,6 +332,7 @@ public boolean onConsoleCommand(String[] split) {
|
|||||||
* @return true if you don't want the dropped item to be spawned in the
|
* @return true if you don't want the dropped item to be spawned in the
|
||||||
* world
|
* world
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onItemDrop(Player player, Item item) {
|
public boolean onItemDrop(Player player, Item item) {
|
||||||
if (itemDropBlacklist != null) {
|
if (itemDropBlacklist != null) {
|
||||||
int n = item.getItemId();
|
int n = item.getItemId();
|
||||||
@ -369,6 +367,7 @@ public boolean onItemDrop(Player player, Item item) {
|
|||||||
* item that was picked up
|
* item that was picked up
|
||||||
* @return true if you want to leave the item where it was
|
* @return true if you want to leave the item where it was
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onItemPickUp(Player player, Item item) {
|
public boolean onItemPickUp(Player player, Item item) {
|
||||||
if (blacklist != null && blacklist.hasOnAcquire()) {
|
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||||
if (!blacklist.onSilentAcquire(item.getItemId(), player)) {
|
if (!blacklist.onSilentAcquire(item.getItemId(), player)) {
|
||||||
@ -386,6 +385,7 @@ public boolean onItemPickUp(Player player, Item item) {
|
|||||||
* player who's inventory was modified
|
* player who's inventory was modified
|
||||||
* @return true if you want any changes to be reverted
|
* @return true if you want any changes to be reverted
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onInventoryChange(Player player) {
|
public boolean onInventoryChange(Player player) {
|
||||||
if (blacklist != null && blacklist.hasOnAcquire()) {
|
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||||
hl[] items = player.getInventory().getArray();
|
hl[] items = player.getInventory().getArray();
|
||||||
@ -419,6 +419,7 @@ public boolean onInventoryChange(Player player) {
|
|||||||
* @param itemInHand
|
* @param itemInHand
|
||||||
* @return false if you want the action to go through
|
* @return false if you want the action to go through
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked,
|
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked,
|
||||||
int itemInHand) {
|
int itemInHand) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null) {
|
||||||
@ -477,6 +478,7 @@ public void run() {
|
|||||||
* @param block
|
* @param block
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onBlockDestroy(Player player, Block block) {
|
public boolean onBlockDestroy(Player player, Block block) {
|
||||||
int type = block.getType();
|
int type = block.getType();
|
||||||
|
|
||||||
@ -490,88 +492,6 @@ public boolean onBlockDestroy(Player player, Block block) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockLagFix
|
|
||||||
&& type != 7 // Bedrock
|
|
||||||
&& type != 46 // TNT
|
|
||||||
&& type != 50 // Torch
|
|
||||||
&& type != 51 // Fire
|
|
||||||
&& type != 59 // Crops
|
|
||||||
&& type != 62 // Burning furnace
|
|
||||||
&& type != 64 // Wooden door
|
|
||||||
&& type != 69 // Lever
|
|
||||||
&& type != 71 // Iron door
|
|
||||||
&& type != 75 // Redstone torch
|
|
||||||
&& type != 76 // Redstone torch
|
|
||||||
&& type != 77 // Stone button
|
|
||||||
) {
|
|
||||||
|
|
||||||
// Check other plugins first to see if this block can be
|
|
||||||
// destroyed. Since this causes the hook to eventually call
|
|
||||||
// twice, we try to nullify it below
|
|
||||||
if (canDestroyBlock(player, block)) {
|
|
||||||
if (block.getStatus() == 3 && canBreakBlock(player, block)) {
|
|
||||||
int dropItem = type;
|
|
||||||
int count = 1;
|
|
||||||
|
|
||||||
if (type == 1) { dropItem = 4; } // Stone
|
|
||||||
else if (type == 2) { dropItem = 3; } // Grass
|
|
||||||
else if (type == 16) { dropItem = 263; } // Coal ore
|
|
||||||
else if (type == 18) { // Leaves
|
|
||||||
if (rand.nextDouble() > 0.95) {
|
|
||||||
dropItem = 6;
|
|
||||||
} else {
|
|
||||||
dropItem = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == 20) { dropItem = 0; } // Glass
|
|
||||||
else if (type == 43) { dropItem = 44; } // Double step
|
|
||||||
else if (type == 47) { dropItem = 0; } // Bookshelves
|
|
||||||
else if (type == 52) { dropItem = 0; } // Mob spawner
|
|
||||||
else if (type == 53) { dropItem = 5; } // Wooden stairs
|
|
||||||
else if (type == 55) { dropItem = 331; } // Redstone wire
|
|
||||||
else if (type == 56) { dropItem = 264; } // Diamond ore
|
|
||||||
else if (type == 60) { dropItem = 3; } // Soil
|
|
||||||
else if (type == 63) { dropItem = 323; } // Sign post
|
|
||||||
else if (type == 67) { dropItem = 4; } // Cobblestone stairs
|
|
||||||
else if (type == 68) { dropItem = 323; } // Wall sign
|
|
||||||
else if (type == 73) { dropItem = 331; count = 4; } // Redstone ore
|
|
||||||
else if (type == 74) { dropItem = 331; count = 4; } // Glowing redstone ore
|
|
||||||
else if (type == 78) { dropItem = 0; } // Snow
|
|
||||||
else if (type == 79) { dropItem = 0; } // Ice
|
|
||||||
else if (type == 82) { dropItem = 337; count = 4; } // Clay
|
|
||||||
else if (type == 83) { dropItem = 338; } // Reed
|
|
||||||
else if (type == 89) { dropItem = 348; } // Lightstone
|
|
||||||
|
|
||||||
etc.getServer().setBlockAt(0, block.getX(), block.getY(), block.getZ());
|
|
||||||
|
|
||||||
if (dropItem > 0) {
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(),
|
|
||||||
dropItem, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Drop flint with gravel
|
|
||||||
if (type == 13) {
|
|
||||||
if (rand.nextDouble() >= 0.9) {
|
|
||||||
etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(),
|
|
||||||
318, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now loop this hook back through!
|
|
||||||
simulateBlockDestroy(player, block);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// So we don't have double hook calls caused by the
|
|
||||||
// plugin/protection check
|
|
||||||
block.setType(0);
|
|
||||||
block.setStatus(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,6 +502,7 @@ else if (type == 18) { // Leaves
|
|||||||
* @param block
|
* @param block
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onBlockBreak(Player player, Block block) {
|
public boolean onBlockBreak(Player player, Block block) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null) {
|
||||||
if (!blacklist.onBreak(block, player)) {
|
if (!blacklist.onBreak(block, player)) {
|
||||||
@ -601,6 +522,7 @@ public boolean onBlockBreak(Player player, Block block) {
|
|||||||
* complex block that changed
|
* complex block that changed
|
||||||
* @return true if you want any changes to be reverted
|
* @return true if you want any changes to be reverted
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onComplexBlockChange(Player player, ComplexBlock complexBlock) {
|
public boolean onComplexBlockChange(Player player, ComplexBlock complexBlock) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null) {
|
||||||
if (complexBlock instanceof Chest) {
|
if (complexBlock instanceof Chest) {
|
||||||
@ -643,6 +565,7 @@ public boolean onComplexBlockChange(Player player, ComplexBlock complexBlock) {
|
|||||||
* complex block that's being sent
|
* complex block that's being sent
|
||||||
* @return true if you want the chest, furnace or sign to be empty
|
* @return true if you want the chest, furnace or sign to be empty
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onSendComplexBlock(Player player, ComplexBlock complexBlock) {
|
public boolean onSendComplexBlock(Player player, ComplexBlock complexBlock) {
|
||||||
if (blacklist != null) {
|
if (blacklist != null) {
|
||||||
if (complexBlock instanceof Chest) {
|
if (complexBlock instanceof Chest) {
|
||||||
@ -678,6 +601,7 @@ public boolean onSendComplexBlock(Player player, ComplexBlock complexBlock) {
|
|||||||
*
|
*
|
||||||
* @return true if you dont want the fire to ignite.
|
* @return true if you dont want the fire to ignite.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onIgnite(Block block, Player player) {
|
public boolean onIgnite(Block block, Player player) {
|
||||||
if (preventLavaFire && block.getStatus() == 1) {
|
if (preventLavaFire && block.getStatus() == 1) {
|
||||||
return true;
|
return true;
|
||||||
@ -722,6 +646,7 @@ public boolean onIgnite(Block block, Player player) {
|
|||||||
*
|
*
|
||||||
* @return true if you dont the block to explode.
|
* @return true if you dont the block to explode.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onExplode(Block block) {
|
public boolean onExplode(Block block) {
|
||||||
if (blockCreepers && block.getStatus() == 2) {
|
if (blockCreepers && block.getStatus() == 2) {
|
||||||
return true;
|
return true;
|
||||||
@ -747,6 +672,7 @@ public boolean onExplode(Block block) {
|
|||||||
*
|
*
|
||||||
* @return true if you dont want the substance to flow.
|
* @return true if you dont want the substance to flow.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public boolean onFlow(Block blockFrom, Block blockTo) {
|
public boolean onFlow(Block blockFrom, Block blockTo) {
|
||||||
int x = blockFrom.getX();
|
int x = blockFrom.getX();
|
||||||
int y = blockFrom.getY();
|
int y = blockFrom.getY();
|
||||||
@ -825,67 +751,11 @@ public boolean onBlockPhysics(Block block, boolean placed) {
|
|||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public void onDisconnect(Player player) {
|
public void onDisconnect(Player player) {
|
||||||
BlacklistEntry.forgetPlayer(player);
|
BlacklistEntry.forgetPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Simulate the block destroy hook.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param block
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean simulateBlockDestroy(Player player, Block block) {
|
|
||||||
plugin.toggleEnabled(); // Prevent infinite loop
|
|
||||||
try {
|
|
||||||
block.setStatus(3);;
|
|
||||||
return !(Boolean)etc.getLoader().callHook(PluginLoader.Hook.BLOCK_DESTROYED,
|
|
||||||
new Object[]{ player.getUser(), block });
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return true;
|
|
||||||
} finally {
|
|
||||||
plugin.toggleEnabled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a block can be broken.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param block
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean canBreakBlock(Player player, Block orig) {
|
|
||||||
try {
|
|
||||||
Block block = etc.getServer().getBlockAt(
|
|
||||||
orig.getX(), orig.getY(), orig.getZ());
|
|
||||||
return !(Boolean)etc.getLoader().callHook(PluginLoader.Hook.BLOCK_BROKEN,
|
|
||||||
new Object[]{ player.getUser(), block });
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a block can be destroyed.
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param block
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private boolean canDestroyBlock(Player player, Block block) {
|
|
||||||
plugin.toggleEnabled(); // Prevent infinite loop
|
|
||||||
try {
|
|
||||||
return !(Boolean)etc.getLoader().callHook(PluginLoader.Hook.BLOCK_DESTROYED,
|
|
||||||
new Object[]{ player.getUser(), block });
|
|
||||||
} catch (Throwable t) {
|
|
||||||
return true;
|
|
||||||
} finally {
|
|
||||||
plugin.toggleEnabled();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call to disable the plugin.
|
* Call to disable the plugin.
|
||||||
*/
|
*/
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldGuard
|
|
||||||
* 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.worldguard;
|
|
||||||
|
|
||||||
import java.util.logging.Formatter;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for formatting.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class ConsoleLogFormat extends Formatter {
|
|
||||||
public String format(LogRecord record) {
|
|
||||||
StringBuilder text = new StringBuilder();
|
|
||||||
Level level = record.getLevel();
|
|
||||||
|
|
||||||
if (level == Level.FINEST) {
|
|
||||||
text.append("[FINEST] ");
|
|
||||||
} else if (level == Level.FINER) {
|
|
||||||
text.append("[FINER] ");
|
|
||||||
} else if (level == Level.FINE) {
|
|
||||||
text.append("[FINE] ");
|
|
||||||
} else if (level == Level.INFO) {
|
|
||||||
text.append("[INFO] ");
|
|
||||||
} else if (level == Level.WARNING) {
|
|
||||||
text.append("[WARNING] ");
|
|
||||||
} else if (level == Level.SEVERE) {
|
|
||||||
text.append("[SEVERE] ");
|
|
||||||
}
|
|
||||||
|
|
||||||
text.append(record.getMessage());
|
|
||||||
text.append("\r\n");
|
|
||||||
|
|
||||||
Throwable t = record.getThrown();
|
|
||||||
if (t != null) {
|
|
||||||
StringWriter writer = new StringWriter();
|
|
||||||
t.printStackTrace(new PrintWriter(writer));
|
|
||||||
text.append(writer.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return text.toString();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
// $Id$
|
|
||||||
/*
|
|
||||||
* WorldGuard
|
|
||||||
* 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.worldguard;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.logging.Formatter;
|
|
||||||
import java.util.logging.LogRecord;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for formatting.
|
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
|
||||||
public class SimpleLogFormat extends Formatter {
|
|
||||||
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
public String format(LogRecord record) {
|
|
||||||
StringBuilder text = new StringBuilder();
|
|
||||||
Level level = record.getLevel();
|
|
||||||
|
|
||||||
text.append("[");
|
|
||||||
text.append(dateFormat.format(new Date(record.getMillis())));
|
|
||||||
text.append("] ");
|
|
||||||
text.append(record.getMessage());
|
|
||||||
text.append("\r\n");
|
|
||||||
|
|
||||||
return text.toString();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user