Merge 6fc5a3990f
into 9f7719074f
This commit is contained in:
commit
fa130fa21a
|
@ -1,20 +1,15 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
public class BorderCheckTask implements Runnable
|
||||
{
|
||||
|
@ -78,7 +73,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();
|
||||
|
@ -121,8 +116,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());
|
||||
|
@ -131,7 +126,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);
|
||||
|
@ -141,7 +136,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());
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
|
||||
public class BorderData
|
||||
{
|
||||
|
@ -168,7 +168,7 @@ public class BorderData
|
|||
{
|
||||
// if this border has a shape override set, use it
|
||||
if (shapeRound != null)
|
||||
round = shapeRound.booleanValue();
|
||||
round = shapeRound;
|
||||
|
||||
// square border
|
||||
if (!round)
|
||||
|
@ -181,14 +181,7 @@ public class BorderData
|
|||
double X = Math.abs(x - xLoc);
|
||||
double Z = Math.abs(z - zLoc);
|
||||
|
||||
if (X < DefiniteRectangleX && Z < DefiniteRectangleZ)
|
||||
return true; // Definitely inside
|
||||
else if (X >= radiusX || Z >= radiusZ)
|
||||
return false; // Definitely outside
|
||||
else if (X * X + Z * Z * radiusSquaredQuotient < radiusXSquared)
|
||||
return true; // After further calculation, inside
|
||||
else
|
||||
return false; // Apparently outside, then
|
||||
return X < DefiniteRectangleX && Z < DefiniteRectangleZ || !(X >= radiusX || Z >= radiusZ) && X * X + Z * Z * radiusSquaredQuotient < radiusXSquared;
|
||||
}
|
||||
}
|
||||
public boolean insideBorder(double xLoc, double zLoc)
|
||||
|
@ -212,7 +205,7 @@ public class BorderData
|
|||
{
|
||||
// if this border has a shape override set, use it
|
||||
if (shapeRound != null)
|
||||
round = shapeRound.booleanValue();
|
||||
round = shapeRound;
|
||||
|
||||
double xLoc = loc.getX();
|
||||
double zLoc = loc.getZ();
|
||||
|
@ -309,9 +302,7 @@ public class BorderData
|
|||
return safe;
|
||||
|
||||
Integer below = (Integer)world.getBlockTypeIdAt(X, Y - 1, Z);
|
||||
return (safe
|
||||
&& (!safeOpenBlocks.contains(below) || below == 8 || below == 9) // below target block not open/breathable (so presumably solid), or is water
|
||||
&& !painfulBlocks.contains(below) // below target block not painful
|
||||
return ((!safeOpenBlocks.contains(below) || below == 8 || below == 9) && !painfulBlocks.contains(below) // below target block not painful
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,17 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
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;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
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;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class Config
|
||||
|
@ -26,7 +19,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 final Logger mcLog = Logger.getLogger("Minecraft");
|
||||
public static DecimalFormat coord = new DecimalFormat("0.0");
|
||||
private static int borderTask = -1;
|
||||
public static WorldFillTask fillTask;
|
||||
|
@ -52,6 +45,104 @@ public class Config
|
|||
private static boolean denyEnderpearl = false;
|
||||
private static int fillAutosaveFrequency = 30;
|
||||
|
||||
public static void load(WorldBorder master, boolean logIt) {
|
||||
// load config from file
|
||||
plugin = master;
|
||||
|
||||
plugin.reloadConfig();
|
||||
cfg = plugin.getConfig();
|
||||
|
||||
int cfgVersion = cfg.getInt("cfg-version", currentCfgVersion);
|
||||
|
||||
String msg = cfg.getString("message");
|
||||
shapeRound = cfg.getBoolean("round-border", true);
|
||||
DEBUG = cfg.getBoolean("debug-mode", false);
|
||||
whooshEffect = cfg.getBoolean("whoosh-effect", false);
|
||||
portalRedirection = cfg.getBoolean("portal-redirection", true);
|
||||
knockBack = cfg.getDouble("knock-back-dist", 3.0);
|
||||
timerTicks = cfg.getInt("timer-delay-ticks", 5);
|
||||
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 + ".");
|
||||
killPlayer = cfg.getBoolean("player-killed-bad-spawn", false);
|
||||
denyEnderpearl = cfg.getBoolean("deny-enderpearl", false);
|
||||
fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30);
|
||||
bypassPlayers = Collections.synchronizedSet(new LinkedHashSet<String>(cfg.getStringList("bypass-list")));
|
||||
|
||||
StartBorderTimer();
|
||||
|
||||
borders.clear();
|
||||
|
||||
// if empty border message, assume no config
|
||||
if (msg == null || msg.isEmpty())
|
||||
{ // store defaults
|
||||
logConfig("Configuration not present, creating new file.");
|
||||
msg = "&cYou have reached the edge of this world.";
|
||||
updateMessage(msg);
|
||||
save(false);
|
||||
return;
|
||||
}
|
||||
// if loading older config which didn't support color codes in border message, make sure default red color code is added at start of it
|
||||
else if (cfgVersion < 8 && !(msg.substring(0, 1).equals("&")))
|
||||
updateMessage("&c" + msg);
|
||||
// otherwise just set border message
|
||||
else
|
||||
updateMessage(msg);
|
||||
|
||||
ConfigurationSection worlds = cfg.getConfigurationSection("worlds");
|
||||
if (worlds != null)
|
||||
{
|
||||
Set<String> worldNames = worlds.getKeys(false);
|
||||
|
||||
for(String worldName : worldNames)
|
||||
{
|
||||
ConfigurationSection bord = worlds.getConfigurationSection(worldName);
|
||||
|
||||
// we're swapping "<" to "." at load since periods denote configuration nodes without a working way to change that, so world names with periods wreak havoc and are thus modified for storage
|
||||
if (cfgVersion > 3)
|
||||
worldName = worldName.replace("<", ".");
|
||||
|
||||
// backwards compatibility for config from before elliptical/rectangular borders were supported
|
||||
if (bord.isSet("radius") && !bord.isSet("radiusX"))
|
||||
{
|
||||
int radius = bord.getInt("radius");
|
||||
bord.set("radiusX", radius);
|
||||
bord.set("radiusZ", radius);
|
||||
}
|
||||
|
||||
Boolean overrideShape = (Boolean) bord.get("shape-round");
|
||||
boolean wrap = 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));
|
||||
}
|
||||
}
|
||||
|
||||
// if we have an unfinished fill task stored from a previous run, load it up
|
||||
ConfigurationSection storedFillTask = cfg.getConfigurationSection("fillTask");
|
||||
if (storedFillTask != null)
|
||||
{
|
||||
String worldName = storedFillTask.getString("world");
|
||||
int fillDistance = storedFillTask.getInt("fillDistance", 176);
|
||||
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 5);
|
||||
int tickFrequency = storedFillTask.getInt("tickFrequency", 20);
|
||||
int fillX = storedFillTask.getInt("x", 0);
|
||||
int fillZ = storedFillTask.getInt("z", 0);
|
||||
int fillLength = storedFillTask.getInt("length", 0);
|
||||
int fillTotal = storedFillTask.getInt("total", 0);
|
||||
boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
|
||||
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
|
||||
save(false);
|
||||
}
|
||||
|
||||
if (logIt)
|
||||
logConfig("Configuration loaded.");
|
||||
|
||||
if (cfgVersion < currentCfgVersion)
|
||||
save(false);
|
||||
}
|
||||
|
||||
// for monitoring plugin efficiency
|
||||
// public static long timeUsed = 0;
|
||||
|
||||
|
@ -64,7 +155,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);
|
||||
}
|
||||
|
@ -72,14 +163,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));
|
||||
}
|
||||
|
||||
|
@ -112,7 +203,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);
|
||||
}
|
||||
|
||||
|
@ -120,7 +211,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);
|
||||
}
|
||||
|
@ -128,7 +219,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();
|
||||
}
|
||||
|
@ -146,10 +237,8 @@ public class Config
|
|||
{
|
||||
Set<String> output = new HashSet<String>();
|
||||
|
||||
Iterator world = borders.keySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
output.add( BorderDescription((String)world.next()) );
|
||||
for(String s : borders.keySet()) {
|
||||
output.add(BorderDescription(s));
|
||||
}
|
||||
|
||||
return output;
|
||||
|
@ -168,7 +257,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);
|
||||
}
|
||||
|
||||
|
@ -195,7 +284,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();
|
||||
}
|
||||
|
@ -217,7 +306,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);
|
||||
}
|
||||
|
||||
|
@ -229,7 +318,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);
|
||||
}
|
||||
|
||||
|
@ -261,7 +350,7 @@ public class Config
|
|||
public static void setPortalRedirection(boolean enable)
|
||||
{
|
||||
portalRedirection = enable;
|
||||
Log("Portal redirection " + (enable ? "enabled" : "disabled") + ".");
|
||||
log("Portal redirection " + (enable ? "enabled" : "disabled") + ".");
|
||||
save(true);
|
||||
}
|
||||
|
||||
|
@ -273,7 +362,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);
|
||||
}
|
||||
|
||||
|
@ -285,7 +374,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);
|
||||
}
|
||||
|
@ -299,11 +388,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);
|
||||
}
|
||||
|
||||
|
@ -316,9 +405,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);
|
||||
}
|
||||
|
||||
|
@ -331,7 +420,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();
|
||||
}
|
||||
|
@ -344,7 +433,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();
|
||||
}
|
||||
|
@ -384,8 +473,7 @@ public class Config
|
|||
|
||||
public static boolean isBorderTimerRunning()
|
||||
{
|
||||
if (borderTask == -1) return false;
|
||||
return (plugin.getServer().getScheduler().isQueued(borderTask) || plugin.getServer().getScheduler().isCurrentlyRunning(borderTask));
|
||||
return borderTask != -1 && (plugin.getServer().getScheduler().isQueued(borderTask) || plugin.getServer().getScheduler().isCurrentlyRunning(borderTask));
|
||||
}
|
||||
|
||||
public static void StartBorderTimer()
|
||||
|
@ -395,9 +483,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()
|
||||
|
@ -406,7 +494,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()
|
||||
|
@ -476,133 +564,33 @@ 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);
|
||||
}
|
||||
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));
|
||||
plugin.getLogger().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);
|
||||
}
|
||||
|
||||
|
||||
private static final int currentCfgVersion = 9;
|
||||
|
||||
public static void load(WorldBorder master, boolean logIt)
|
||||
{ // load config from file
|
||||
plugin = master;
|
||||
|
||||
plugin.reloadConfig();
|
||||
cfg = plugin.getConfig();
|
||||
|
||||
int cfgVersion = cfg.getInt("cfg-version", currentCfgVersion);
|
||||
|
||||
String msg = cfg.getString("message");
|
||||
shapeRound = cfg.getBoolean("round-border", true);
|
||||
DEBUG = cfg.getBoolean("debug-mode", false);
|
||||
whooshEffect = cfg.getBoolean("whoosh-effect", false);
|
||||
portalRedirection = cfg.getBoolean("portal-redirection", true);
|
||||
knockBack = cfg.getDouble("knock-back-dist", 3.0);
|
||||
timerTicks = cfg.getInt("timer-delay-ticks", 5);
|
||||
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 + ".");
|
||||
killPlayer = cfg.getBoolean("player-killed-bad-spawn", false);
|
||||
denyEnderpearl = cfg.getBoolean("deny-enderpearl", false);
|
||||
fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30);
|
||||
bypassPlayers = Collections.synchronizedSet(new LinkedHashSet<String>(cfg.getStringList("bypass-list")));
|
||||
|
||||
StartBorderTimer();
|
||||
|
||||
borders.clear();
|
||||
|
||||
// if empty border message, assume no config
|
||||
if (msg == null || msg.isEmpty())
|
||||
{ // store defaults
|
||||
LogConfig("Configuration not present, creating new file.");
|
||||
msg = "&cYou have reached the edge of this world.";
|
||||
updateMessage(msg);
|
||||
save(false);
|
||||
return;
|
||||
}
|
||||
// if loading older config which didn't support color codes in border message, make sure default red color code is added at start of it
|
||||
else if (cfgVersion < 8 && !(msg.substring(0, 1).equals("&")))
|
||||
updateMessage("&c" + msg);
|
||||
// otherwise just set border message
|
||||
else
|
||||
updateMessage(msg);
|
||||
|
||||
ConfigurationSection worlds = cfg.getConfigurationSection("worlds");
|
||||
if (worlds != null)
|
||||
{
|
||||
Set<String> worldNames = worlds.getKeys(false);
|
||||
|
||||
for(String worldName : worldNames)
|
||||
{
|
||||
ConfigurationSection bord = worlds.getConfigurationSection(worldName);
|
||||
|
||||
// we're swapping "<" to "." at load since periods denote configuration nodes without a working way to change that, so world names with periods wreak havoc and are thus modified for storage
|
||||
if (cfgVersion > 3)
|
||||
worldName = worldName.replace("<", ".");
|
||||
|
||||
// backwards compatibility for config from before elliptical/rectangular borders were supported
|
||||
if (bord.isSet("radius") && !bord.isSet("radiusX"))
|
||||
{
|
||||
int radius = bord.getInt("radius");
|
||||
bord.set("radiusX", radius);
|
||||
bord.set("radiusZ", radius);
|
||||
}
|
||||
|
||||
Boolean overrideShape = (Boolean) bord.get("shape-round");
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
// if we have an unfinished fill task stored from a previous run, load it up
|
||||
ConfigurationSection storedFillTask = cfg.getConfigurationSection("fillTask");
|
||||
if (storedFillTask != null)
|
||||
{
|
||||
String worldName = storedFillTask.getString("world");
|
||||
int fillDistance = storedFillTask.getInt("fillDistance", 176);
|
||||
int chunksPerRun = storedFillTask.getInt("chunksPerRun", 5);
|
||||
int tickFrequency = storedFillTask.getInt("tickFrequency", 20);
|
||||
int fillX = storedFillTask.getInt("x", 0);
|
||||
int fillZ = storedFillTask.getInt("z", 0);
|
||||
int fillLength = storedFillTask.getInt("length", 0);
|
||||
int fillTotal = storedFillTask.getInt("total", 0);
|
||||
boolean forceLoad = storedFillTask.getBoolean("forceLoad", false);
|
||||
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal, forceLoad);
|
||||
save(false);
|
||||
}
|
||||
|
||||
if (logIt)
|
||||
LogConfig("Configuration loaded.");
|
||||
|
||||
if (cfgVersion < currentCfgVersion)
|
||||
save(false);
|
||||
}
|
||||
|
||||
public static void save(boolean logIt)
|
||||
{
|
||||
save(logIt, false);
|
||||
|
@ -625,15 +613,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("worlds", null);
|
||||
Iterator world = borders.entrySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
Entry wdata = (Entry)world.next();
|
||||
String name = ((String)wdata.getKey()).replace(".", "<");
|
||||
BorderData bord = (BorderData)wdata.getValue();
|
||||
for(Entry<String, BorderData> stringBorderDataEntry : borders.entrySet()) {
|
||||
Entry wdata = (Entry) stringBorderDataEntry;
|
||||
String name = ((String) wdata.getKey()).replace(".", "<");
|
||||
BorderData bord = (BorderData) wdata.getValue();
|
||||
|
||||
cfg.set("worlds." + name + ".x", bord.getX());
|
||||
cfg.set("worlds." + name + ".z", bord.getZ());
|
||||
|
@ -641,7 +627,7 @@ public class Config
|
|||
cfg.set("worlds." + name + ".radiusZ", bord.getRadiusZ());
|
||||
cfg.set("worlds." + name + ".wrapping", bord.getWrapping());
|
||||
|
||||
if (bord.getShape() != null)
|
||||
if(bord.getShape() != null)
|
||||
cfg.set("worlds." + name + ".shape-round", bord.getShape());
|
||||
}
|
||||
|
||||
|
@ -663,6 +649,6 @@ public class Config
|
|||
plugin.saveConfig();
|
||||
|
||||
if (logIt)
|
||||
LogConfig("Configuration saved.");
|
||||
logConfig("Configuration saved.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,30 +1,25 @@
|
|||
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;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.World;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.markers.AreaMarker;
|
||||
import org.dynmap.markers.CircleMarker;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.markers.MarkerSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
public class DynMapFeatures
|
||||
{
|
||||
private static DynmapAPI api;
|
||||
private static MarkerAPI markApi;
|
||||
private static MarkerSet markSet;
|
||||
private static int lineWeight = 3;
|
||||
private static double lineOpacity = 1.0;
|
||||
private static int lineColor = 0xFF0000;
|
||||
|
||||
// Whether re-rendering functionality is available
|
||||
public static boolean renderEnabled()
|
||||
|
@ -56,12 +51,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 +67,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,12 +148,10 @@ public class DynMapFeatures
|
|||
markSet.setMarkerSetLabel("WorldBorder");
|
||||
|
||||
Map<String, BorderData> borders = Config.getBorders();
|
||||
Iterator worlds = borders.entrySet().iterator();
|
||||
while(worlds.hasNext())
|
||||
{
|
||||
Entry wdata = (Entry)worlds.next();
|
||||
String worldName = ((String)wdata.getKey());
|
||||
BorderData border = (BorderData)wdata.getValue();
|
||||
for(Entry<String, BorderData> stringBorderDataEntry : borders.entrySet()) {
|
||||
Entry wdata = (Entry) stringBorderDataEntry;
|
||||
String worldName = ((String) wdata.getKey());
|
||||
BorderData border = (BorderData) wdata.getValue();
|
||||
showBorder(worldName, border);
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +177,9 @@ public class DynMapFeatures
|
|||
if (marker == null)
|
||||
{
|
||||
marker = markSet.createCircleMarker("worldborder_"+worldName, Config.DynmapMessage(), false, worldName, border.getX(), 64.0, border.getZ(), border.getRadiusX(), border.getRadiusZ(), true);
|
||||
int lineWeight = 3;
|
||||
double lineOpacity = 1.0;
|
||||
int lineColor = 0xFF0000;
|
||||
marker.setLineStyle(lineWeight, lineOpacity, lineColor);
|
||||
marker.setFillStyle(0.0, 0x000000);
|
||||
roundBorders.put(worldName, marker);
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class WBCommand implements CommandExecutor
|
||||
|
@ -302,10 +303,8 @@ public class WBCommand implements CommandExecutor
|
|||
return true;
|
||||
}
|
||||
|
||||
Iterator listItem = list.iterator();
|
||||
while(listItem.hasNext())
|
||||
{
|
||||
sender.sendMessage( (String)listItem.next() );
|
||||
for(String aList : list) {
|
||||
sender.sendMessage(aList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,7 +368,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 +384,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 +399,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()) + ".");
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +482,7 @@ public class WBCommand implements CommandExecutor
|
|||
Config.setBorder(world, border);
|
||||
|
||||
if (player != null)
|
||||
sender.sendMessage("Border shape for world \"" + world + "\" is now set to \"" + (shape == null ? "default" : Config.ShapeName(shape.booleanValue())) + "\".");
|
||||
sender.sendMessage("Border shape for world \"" + world + "\" is now set to \"" + (shape == null ? "default" : Config.ShapeName(shape)) + "\".");
|
||||
}
|
||||
|
||||
// "wshape" command from player, using current world
|
||||
|
@ -508,7 +507,7 @@ public class WBCommand implements CommandExecutor
|
|||
border.setShape(shape);
|
||||
Config.setBorder(world, border);
|
||||
|
||||
sender.sendMessage("Border shape for world \"" + world + "\" is now set to \"" + (shape == null ? "default" : Config.ShapeName(shape.booleanValue())) + "\".");
|
||||
sender.sendMessage("Border shape for world \"" + world + "\" is now set to \"" + (shape == null ? "default" : Config.ShapeName(shape)) + "\".");
|
||||
}
|
||||
|
||||
// "wrap" command from player or console, world specified
|
||||
|
@ -561,7 +560,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()) + ".");
|
||||
}
|
||||
}
|
||||
|
@ -752,7 +751,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
|
||||
|
@ -794,7 +793,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) + ".");
|
||||
}
|
||||
|
@ -809,7 +808,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) + ".");
|
||||
}
|
||||
|
||||
|
@ -833,7 +832,7 @@ public class WBCommand implements CommandExecutor
|
|||
{
|
||||
page = Integer.parseInt(split[0]);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
catch(NumberFormatException ignored)
|
||||
{
|
||||
}
|
||||
if (page > 4)
|
||||
|
@ -903,11 +902,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)
|
||||
|
@ -1055,7 +1050,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)
|
||||
|
@ -1166,7 +1161,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)
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
public class WBListener implements Listener
|
||||
|
@ -20,7 +19,7 @@ public class WBListener implements Listener
|
|||
return;
|
||||
|
||||
if (Config.Debug())
|
||||
Config.Log("Teleport cause: "+event.getCause().toString());
|
||||
Config.log("Teleport cause: " + event.getCause().toString());
|
||||
|
||||
if(event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && Config.getDenyEnderpearl())
|
||||
{
|
||||
|
@ -59,13 +58,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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
// image output stuff, for debugging method at bottom of this file
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import javax.imageio.*;
|
||||
|
||||
|
||||
// by the way, this region file handler was created based on the divulged region file format: http://mojang.com/2011/02/16/minecraft-save-file-format-in-beta-1-3/
|
||||
|
@ -36,11 +33,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++)
|
||||
{
|
||||
File possible = new File(newData.world.getWorldFolder(), possibleDimFolders[i].getName()+File.separator+"region");
|
||||
if (possible.exists() && possible.isDirectory())
|
||||
{
|
||||
for(File possibleDimFolder : possibleDimFolders) {
|
||||
File possible = new File(newData.world.getWorldFolder(), possibleDimFolder.getName() + File.separator + "region");
|
||||
if(possible.exists() && possible.isDirectory()) {
|
||||
newData.regionFolder = possible;
|
||||
break;
|
||||
}
|
||||
|
@ -127,7 +122,7 @@ public class WorldFileData
|
|||
CoordXZ region = new CoordXZ(CoordXZ.chunkToRegion(x), CoordXZ.chunkToRegion(z));
|
||||
List<Boolean> regionChunks = this.getRegionData(region);
|
||||
// Bukkit.getLogger().info("x: "+x+" z: "+z+" offset: "+coordToRegionOffset(x, z));
|
||||
return regionChunks.get(coordToRegionOffset(x, z)).booleanValue();
|
||||
return regionChunks.get(coordToRegionOffset(x, z));
|
||||
}
|
||||
|
||||
// Find out if the chunk at the given coordinates has been fully generated.
|
||||
|
@ -219,7 +214,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);
|
||||
}
|
||||
|
@ -272,19 +267,19 @@ public class WorldFileData
|
|||
{
|
||||
for (int z = 0; z < 32; z++)
|
||||
{
|
||||
if (data.get(current).booleanValue())
|
||||
if (data.get(current))
|
||||
g2.fillRect(x,z, x+1, z+1);
|
||||
current++;
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class WorldFillTask implements Runnable
|
||||
|
@ -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
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
package com.wimbli.WorldBorder;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class WorldTrimTask implements Runnable
|
||||
|
@ -274,7 +277,7 @@ 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 +390,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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue