Made colors load from jar when not found in filesystem.

This commit is contained in:
FrozenCow 2011-01-13 11:18:54 +01:00
parent 4f0e89b1d8
commit 342a72f39f
4 changed files with 98 additions and 79 deletions

View File

@ -20,12 +20,12 @@
<fileset dir="${bin}"/>
<fileset file="${src}/main/resources/plugin.yml"/>
<zipfileset dir="web" prefix="web/"/>
<zipfileset file="${src}/main/resources/colors.txt"/>
</jar>
</target>
<target name="deploy" depends="dist">
<copy file="${dist}/${pluginname}.jar" todir="${plugins}"/>
<copy file="colors.txt" todir="${minecraft}"/>
<copy todir="${http_root}">
<fileset dir="web"/>
</copy>

View File

@ -82,6 +82,12 @@ public class MapManager extends Thread {
this.debugger = debugger;
this.staleQueue = new StaleQueue();
File tilepathFile = new File(tilepath);
if (!tilepathFile.isDirectory())
tilepathFile.mkdirs();
serverport = 8123;
bindaddress = "0.0.0.0";
//webPath = "/srv/http/dynmap/";

View File

@ -2,6 +2,8 @@ package org.dynmap.kzedmap;
import java.awt.Color;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Scanner;
import java.util.logging.Level;
@ -35,8 +37,11 @@ public class KzedMap extends Map {
public KzedMap(MapManager manager, World world, Debugger debugger) {
super(manager, world, debugger);
if (colors == null)
getDebugger().debug("Loading colors...");
if (colors == null) {
getDebugger().debug("Loading colors2...");
colors = loadColorSet("colors.txt");
}
renderers = new MapTileRenderer[] {
new DefaultTileRenderer("t", debugger),
new CaveTileRenderer("ct", debugger),
@ -312,14 +317,21 @@ public class KzedMap extends Map {
}
*/
public static java.util.Map<Integer, Color[]> loadColorSet(String colorsetpath) {
public java.util.Map<Integer, Color[]> loadColorSet(String colorsetpath) {
java.util.Map<Integer, Color[]> colors = new HashMap<Integer, Color[]>();
/* load colorset */
File cfile = new File(colorsetpath);
InputStream stream;
try {
Scanner scanner = new Scanner(cfile);
/* load colorset */
File cfile = new File(colorsetpath);
if (cfile.exists()) {
stream = new FileInputStream(cfile);
} else {
stream = KzedMap.class.getResourceAsStream("/colors.txt");
}
Scanner scanner = new Scanner(stream);
int nc = 0;
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
@ -347,6 +359,7 @@ public class KzedMap extends Map {
}
scanner.close();
} catch(Exception e) {
getDebugger().error("Could not load colors", e);
return null;
}
return colors;