mirror of
https://github.com/Brettflan/WorldBorder.git
synced 2025-01-22 23:41:21 +01:00
Compatibility with upcoming CB 1.1-R5 and above: removed legacy Configuration code.
This commit is contained in:
parent
9c262004d4
commit
c0fc603e5f
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,10 +1,10 @@
|
||||
|
||||
/lib/craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
/lib/craftbukkit.jar
|
||||
/lib/Permissions.jar
|
||||
/nbproject/private
|
||||
/build
|
||||
/dist
|
||||
/lib/GroupManager.jar
|
||||
/nbproject/pmd.settings
|
||||
/lib/craftbukkit-1.0.0-SNAPSHOT.jar
|
||||
/lib/craftbukkit-1.0.1-R1.jar
|
||||
|
||||
/nbproject/findbugs.settings
|
@ -15,10 +15,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import org.bukkit.util.config.Configuration;
|
||||
import org.bukkit.util.config.ConfigurationNode;
|
||||
|
||||
|
||||
|
||||
public class Config
|
||||
{
|
||||
@ -28,8 +24,8 @@ public class Config
|
||||
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 = null;
|
||||
public static WorldTrimTask trimTask = null;
|
||||
public static WorldFillTask fillTask;
|
||||
public static WorldTrimTask trimTask;
|
||||
public static Set<String> movedPlayers = Collections.synchronizedSet(new HashSet<String>());
|
||||
private static Runtime rt = Runtime.getRuntime();
|
||||
|
||||
@ -284,13 +280,8 @@ public class Config
|
||||
{ // load config from file
|
||||
plugin = master;
|
||||
|
||||
// do this first, in case config.yml has any old "¨" compatibility characters in it which cause errors in Bukkit's new configuration handler
|
||||
compat_load();
|
||||
|
||||
plugin.reloadConfig();
|
||||
cfg = plugin.getConfig();
|
||||
// cfg.options().pathSeparator('>'); // should work to get rid of hackish "world names with periods in them" workaround
|
||||
// ^ sadly, while Bukkit saves the data fine with periods intact using this, it does not load it correctly (bugged, still treats periods as separators in addition to chosen separator)
|
||||
|
||||
int cfgVersion = cfg.getInt("cfg-version", currentCfgVersion);
|
||||
|
||||
@ -384,10 +375,6 @@ public class Config
|
||||
cfg.set("worlds." + name + ".x", bord.getX());
|
||||
cfg.set("worlds." + name + ".z", bord.getZ());
|
||||
cfg.set("worlds." + name + ".radius", bord.getRadius());
|
||||
/* cfg.set("worlds>" + name + ">x", bord.getX());
|
||||
cfg.set("worlds>" + name + ">z", bord.getZ());
|
||||
cfg.set("worlds>" + name + ">radius", bord.getRadius());
|
||||
*/
|
||||
|
||||
if (bord.getShape() != null)
|
||||
cfg.set("worlds." + name + ".shape-round", bord.getShape());
|
||||
@ -412,69 +399,4 @@ public class Config
|
||||
if (logIt)
|
||||
LogConfig("Configuration saved.");
|
||||
}
|
||||
|
||||
// needed in case config.yml has any old "¨" compatibility characters in it, since they cause parse errors in Bukkit's new configuration handler
|
||||
public static void compat_load()
|
||||
{ // load config from file
|
||||
Configuration old_cfg = plugin.getConfiguration();
|
||||
|
||||
int cfgVersion = old_cfg.getInt("cfg-version", currentCfgVersion);
|
||||
|
||||
// if the config version is newer than this, it's safe to load through the normal handler
|
||||
if (cfgVersion > 3)
|
||||
return;
|
||||
|
||||
LogConfig("Upgrading older version config file.");
|
||||
|
||||
message = old_cfg.getString("message");
|
||||
shapeRound = old_cfg.getBoolean("round-border", true);
|
||||
DEBUG = old_cfg.getBoolean("debug-mode", false);
|
||||
whooshEffect = old_cfg.getBoolean("whoosh-effect", false);
|
||||
knockBack = old_cfg.getDouble("knock-back-dist", 3.0);
|
||||
timerTicks = old_cfg.getInt("timer-delay-ticks", 5);
|
||||
|
||||
borders.clear();
|
||||
|
||||
Map<String, ConfigurationNode> worlds = old_cfg.getNodes("worlds");
|
||||
if (worlds != null)
|
||||
{
|
||||
Iterator world = worlds.entrySet().iterator();
|
||||
while(world.hasNext())
|
||||
{
|
||||
Entry wdata = (Entry)world.next();
|
||||
|
||||
String name = null;
|
||||
// we're swapping "¨" (from extended ASCII set) and "." back and forth at save and load since periods denote configuration nodes, and world names with periods otherwise wreak havoc
|
||||
if (cfgVersion > 1)
|
||||
name = ((String)wdata.getKey()).replace("¨", ".");
|
||||
else // old v1 format, periods encoded as slashes, which had problems
|
||||
name = ((String)wdata.getKey()).replace("/", ".");
|
||||
|
||||
ConfigurationNode bord = (ConfigurationNode)wdata.getValue();
|
||||
Boolean overrideShape = (Boolean) bord.getProperty("shape-round");
|
||||
BorderData border = new BorderData(bord.getDouble("x", 0), bord.getDouble("z", 0), bord.getInt("radius", 0), overrideShape);
|
||||
borders.put(name, border);
|
||||
}
|
||||
}
|
||||
|
||||
// if we have an unfinished fill task stored from a previous run, load it up
|
||||
ConfigurationNode storedFillTask = old_cfg.getNode("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);
|
||||
RestoreFillTask(worldName, fillDistance, chunksPerRun, tickFrequency, fillX, fillZ, fillLength, fillTotal);
|
||||
}
|
||||
|
||||
old_cfg.removeProperty("worlds");
|
||||
old_cfg.save();
|
||||
cfg = plugin.getConfig();
|
||||
save(false, false);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.wimbli.WorldBorder;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
|
||||
public class WorldBorder extends JavaPlugin
|
||||
|
@ -16,6 +16,8 @@ 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/
|
||||
|
||||
public class WorldFileData
|
||||
{
|
||||
private transient World world;
|
||||
@ -143,7 +145,7 @@ public class WorldFileData
|
||||
|
||||
|
||||
|
||||
// region is 32 X 32 chunks; chunk pointers are stored in region file at position: x + z*32 (max 1024)
|
||||
// region is 32 * 32 chunks; chunk pointers are stored in region file at position: x + z*32 (32 * 32 chunks = 1024)
|
||||
// input x and z values can be world-based chunk coordinates or local-to-region chunk coordinates either one
|
||||
private int coordToRegionOffset(int x, int z)
|
||||
{
|
||||
@ -181,7 +183,7 @@ public class WorldFileData
|
||||
try
|
||||
{
|
||||
RandomAccessFile regionData = new RandomAccessFile(this.regionFile(i), "r");
|
||||
// first 4096 bytes of region file consists of 4-byte int pointers to chunk data in the file
|
||||
// first 4096 bytes of region file consists of 4-byte int pointers to chunk data in the file (32*32 chunks = 1024; 1024 chunks * 4 bytes each = 4096)
|
||||
for (int j = 0; j < 1024; j++)
|
||||
{
|
||||
// if chunk pointer data is 0, chunk doesn't exist yet; otherwise, it does
|
||||
|
@ -251,7 +251,6 @@ public class WorldTrimTask implements Runnable
|
||||
}
|
||||
|
||||
// edit region file to wipe all chunk pointers for chunks outside the border
|
||||
// by the way, this method was created based on the divulged region file format: http://mojang.com/2011/02/16/minecraft-save-file-format-in-beta-1-3/
|
||||
private void wipeChunks()
|
||||
{
|
||||
File regionFile = worldData.regionFile(currentRegion);
|
||||
|
Loading…
Reference in New Issue
Block a user