diff --git a/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java b/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java index 0dbc5377cd..f552501cdc 100644 --- a/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java +++ b/bukkit/cpw/mods/fml/server/FMLBukkitHandler.java @@ -79,6 +79,34 @@ public class FMLBukkitHandler implements IFMLSidedHandler */ public void onPreLoad(MinecraftServer minecraftServer) { + try + { + Class.forName("BaseModMp", false, getClass().getClassLoader()); + MinecraftServer.field_6038_a.severe("" + + "Forge Mod Loader has detected that this server has an ModLoaderMP installed alongside Forge Mod Loader.\n" + + "This will cause a serious problem with compatibility. To protect your worlds, this minecraft server will now shutdown.\n" + + "You should follow the installation instructions of either Minecraft Forge of Forge Mod Loader and NOT install ModLoaderMP \n" + + "into the minecraft_server.jar file " + + "before this server will be allowed to start up.\n\nFailure to do so will simply result in more startup failures.\n\n" + + "The authors of Minecraft Forge and Forge Mod Loader strongly suggest you talk to your mod's authors and get them to\nupdate their " + + "requirements. ModLoaderMP is not compatible with Minecraft Forge on the server and they will need to update their mod\n" + + "for Minecraft Forge and other server compatibility, unless they are Minecraft Forge mods, in which case they already\n" + + "don't need ModLoaderMP and the mod author simply has failed to update his requirements and should be informed appropriately.\n\n" + + "The authors of Forge Mod Loader would like to be compatible with ModLoaderMP but it is closed source and owned by SDK.\n" + + "SDK, the author of ModLoaderMP, has a standing invitation to submit compatibility patches \n" + + "to the open source community project that is Forge Mod Loader so that this incompatibility doesn't last. \n" + + "Users who wish to enjoy mods of both types are " + + "encouraged to request of SDK that he submit a\ncompatibility patch to the Forge Mod Loader project at \n" + + "http://github.com/cpw/FML.\nPosting on the minecraft forums at\nhttp://www.minecraftforum.net/topic/86765- (the MLMP thread)\n" + + "may encourage him in this effort. However, I ask that your requests be polite.\n" + + "Now, the server has to shutdown so you can reinstall your minecraft_server.jar\nproperly, until such time as we can work together."); + throw new RuntimeException( + "This FML based server has detected an installation of ModLoaderMP alongside. This will cause serious compatibility issues, so the server will now shut down."); + } + catch (ClassNotFoundException e) + { + // We're safe. continue + } server = minecraftServer; FMLCommonHandler.instance().registerSidedDelegate(this); CommonRegistry.registerRegistry(new BukkitRegistry()); diff --git a/bukkit/cpw/mods/fml/server/ModLoaderModContainer.java b/bukkit/cpw/mods/fml/server/ModLoaderModContainer.java index 54f72e9ab0..58491887a1 100644 --- a/bukkit/cpw/mods/fml/server/ModLoaderModContainer.java +++ b/bukkit/cpw/mods/fml/server/ModLoaderModContainer.java @@ -85,13 +85,15 @@ public class ModLoaderModContainer implements ModContainer private void configureMod() { File configDir = Loader.instance().getConfigDir(); - File modConfig = new File(configDir, String.format("%s.cfg", modClazz.getSimpleName())); + String modConfigName = modClazz.getSimpleName(); + File modConfig = new File(configDir, String.format("%s.cfg", modConfigName)); Properties props = new Properties(); if (modConfig.exists()) { try { + Loader.log.fine(String.format("Reading existing configuration file for %s : %s", modConfigName, modConfig.getName())); FileReader configReader = new FileReader(modConfig); props.load(configReader); configReader.close(); @@ -130,10 +132,12 @@ public class ModLoaderModContainer implements ModContainer { defaultValue = f.get(null); propertyValue = props.getProperty(propertyName, extractValue(defaultValue)); - Object currentValue = parseValue(propertyValue, property, f.getType()); + Object currentValue = parseValue(propertyValue, property, f.getType(), propertyName, modConfigName); + Loader.log.finest(String.format("Configuration for %s.%s found values default: %s, configured: %s, interpreted: %s", modConfigName, propertyName, defaultValue, propertyValue, currentValue)); if (currentValue != null && !currentValue.equals(defaultValue)) { + Loader.log.finest(String.format("Configuration for %s.%s value set to: %s", modConfigName, propertyName, currentValue)); f.set(null, currentValue); } } @@ -168,6 +172,7 @@ public class ModLoaderModContainer implements ModContainer { props.setProperty(propertyName, extractValue(propertyValue)); } + comments.append("\n"); } } } @@ -178,6 +183,7 @@ public class ModLoaderModContainer implements ModContainer FileWriter configWriter = new FileWriter(modConfig); props.store(configWriter, comments.toString()); configWriter.close(); + Loader.log.fine(String.format("Configuration for %s written to %s", modConfigName, modConfig.getName())); } catch (IOException e) { @@ -188,7 +194,7 @@ public class ModLoaderModContainer implements ModContainer } } - private Object parseValue(String val, MLProp property, Class type) + private Object parseValue(String val, MLProp property, Class type, String propertyName, String modConfigName) { if (type.isAssignableFrom(String.class)) { @@ -198,41 +204,42 @@ public class ModLoaderModContainer implements ModContainer { return Boolean.parseBoolean(val); } - else if (Number.class.isAssignableFrom(type)) + else if (Number.class.isAssignableFrom(type) || type.isPrimitive()) { Number n = null; - if (Double.class.isAssignableFrom(type)) + if (type.isAssignableFrom(Double.TYPE) || Double.class.isAssignableFrom(type)) { n = Double.parseDouble(val); } - if (Float.class.isAssignableFrom(type)) + else if (type.isAssignableFrom(Float.TYPE) || Float.class.isAssignableFrom(type)) { n = Float.parseFloat(val); } - if (Long.class.isAssignableFrom(type)) + else if (type.isAssignableFrom(Long.TYPE) || Long.class.isAssignableFrom(type)) { n = Long.parseLong(val); } - if (Integer.class.isAssignableFrom(type)) + else if (type.isAssignableFrom(Integer.TYPE) || Integer.class.isAssignableFrom(type)) { n = Integer.parseInt(val); } - if (Short.class.isAssignableFrom(type)) + else if (type.isAssignableFrom(Short.TYPE) || Short.class.isAssignableFrom(type)) { n = Short.parseShort(val); } - if (Byte.class.isAssignableFrom(type)) + else if (type.isAssignableFrom(Byte.TYPE) || Byte.class.isAssignableFrom(type)) { n = Byte.parseByte(val); } else { - throw new IllegalArgumentException("MLProp declared on non-standard type"); + throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName())); } if (n.doubleValue() < property.min() || n.doubleValue() > property.max()) { + Loader.log.warning(String.format("Configuration for %s.%s found value %s outside acceptable range %s,%s", modConfigName,propertyName, n, property.min(), property.max())); return null; } else @@ -241,7 +248,7 @@ public class ModLoaderModContainer implements ModContainer } } - return null; + throw new IllegalArgumentException(String.format("MLProp declared on %s of type %s, an unsupported type",propertyName, type.getName())); } private String extractValue(Object value) { diff --git a/bukkit/net/minecraft/server/MLProp.java b/bukkit/net/minecraft/server/MLProp.java index 25a20cbbd2..e17928d3d0 100644 --- a/bukkit/net/minecraft/server/MLProp.java +++ b/bukkit/net/minecraft/server/MLProp.java @@ -33,12 +33,12 @@ String info() default ""; /** * Maximum value allowed if field is a number. */ -double max() default 1D; + double max() default Double.MAX_VALUE; /** * Minimum value allowed if field is a number. */ -double min() default -1D; + double min() default Double.MIN_VALUE; /** * Overrides the field name for property key.