Some minor code refactoring and cleanup courtesy of Zeluboba, taken in desired bits referenced from his larger pull request here:

https://github.com/Brettflan/WorldBorder/pull/32/files
This commit is contained in:
Brettflan 2014-02-17 06:37:18 -06:00
parent 6eecf93a53
commit 9e7e9d0682
9 changed files with 88 additions and 96 deletions

View File

@ -79,7 +79,7 @@ public class BorderCheckTask implements Runnable
Location rideLoc = newLoc.clone();
rideLoc.setY(newLoc.getY() + vertOffset);
if (Config.Debug())
Config.LogWarn("Player was riding a \"" + ride.toString() + "\".");
Config.logWarn("Player was riding a \"" + ride.toString() + "\".");
if (ride instanceof Boat)
{ // boats currently glitch on client when teleported, so crappy workaround is to remove it and spawn a new one
ride.remove();
@ -122,8 +122,8 @@ public class BorderCheckTask implements Runnable
{
if (Config.Debug())
{
Config.LogWarn((notify ? "Border crossing" : "Check was run") + " in \"" + loc.getWorld().getName() + "\". Border " + border.toString());
Config.LogWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
Config.logWarn((notify ? "Border crossing" : "Check was run") + " in \"" + loc.getWorld().getName() + "\". Border " + border.toString());
Config.logWarn("Player position X: " + Config.coord.format(loc.getX()) + " Y: " + Config.coord.format(loc.getY()) + " Z: " + Config.coord.format(loc.getZ()));
}
Location newLoc = border.correctedPosition(loc, Config.ShapeRound(), player.isFlying());
@ -132,7 +132,7 @@ public class BorderCheckTask implements Runnable
if (newLoc == null)
{
if (Config.Debug())
Config.LogWarn("Target new location unviable, using spawn or killing player.");
Config.logWarn("Target new location unviable, using spawn or killing player.");
if (Config.getIfPlayerKill())
{
player.setHealth(0.0D);
@ -142,7 +142,7 @@ public class BorderCheckTask implements Runnable
}
if (Config.Debug())
Config.LogWarn("New position in world \"" + newLoc.getWorld().getName() + "\" at X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
Config.logWarn("New position in world \"" + newLoc.getWorld().getName() + "\" at X: " + Config.coord.format(newLoc.getX()) + " Y: " + Config.coord.format(newLoc.getY()) + " Z: " + Config.coord.format(newLoc.getZ()));
if (notify)
player.sendMessage(Config.Message());

View File

@ -4,7 +4,6 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.logging.Level;
@ -15,6 +14,7 @@ import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.entity.Player;
import org.bukkit.Location;
@ -26,7 +26,7 @@ public class Config
// private stuff used within this class
private static WorldBorder plugin;
private static FileConfiguration cfg = null;
private static final Logger mcLog = Logger.getLogger("Minecraft");
private static Logger wbLog = null;
public static DecimalFormat coord = new DecimalFormat("0.0");
private static int borderTask = -1;
public static WorldFillTask fillTask;
@ -65,7 +65,7 @@ public class Config
public static void setBorder(String world, BorderData border)
{
borders.put(world, border);
Log("Border set. " + BorderDescription(world));
log("Border set. " + BorderDescription(world));
save(true);
DynMapFeatures.showBorder(world, border);
}
@ -73,14 +73,14 @@ public class Config
public static void setBorder(String world, int radiusX, int radiusZ, double x, double z, Boolean shapeRound)
{
BorderData old = Border(world);
boolean oldWrap = (old == null) ? false : old.getWrapping();
boolean oldWrap = (old != null) && old.getWrapping();
setBorder(world, new BorderData(x, z, radiusX, radiusZ, shapeRound, oldWrap));
}
public static void setBorder(String world, int radiusX, int radiusZ, double x, double z)
{
BorderData old = Border(world);
Boolean oldShape = (old == null) ? null : old.getShape();
boolean oldWrap = (old == null) ? false : old.getWrapping();
boolean oldWrap = (old != null) && old.getWrapping();
setBorder(world, new BorderData(x, z, radiusX, radiusZ, oldShape, oldWrap));
}
@ -113,7 +113,7 @@ public class Config
{
BorderData old = Border(world);
Boolean oldShape = (old == null) ? null : old.getShape();
boolean oldWrap = (old == null) ? false : old.getWrapping();
boolean oldWrap = (old != null) && old.getWrapping();
setBorderCorners(world, x1, z1, x2, z2, oldShape, oldWrap);
}
@ -121,7 +121,7 @@ public class Config
public static void removeBorder(String world)
{
borders.remove(world);
Log("Removed border for world \"" + world + "\".");
log("Removed border for world \"" + world + "\".");
save(true);
DynMapFeatures.removeBorder(world);
}
@ -129,7 +129,7 @@ public class Config
public static void removeAllBorders()
{
borders.clear();
Log("Removed all borders for all worlds.");
log("Removed all borders for all worlds.");
save(true);
DynMapFeatures.removeAllBorders();
}
@ -147,10 +147,9 @@ public class Config
{
Set<String> output = new HashSet<String>();
Iterator world = borders.keySet().iterator();
while(world.hasNext())
for(String worldName : borders.keySet())
{
output.add( BorderDescription((String)world.next()) );
output.add(BorderDescription(worldName));
}
return output;
@ -169,7 +168,7 @@ public class Config
public static void setMessage(String msg)
{
updateMessage(msg);
Log("Border message is now set to: " + MessageRaw());
log("Border message is now set to: " + MessageRaw());
save(true);
}
@ -196,7 +195,7 @@ public class Config
public static void setShape(boolean round)
{
shapeRound = round;
Log("Set default border shape to " + (ShapeName()) + ".");
log("Set default border shape to " + (ShapeName()) + ".");
save(true);
DynMapFeatures.showAllBorders();
}
@ -218,7 +217,7 @@ public class Config
public static void setDebug(boolean debugMode)
{
DEBUG = debugMode;
Log("Debug mode " + (DEBUG ? "enabled" : "disabled") + ".");
log("Debug mode " + (DEBUG ? "enabled" : "disabled") + ".");
save(true);
}
@ -230,7 +229,7 @@ public class Config
public static void setWhooshEffect(boolean enable)
{
whooshEffect = enable;
Log("\"Whoosh\" knockback effect " + (enable ? "enabled" : "disabled") + ".");
log("\"Whoosh\" knockback effect " + (enable ? "enabled" : "disabled") + ".");
save(true);
}
@ -266,14 +265,14 @@ public class Config
public static void setDenyEnderpearl(boolean enable)
{
denyEnderpearl = enable;
Log("Direct cancellation of ender pearls thrown past the border " + (enable ? "enabled" : "disabled") + ".");
log("Direct cancellation of ender pearls thrown past the border " + (enable ? "enabled" : "disabled") + ".");
save(true);
}
public static void setPortalRedirection(boolean enable)
{
portalRedirection = enable;
Log("Portal redirection " + (enable ? "enabled" : "disabled") + ".");
log("Portal redirection " + (enable ? "enabled" : "disabled") + ".");
save(true);
}
@ -285,7 +284,7 @@ public class Config
public static void setKnockBack(double numBlocks)
{
knockBack = numBlocks;
Log("Knockback set to " + knockBack + " blocks inside the border.");
log("Knockback set to " + knockBack + " blocks inside the border.");
save(true);
}
@ -297,7 +296,7 @@ public class Config
public static void setTimerTicks(int ticks)
{
timerTicks = ticks;
Log("Timer delay set to " + timerTicks + " tick(s). That is roughly " + (timerTicks * 50) + "ms / " + (((double)timerTicks * 50.0) / 1000.0) + " seconds.");
log("Timer delay set to " + timerTicks + " tick(s). That is roughly " + (timerTicks * 50) + "ms / " + (((double)timerTicks * 50.0) / 1000.0) + " seconds.");
StartBorderTimer();
save(true);
}
@ -311,11 +310,11 @@ public class Config
{
remountDelayTicks = ticks;
if (remountDelayTicks == 0)
Log("Remount delay set to 0. Players will be left dismounted when knocked back from the border while on a vehicle.");
log("Remount delay set to 0. Players will be left dismounted when knocked back from the border while on a vehicle.");
else
Log("Remount delay set to " + remountDelayTicks + " tick(s). That is roughly " + (remountDelayTicks * 50) + "ms / " + (((double)remountDelayTicks * 50.0) / 1000.0) + " seconds.");
log("Remount delay set to " + remountDelayTicks + " tick(s). That is roughly " + (remountDelayTicks * 50) + "ms / " + (((double)remountDelayTicks * 50.0) / 1000.0) + " seconds.");
if (ticks < 10)
LogWarn("setting the remount delay to less than 10 (and greater than 0) is not recommended. This can lead to nasty client glitches.");
logWarn("setting the remount delay to less than 10 (and greater than 0) is not recommended. This can lead to nasty client glitches.");
save(true);
}
@ -328,9 +327,9 @@ public class Config
{
fillAutosaveFrequency = seconds;
if (fillAutosaveFrequency == 0)
Log("World autosave frequency during Fill process set to 0, disabling it. Note that much progress can be lost this way if there is a bug or crash in the world generation process from Bukkit or any world generation plugin you use.");
log("World autosave frequency during Fill process set to 0, disabling it. Note that much progress can be lost this way if there is a bug or crash in the world generation process from Bukkit or any world generation plugin you use.");
else
Log("World autosave frequency during Fill process set to " + fillAutosaveFrequency + " seconds (rounded to a multiple of 5). New chunks generated by the Fill process will be forcibly saved to disk this often to prevent loss of progress due to bugs or crashes in the world generation process.");
log("World autosave frequency during Fill process set to " + fillAutosaveFrequency + " seconds (rounded to a multiple of 5). New chunks generated by the Fill process will be forcibly saved to disk this often to prevent loss of progress due to bugs or crashes in the world generation process.");
save(true);
}
@ -343,7 +342,7 @@ public class Config
public static void setDynmapBorderEnabled(boolean enable)
{
dynmapEnable = enable;
Log("DynMap border display is now " + (enable ? "enabled" : "disabled") + ".");
log("DynMap border display is now " + (enable ? "enabled" : "disabled") + ".");
save(true);
DynMapFeatures.showAllBorders();
}
@ -356,7 +355,7 @@ public class Config
public static void setDynmapMessage(String msg)
{
dynmapMessage = msg;
Log("DynMap border label is now set to: " + msg);
log("DynMap border label is now set to: " + msg);
save(true);
DynMapFeatures.showAllBorders();
}
@ -407,9 +406,9 @@ public class Config
borderTask = plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new BorderCheckTask(), timerTicks, timerTicks);
if (borderTask == -1)
LogWarn("Failed to start timed border-checking task! This will prevent the plugin from working. Try restarting Bukkit.");
logWarn("Failed to start timed border-checking task! This will prevent the plugin from working. Try restarting Bukkit.");
LogConfig("Border-checking timed task started.");
logConfig("Border-checking timed task started.");
}
public static void StopBorderTimer()
@ -418,7 +417,7 @@ public class Config
plugin.getServer().getScheduler().cancelTask(borderTask);
borderTask = -1;
LogConfig("Border-checking timed task stopped.");
logConfig("Border-checking timed task stopped.");
}
public static void StopFillTask()
@ -490,33 +489,32 @@ public class Config
}
// adapted from code posted by Sleaker
public static String replaceAmpColors (String message)
{
return message.replaceAll("(?i)&([a-fk-or0-9])", "\u00A7$1");
return ChatColor.translateAlternateColorCodes('&', message);
}
// adapted from code posted by Sleaker
public static String stripAmpColors (String message)
{
return message.replaceAll("(?i)&([a-fk-or0-9])", "");
}
private static final String logName = "WorldBorder";
public static void Log(Level lvl, String text)
public static void log(Level lvl, String text)
{
mcLog.log(lvl, String.format("[%s] %s", logName, text));
wbLog.log(lvl, text);
}
public static void Log(String text)
public static void log(String text)
{
Log(Level.INFO, text);
log(Level.INFO, text);
}
public static void LogWarn(String text)
public static void logWarn(String text)
{
Log(Level.WARNING, text);
log(Level.WARNING, text);
}
public static void LogConfig(String text)
public static void logConfig(String text)
{
Log(Level.INFO, "[CONFIG] " + text);
log(Level.INFO, "[CONFIG] " + text);
}
@ -525,6 +523,7 @@ public class Config
public static void load(WorldBorder master, boolean logIt)
{ // load config from file
plugin = master;
wbLog = plugin.getLogger();
plugin.reloadConfig();
cfg = plugin.getConfig();
@ -541,7 +540,7 @@ public class Config
remountDelayTicks = cfg.getInt("remount-delay-ticks", 0);
dynmapEnable = cfg.getBoolean("dynmap-border-enabled", true);
dynmapMessage = cfg.getString("dynmap-border-message", "The border of the world.");
LogConfig("Using " + (ShapeName()) + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
logConfig("Using " + (ShapeName()) + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
killPlayer = cfg.getBoolean("player-killed-bad-spawn", false);
denyEnderpearl = cfg.getBoolean("deny-enderpearl", true);
fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30);
@ -555,7 +554,7 @@ public class Config
// if empty border message, assume no config
if (msg == null || msg.isEmpty())
{ // store defaults
LogConfig("Configuration not present, creating new file.");
logConfig("Configuration not present, creating new file.");
msg = "&cYou have reached the edge of this world.";
updateMessage(msg);
save(false);
@ -593,7 +592,7 @@ public class Config
boolean wrap = (boolean) bord.getBoolean("wrapping", false);
BorderData border = new BorderData(bord.getDouble("x", 0), bord.getDouble("z", 0), bord.getInt("radiusX", 0), bord.getInt("radiusZ", 0), overrideShape, wrap);
borders.put(worldName, border);
LogConfig(BorderDescription(worldName));
logConfig(BorderDescription(worldName));
}
}
@ -615,7 +614,7 @@ public class Config
}
if (logIt)
LogConfig("Configuration loaded.");
logConfig("Configuration loaded.");
if (cfgVersion < currentCfgVersion)
save(false);
@ -643,14 +642,13 @@ public class Config
cfg.set("player-killed-bad-spawn", killPlayer);
cfg.set("deny-enderpearl", denyEnderpearl);
cfg.set("fill-autosave-frequency", fillAutosaveFrequency);
cfg.set("bypass-list", new ArrayList(bypassPlayers));
cfg.set("bypass-list", new ArrayList<String>(bypassPlayers));
cfg.set("fill-memory-tolerance", fillMemoryTolerance);
cfg.set("worlds", null);
Iterator world = borders.entrySet().iterator();
while(world.hasNext())
for(Entry<String, BorderData> stringBorderDataEntry : borders.entrySet())
{
Entry wdata = (Entry)world.next();
Entry wdata = stringBorderDataEntry;
String name = ((String)wdata.getKey()).replace(".", "<");
BorderData bord = (BorderData)wdata.getValue();
@ -682,6 +680,6 @@ public class Config
plugin.saveConfig();
if (logIt)
LogConfig("Configuration saved.");
logConfig("Configuration saved.");
}
}

View File

@ -1,7 +1,6 @@
package com.wimbli.WorldBorder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@ -56,12 +55,12 @@ public class DynMapFeatures
}
catch (ClassNotFoundException ex)
{
Config.LogConfig("DynMap is available, but border display is currently disabled: you need DynMap v0.36 or newer.");
Config.logConfig("DynMap is available, but border display is currently disabled: you need DynMap v0.36 or newer.");
return;
}
catch (NullPointerException ex)
{
Config.LogConfig("DynMap is present, but an NPE (type 1) was encountered while trying to integrate. Border display disabled.");
Config.logConfig("DynMap is present, but an NPE (type 1) was encountered while trying to integrate. Border display disabled.");
return;
}
@ -72,14 +71,14 @@ public class DynMapFeatures
}
catch (NullPointerException ex)
{
Config.LogConfig("DynMap is present, but an NPE (type 2) was encountered while trying to integrate. Border display disabled.");
Config.logConfig("DynMap is present, but an NPE (type 2) was encountered while trying to integrate. Border display disabled.");
return;
}
// go ahead and show borders for all worlds
showAllBorders();
Config.LogConfig("Successfully hooked into DynMap for the ability to display borders.");
Config.logConfig("Successfully hooked into DynMap for the ability to display borders.");
}
@ -153,10 +152,9 @@ public class DynMapFeatures
markSet.setMarkerSetLabel("WorldBorder");
Map<String, BorderData> borders = Config.getBorders();
Iterator worlds = borders.entrySet().iterator();
while(worlds.hasNext())
for(Entry<String, BorderData> stringBorderDataEntry : borders.entrySet())
{
Entry wdata = (Entry)worlds.next();
Entry wdata = stringBorderDataEntry;
String worldName = ((String)wdata.getKey());
BorderData border = (BorderData)wdata.getValue();
showBorder(worldName, border);

View File

@ -1,7 +1,6 @@
package com.wimbli.WorldBorder;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -302,10 +301,9 @@ public class WBCommand implements CommandExecutor
return true;
}
Iterator listItem = list.iterator();
while(listItem.hasNext())
for(String borderDesc : list)
{
sender.sendMessage( (String)listItem.next() );
sender.sendMessage(borderDesc);
}
}
@ -369,7 +367,7 @@ public class WBCommand implements CommandExecutor
if (!Config.HasPermission(player, "reload")) return true;
if (player != null)
Config.Log("Reloading config file at the command of player \"" + player.getName() + "\".");
Config.log("Reloading config file at the command of player \"" + player.getName() + "\".");
Config.load(plugin, true);
@ -385,7 +383,7 @@ public class WBCommand implements CommandExecutor
Config.setDebug(strAsBool(split[1]));
if (player != null)
Config.Log((Config.Debug() ? "Enabling" : "Disabling") + " debug output at the command of player \"" + player.getName() + "\".");
Config.log((Config.Debug() ? "Enabling" : "Disabling") + " debug output at the command of player \"" + player.getName() + "\".");
if (player != null)
sender.sendMessage("Debug mode " + enabledColored(Config.Debug()) + ".");
@ -400,7 +398,7 @@ public class WBCommand implements CommandExecutor
if (player != null)
{
Config.Log((Config.whooshEffect() ? "Enabling" : "Disabling") + " \"whoosh\" knockback effect at the command of player \"" + player.getName() + "\".");
Config.log((Config.whooshEffect() ? "Enabling" : "Disabling") + " \"whoosh\" knockback effect at the command of player \"" + player.getName() + "\".");
sender.sendMessage("\"Whoosh\" knockback effect " + enabledColored(Config.whooshEffect()) + ".");
}
}
@ -414,7 +412,7 @@ public class WBCommand implements CommandExecutor
if (player != null)
{
Config.Log((Config.whooshEffect() ? "Enabling" : "Disabling") + " direct cancellation of ender pearls thrown past the border at the command of player \"" + player.getName() + "\".");
Config.log((Config.whooshEffect() ? "Enabling" : "Disabling") + " direct cancellation of ender pearls thrown past the border at the command of player \"" + player.getName() + "\".");
sender.sendMessage("Direct cancellation of ender pearls thrown past the border " + enabledColored(Config.whooshEffect()) + ".");
}
}
@ -575,7 +573,7 @@ public class WBCommand implements CommandExecutor
if (player != null)
{
Config.Log((Config.portalRedirection() ? "Enabling" : "Disabling") + " portal redirection at the command of player \"" + player.getName() + "\".");
Config.log((Config.portalRedirection() ? "Enabling" : "Disabling") + " portal redirection at the command of player \"" + player.getName() + "\".");
sender.sendMessage("Portal redirection " + enabledColored(Config.portalRedirection()) + ".");
}
}
@ -766,7 +764,7 @@ public class WBCommand implements CommandExecutor
sender.sendMessage("DynMap border display " + (Config.DynmapBorderEnabled() ? "enabled" : "disabled") + ".");
if (player != null)
Config.Log((Config.DynmapBorderEnabled() ? "Enabled" : "Disabled") + " DynMap border display at the command of player \"" + player.getName() + "\".");
Config.log((Config.DynmapBorderEnabled() ? "Enabled" : "Disabled") + " DynMap border display at the command of player \"" + player.getName() + "\".");
}
// "dynmapmsg" command from player or console
@ -808,7 +806,7 @@ public class WBCommand implements CommandExecutor
if (target != null && target.isOnline())
target.sendMessage("Border bypass is now " + enabledColored(bypassing) + ".");
Config.Log("Border bypass for player \"" + sPlayer + "\" is " + (bypassing ? "enabled" : "disabled") + (player != null ? " at the command of player \"" + player.getName() + "\"" : "") + ".");
Config.log("Border bypass for player \"" + sPlayer + "\" is " + (bypassing ? "enabled" : "disabled") + (player != null ? " at the command of player \"" + player.getName() + "\"" : "") + ".");
if (player != null && player != target)
sender.sendMessage("Border bypass for player \"" + sPlayer + "\" is " + enabledColored(bypassing) + ".");
}
@ -823,7 +821,7 @@ public class WBCommand implements CommandExecutor
boolean bypassing = !Config.isPlayerBypassing(sPlayer);
Config.setPlayerBypass(sPlayer, bypassing);
Config.Log("Border bypass is " + (bypassing ? "enabled" : "disabled") + " for player \"" + sPlayer + "\".");
Config.log("Border bypass is " + (bypassing ? "enabled" : "disabled") + " for player \"" + sPlayer + "\".");
sender.sendMessage("Border bypass is now " + enabledColored(bypassing) + ".");
}
@ -847,7 +845,7 @@ public class WBCommand implements CommandExecutor
{
page = Integer.parseInt(split[0]);
}
catch(NumberFormatException ex)
catch(NumberFormatException ignored)
{
}
if (page > 4)
@ -918,11 +916,7 @@ public class WBCommand implements CommandExecutor
private boolean strAsBool(String str)
{
str = str.toLowerCase();
if (str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1"))
{
return true;
}
return false;
return str.startsWith("y") || str.startsWith("t") || str.startsWith("on") || str.startsWith("+") || str.startsWith("1");
}
private String enabledColored(boolean enabled)
@ -1070,7 +1064,7 @@ public class WBCommand implements CommandExecutor
}
if (player != null)
Config.Log("Filling out world to border at the command of player \"" + player.getName() + "\".");
Config.log("Filling out world to border at the command of player \"" + player.getName() + "\".");
int ticks = 1, repeats = 1;
if (fillFrequency > 20)
@ -1181,7 +1175,7 @@ public class WBCommand implements CommandExecutor
}
if (player != null)
Config.Log("Trimming world beyond border at the command of player \"" + player.getName() + "\".");
Config.log("Trimming world beyond border at the command of player \"" + player.getName() + "\".");
int ticks = 1, repeats = 1;
if (trimFrequency > 20)

View File

@ -20,7 +20,7 @@ public class WBListener implements Listener
return;
if (Config.Debug())
Config.Log("Teleport cause: "+event.getCause().toString());
Config.log("Teleport cause: " + event.getCause().toString());
Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true, true);
if (newLoc != null)
@ -61,13 +61,13 @@ public class WBListener implements Listener
{
Chunk chunk = event.getChunk();
chunk.unload(false, false);
Config.LogWarn("New chunk generation has been prevented at X " + chunk.getX() + ", Z " + chunk.getZ());
Config.logWarn("New chunk generation has been prevented at X " + chunk.getX() + ", Z " + chunk.getZ());
}
*/
// make sure our border monitoring task is still running like it should
if (Config.isBorderTimerRunning()) return;
Config.LogWarn("Border-checking task was not running! Something on your server apparently killed it. It will now be restarted.");
Config.logWarn("Border-checking task was not running! Something on your server apparently killed it. It will now be restarted.");
Config.StartBorderTimer();
}
}

View File

@ -30,7 +30,7 @@ public class WorldBorder extends JavaPlugin
// Well I for one find this info useful, so...
Location spawn = getServer().getWorlds().get(0).getSpawnLocation();
System.out.println("For reference, the main world's spawn location is at X: " + Config.coord.format(spawn.getX()) + " Y: " + Config.coord.format(spawn.getY()) + " Z: " + Config.coord.format(spawn.getZ()));
Config.log("For reference, the main world's spawn location is at X: " + Config.coord.format(spawn.getX()) + " Y: " + Config.coord.format(spawn.getY()) + " Z: " + Config.coord.format(spawn.getZ()));
}
@Override

View File

@ -36,9 +36,9 @@ public class WorldFileData
{
// check for region folder inside a DIM* folder (DIM-1 for nether, DIM1 for end, DIMwhatever for custom world types)
File[] possibleDimFolders = newData.world.getWorldFolder().listFiles(new DimFolderFileFilter());
for (int i = 0; i < possibleDimFolders.length; i++)
for (File possibleDimFolder : possibleDimFolders)
{
File possible = new File(newData.world.getWorldFolder(), possibleDimFolders[i].getName()+File.separator+"region");
File possible = new File(newData.world.getWorldFolder(), possibleDimFolder.getName() + File.separator + "region");
if (possible.exists() && possible.isDirectory())
{
newData.regionFolder = possible;
@ -219,7 +219,7 @@ public class WorldFileData
// send a message to the server console/log and possibly to an in-game player
private void sendMessage(String text)
{
Config.Log("[WorldData] " + text);
Config.log("[WorldData] " + text);
if (notifyPlayer != null && notifyPlayer.isOnline())
notifyPlayer.sendMessage("[WorldData] " + text);
}
@ -279,12 +279,12 @@ public class WorldFileData
}
File f = new File("region_"+region.x+"_"+region.z+"_.png");
Config.Log(f.getAbsolutePath());
Config.log(f.getAbsolutePath());
try {
// png is an image format (like gif or jpg)
ImageIO.write(bi, "png", f);
} catch (IOException ex) {
Config.Log("[SEVERE]"+ex.getLocalizedMessage());
Config.log("[SEVERE]" + ex.getLocalizedMessage());
}
}
}

View File

@ -283,7 +283,7 @@ public class WorldFillTask implements Runnable
// if we've been around one full loop (4 legs)...
if (isZLeg && isNeg && current == 0)
{ // see if we've been outside the border for the whole loop
if (insideBorder == false)
if (!insideBorder)
{ // and finish if so
finish();
return false;
@ -400,7 +400,7 @@ public class WorldFillTask implements Runnable
// Due to chunk generation eating up memory and Java being too slow about GC, we need to track memory availability
int availMem = Config.AvailableMemory();
Config.Log("[Fill] " + text + " (free mem: " + availMem + " MB)");
Config.log("[Fill] " + text + " (free mem: " + availMem + " MB)");
if (notifyPlayer != null)
notifyPlayer.sendMessage("[Fill] " + text);
@ -409,7 +409,7 @@ public class WorldFillTask implements Runnable
pausedForMemory = true;
Config.StoreFillTask();
text = "Available memory is very low, task is pausing. A cleanup will be attempted now, and the task will automatically continue if/when sufficient memory is freed up.\n Alternatively, if you restart the server, this task will automatically continue once the server is back up.";
Config.Log("[Fill] " + text);
Config.log("[Fill] " + text);
if (notifyPlayer != null)
notifyPlayer.sendMessage("[Fill] " + text);
// prod Java with a request to go ahead and do GC to clean unloaded chunks from memory; this seems to work wonders almost immediately

View File

@ -274,7 +274,9 @@ public class WorldTrimTask implements Runnable
File regionFile = worldData.regionFile(currentRegion);
if (!regionFile.canWrite())
{
regionFile.setWritable(true);
if (!regionFile.setWritable(true))
throw new RuntimeException();
if (!regionFile.canWrite())
{
sendMessage("Error! region file is locked and can't be trimmed: "+regionFile.getName());
@ -387,7 +389,7 @@ public class WorldTrimTask implements Runnable
// send a message to the server console/log and possibly to an in-game player
private void sendMessage(String text)
{
Config.Log("[Trim] " + text);
Config.log("[Trim] " + text);
if (notifyPlayer != null)
notifyPlayer.sendMessage("[Trim] " + text);
}