Add support for 'compass-mode' - handle 1.9 change of proper north

This commit is contained in:
Mike Primm 2011-10-13 23:54:52 -05:00
parent d6b93868a7
commit 5c064eab2b
6 changed files with 43 additions and 9 deletions

View File

@ -1,10 +1,7 @@
package org.dynmap; package org.dynmap;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
@ -18,7 +15,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.World.Environment; import org.bukkit.World.Environment;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -40,7 +36,6 @@ import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.BlockSpreadEvent;
import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityListener; import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
@ -54,7 +49,6 @@ import org.bukkit.event.world.ChunkPopulateEvent;
import org.bukkit.event.world.SpawnChangeEvent; import org.bukkit.event.world.SpawnChangeEvent;
import org.bukkit.event.world.WorldListener; import org.bukkit.event.world.WorldListener;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -86,6 +80,13 @@ public class DynmapPlugin extends JavaPlugin {
boolean swampshading = false; boolean swampshading = false;
boolean waterbiomeshading = false; boolean waterbiomeshading = false;
boolean fencejoin = false; boolean fencejoin = false;
public CompassMode compassmode = CompassMode.PRE19;
public enum CompassMode {
PRE19, /* Default for 1.8 and earlier (east is Z+) */
NEWROSE, /* Use same map orientation, fix rose */
NEWNORTH /* Use new map orientation */
};
/* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */ /* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */
public boolean is_reload = false; public boolean is_reload = false;
@ -258,6 +259,14 @@ public class DynmapPlugin extends JavaPlugin {
waterbiomeshading = configuration.getBoolean("waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8")); waterbiomeshading = configuration.getBoolean("waterbiomeshaded", !getServer().getVersion().contains("(MC: 1.8"));
/* Default fence-to-block-join off for 1.8, on after */ /* Default fence-to-block-join off for 1.8, on after */
fencejoin = configuration.getBoolean("fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8")); fencejoin = configuration.getBoolean("fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8"));
/* Default compassmode to pre19, to newrose after */
String cmode = configuration.getString("compass-mode", getServer().getVersion().contains("(MC: 1.8")?"pre19":"newrose");
if(cmode.equals("newnorth"))
compassmode = CompassMode.NEWNORTH;
else if(cmode.equals("newrose"))
compassmode = CompassMode.NEWROSE;
else
compassmode = CompassMode.PRE19;
loadDebuggers(); loadDebuggers();

View File

@ -24,6 +24,7 @@ import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.dynmap.DynmapPlugin.CompassMode;
import org.dynmap.DynmapWorld.AutoGenerateOption; import org.dynmap.DynmapWorld.AutoGenerateOption;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
import org.dynmap.hdmap.HDMapManager; import org.dynmap.hdmap.HDMapManager;
@ -1167,6 +1168,10 @@ public class MapManager {
return plug_in.fencejoin; return plug_in.fencejoin;
} }
public CompassMode getCompassMode() {
return plug_in.compassmode;
}
public boolean getHideOres() { public boolean getHideOres() {
return hideores; return hideores;
} }

View File

@ -17,6 +17,7 @@ import org.dynmap.Color;
import org.dynmap.ColorScheme; import org.dynmap.ColorScheme;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.DynmapPlugin.CompassMode;
import org.dynmap.MapManager; import org.dynmap.MapManager;
import org.dynmap.TileHashManager; import org.dynmap.TileHashManager;
import org.dynmap.MapTile; import org.dynmap.MapTile;
@ -602,6 +603,9 @@ public class FlatMap extends MapType {
s(o, "bigmap", this.isBigWorldMap(world)); s(o, "bigmap", this.isBigWorldMap(world));
s(o, "mapzoomin", c.getInteger("mapzoomin", 3)); s(o, "mapzoomin", c.getInteger("mapzoomin", 3));
s(o, "mapzoomout", world.getExtraZoomOutLevels()); s(o, "mapzoomout", world.getExtraZoomOutLevels());
if(MapManager.mapman.getCompassMode() != CompassMode.PRE19)
s(o, "compassview", "E"); /* Always from east */
else
s(o, "compassview", "S"); /* Always from south */ s(o, "compassview", "S"); /* Always from south */
s(o, "image-format", ImageFormat.FORMAT_PNG.getFileExt()); s(o, "image-format", ImageFormat.FORMAT_PNG.getFileExt());
a(worldObject, "maps", o); a(worldObject, "maps", o);

View File

@ -18,6 +18,7 @@ import org.dynmap.Client;
import org.dynmap.Color; import org.dynmap.Color;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.DynmapPlugin.CompassMode;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.MapManager; import org.dynmap.MapManager;
import org.dynmap.MapTile; import org.dynmap.MapTile;
@ -737,6 +738,10 @@ public class IsoHDPerspective implements HDPerspective {
return; return;
} }
azimuth = configuration.getDouble("azimuth", 135.0); /* Get azimuth (default to classic kzed POV */ azimuth = configuration.getDouble("azimuth", 135.0); /* Get azimuth (default to classic kzed POV */
/* Fix azimuth so that we respect new north, if that is requested (newnorth = oldeast) */
if(MapManager.mapman.getCompassMode() == CompassMode.NEWNORTH) {
azimuth = (azimuth + 90.0); if(azimuth >= 360.0) azimuth = azimuth - 360.0;
}
inclination = configuration.getDouble("inclination", 60.0); inclination = configuration.getDouble("inclination", 60.0);
if(inclination > MAX_INCLINATION) inclination = MAX_INCLINATION; if(inclination > MAX_INCLINATION) inclination = MAX_INCLINATION;
if(inclination < MIN_INCLINATION) inclination = MIN_INCLINATION; if(inclination < MIN_INCLINATION) inclination = MIN_INCLINATION;
@ -1239,7 +1244,9 @@ public class IsoHDPerspective implements HDPerspective {
s(mapObject, "scale", scale); s(mapObject, "scale", scale);
s(mapObject, "worldtomap", world_to_map.toJSON()); s(mapObject, "worldtomap", world_to_map.toJSON());
s(mapObject, "maptoworld", map_to_world.toJSON()); s(mapObject, "maptoworld", map_to_world.toJSON());
int dir = ((360 + (int)(22.5+azimuth)) / 45) % 8;; int dir = ((360 + (int)(22.5+azimuth)) / 45) % 8;
if(MapManager.mapman.getCompassMode() != CompassMode.PRE19)
dir = (dir + 6) % 8;
s(mapObject, "compassview", directions[dir]); s(mapObject, "compassview", directions[dir]);
} }

View File

@ -18,6 +18,7 @@ import org.dynmap.ColorScheme;
import org.dynmap.ConfigurationNode; import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapWorld; import org.dynmap.DynmapWorld;
import org.dynmap.MapManager; import org.dynmap.MapManager;
import org.dynmap.DynmapPlugin.CompassMode;
import org.dynmap.MapType.ImageFormat; import org.dynmap.MapType.ImageFormat;
import org.dynmap.TileHashManager; import org.dynmap.TileHashManager;
import org.dynmap.debug.Debug; import org.dynmap.debug.Debug;
@ -589,6 +590,9 @@ public class DefaultTileRenderer implements MapTileRenderer {
s(o, "bigmap", map.isBigWorldMap(world)); s(o, "bigmap", map.isBigWorldMap(world));
s(o, "mapzoomin", c.getInteger("mapzoomin", 2)); s(o, "mapzoomin", c.getInteger("mapzoomin", 2));
s(o, "mapzoomout", world.getExtraZoomOutLevels()+1); s(o, "mapzoomout", world.getExtraZoomOutLevels()+1);
if(MapManager.mapman.getCompassMode() != CompassMode.PRE19)
s(o, "compassview", "NE"); /* Always from northeast */
else
s(o, "compassview", "SE"); /* Always from southeast */ s(o, "compassview", "SE"); /* Always from southeast */
s(o, "image-format", ImageFormat.FORMAT_PNG.getFileExt()); s(o, "image-format", ImageFormat.FORMAT_PNG.getFileExt());
a(worldObject, "maps", o); a(worldObject, "maps", o);

View File

@ -266,6 +266,11 @@ enabletilehash: true
# Control updating of player faces, once loaded (if faces are being managed by other apps or manually) # Control updating of player faces, once loaded (if faces are being managed by other apps or manually)
#refreshskins: false #refreshskins: false
# Control behavior for new (1.9+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
# default is 'pre19' for 1.8 server (existing orientation), 'newrose' for 1.9+ (preserve maps, rotate rose)
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
#compass-mode: newnorth
render-triggers: render-triggers:
#- chunkloaded #- chunkloaded
#- playermove #- playermove