Changed the version checker to be more regex friendly.

This commit is contained in:
Garbage Mule 2011-09-30 12:47:59 +02:00
parent b23d0d18cd
commit 5c3f65fabe
3 changed files with 12 additions and 27 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: MobArena
main: com.garbagemule.MobArena.MobArena
version: 0.94.3.6
version: 0.94.3.7
softdepend: [Spout,Permissions,MultiVerse,XcraftGate,Towny,Heroes,MagicSpells]
commands:
ma:

View File

@ -1343,44 +1343,29 @@ public class MAUtils
e.printStackTrace();
return 0;
}
/*
Field f = null;
try
{
String[] parts = Bukkit.getVersion().split("-");
String version = parts[5].substring(1, 5);
int v = (version.matches("[0-9]+")) ? Integer.parseInt(version) : 0;
String fieldName = (v >= 1191) ? "difficulty" : "spawnMonsters";
f = net.minecraft.server.World.class.getDeclaredField(fieldName);
if (f != null)
return f.getInt(w);
}
catch (Exception e)
{
e.printStackTrace();
}
return 0;*/
}
private static Field getSpawnMonstersField(World world)
{
try
{
String[] parts = Bukkit.getVersion().split("-");
String version = parts[5].substring(1, 5);
int v = (version.matches("[0-9]+")) ? Integer.parseInt(version) : 0;
int version = 0;
String fieldName = (v >= 1191) ? "difficulty" : "spawnMonsters";
Pattern pattern = Pattern.compile("b([0-9][0-9][0-9][0-9])jnks");
Matcher matcher = pattern.matcher(Bukkit.getVersion());
if (matcher.find())
{
String ver = matcher.group(1);
version = (ver.matches("[0-9]+")) ? Integer.parseInt(ver) : 0;
}
String fieldName = (version >= 1191) ? "difficulty" : "spawnMonsters";
return net.minecraft.server.World.class.getDeclaredField(fieldName);
}
catch (Exception e)
{
e.printStackTrace();
MobArena.error("Your CraftBukkit version is messed up somehow...");
}
return null;