Combine support for pre 1.4.5 versions and new 1.4.x packaging crud
This commit is contained in:
parent
5a9d9fd957
commit
53886ce0ab
3 changed files with 481 additions and 173 deletions
|
|
@ -2,7 +2,6 @@ package org.dynmap.bukkit;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
@ -16,8 +15,6 @@ import java.util.concurrent.Callable;
|
|||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
|
|
@ -60,8 +57,6 @@ import org.bukkit.event.world.SpawnChangeEvent;
|
|||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.bukkit.material.Tree;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
|
@ -112,7 +107,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
/* Lookup cache */
|
||||
private World last_world;
|
||||
private BukkitWorld last_bworld;
|
||||
|
||||
|
||||
private BukkitVersionHelper helper = BukkitVersionHelper.getHelper();
|
||||
|
||||
private final BukkitWorld getWorldByName(String name) {
|
||||
if((last_world != null) && (last_world.getName().equals(name))) {
|
||||
return last_bworld;
|
||||
|
|
@ -636,57 +633,29 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
}
|
||||
|
||||
public void loadExtraBiomes() {
|
||||
Field tmpfld;
|
||||
Field humfld;
|
||||
int cnt = 0;
|
||||
try {
|
||||
tmpfld = BiomeBase.class.getField("temperature");
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
try {
|
||||
tmpfld = BiomeBase.class.getField("F");
|
||||
} catch (NoSuchFieldException nsfx2) {
|
||||
Log.warning("BiomeBase.temperature field not found");
|
||||
tmpfld = null;
|
||||
}
|
||||
}
|
||||
if((tmpfld != null) && (tmpfld.getType().getClass().isAssignableFrom(float.class) == false)) {
|
||||
tmpfld = null;
|
||||
}
|
||||
try {
|
||||
humfld = BiomeBase.class.getField("humidity");
|
||||
} catch (NoSuchFieldException nsfx) {
|
||||
try {
|
||||
humfld = BiomeBase.class.getField("G");
|
||||
} catch (NoSuchFieldException nsfx2) {
|
||||
Log.warning("BiomeBase.humidity field not found");
|
||||
humfld = null;
|
||||
}
|
||||
}
|
||||
if((humfld != null) && (humfld.getType().getClass().isAssignableFrom(float.class) == false)) {
|
||||
humfld = null;
|
||||
}
|
||||
|
||||
for(int i = BiomeMap.LAST_WELL_KNOWN+1; i < BiomeBase.biomes.length; i++) {
|
||||
BiomeBase bb = BiomeBase.biomes[i];
|
||||
/* Find array of biomes in biomebase */
|
||||
Object[] biomelist = helper.getBiomeBaseList();
|
||||
/* Loop through list, starting afer well known biomes */
|
||||
for(int i = BiomeMap.LAST_WELL_KNOWN+1; i < biomelist.length; i++) {
|
||||
Object bb = biomelist[i];
|
||||
if(bb != null) {
|
||||
String id = "BIOME_" + i;
|
||||
float tmp = 0.5F, hum = 0.5F;
|
||||
try {
|
||||
id = bb.y;
|
||||
} catch (Exception x) {}
|
||||
try {
|
||||
if(tmpfld != null)
|
||||
tmp = tmpfld.getFloat(bb);
|
||||
if(humfld != null)
|
||||
hum = humfld.getFloat(bb);
|
||||
} catch (Exception x) {
|
||||
String id = helper.getBiomeBaseIDString(bb);
|
||||
if(id == null) {
|
||||
id = "BIOME_" + i;
|
||||
}
|
||||
float tmp = helper.getBiomeBaseTemperature(bb);
|
||||
float hum = helper.getBiomeBaseHumidity(bb);
|
||||
|
||||
BiomeMap m = new BiomeMap(i, id, tmp, hum);
|
||||
Log.verboseinfo("Add custom biome [" + m.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
Log.info("Added " + cnt + " custom biome mappings");
|
||||
if(cnt > 0) {
|
||||
Log.info("Added " + cnt + " custom biome mappings");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue