mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-19 03:39:17 +00:00
- Fixed Java 7 compatibility due to accidental usage of Java 8-only methods
- Fixed mod support loading even if the respective mod isn't present - Fixed iterator implementations missing the remove method (fine in Java 8, but not in Java 7) - Added /mt mods command
This commit is contained in:
1 parent
3827eba3e2
commit
8e47ca9317
11 files changed
+80
-25
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package minetweaker.api.mods;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stan
|
||||
*/
|
||||
public class IMod {
|
||||
|
||||
}
|
||||
@@ -141,12 +141,14 @@ public class GlobalRegistry {
|
||||
}
|
||||
|
||||
public static void registerExpansion(Class cls) {
|
||||
for (Annotation annotation : cls.getAnnotationsByType(ZenExpansion.class)) {
|
||||
ZenExpansion eAnnotation = (ZenExpansion) annotation;
|
||||
if (!expansions.containsKey(eAnnotation.value())) {
|
||||
expansions.put(eAnnotation.value(), new TypeExpansion());
|
||||
for (Annotation annotation : cls.getAnnotations()) {
|
||||
if (annotation instanceof ZenExpansion) {
|
||||
ZenExpansion eAnnotation = (ZenExpansion) annotation;
|
||||
if (!expansions.containsKey(eAnnotation.value())) {
|
||||
expansions.put(eAnnotation.value(), new TypeExpansion());
|
||||
}
|
||||
expansions.get(eAnnotation.value()).expand(cls, types);
|
||||
}
|
||||
expansions.get(eAnnotation.value()).expand(cls, types);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -70,5 +70,10 @@ public class ScriptProviderCascade implements IScriptProvider {
|
||||
currentValue = current.next();
|
||||
} while (executed.contains(currentValue.getGroupName()) && hasNext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-1
@@ -106,7 +106,7 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
}
|
||||
|
||||
private class ProviderIterator implements Iterator<IScriptIterator> {
|
||||
private Iterator<MemoryModule> baseIterator = modules.values().iterator();
|
||||
private final Iterator<MemoryModule> baseIterator = modules.values().iterator();
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
@@ -117,6 +117,11 @@ public class ScriptProviderMemory implements IScriptProvider {
|
||||
public IScriptIterator next() {
|
||||
return new ScriptIterator(baseIterator.next());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
|
||||
private class ScriptIterator implements IScriptIterator {
|
||||
|
||||
@@ -55,6 +55,11 @@ public class CloseablePriorityList<T> implements Iterable<T> {
|
||||
current = current == null ? first : current.next;
|
||||
return current.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
}
|
||||
|
||||
private class CloseableEntry implements Closeable {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package minetweaker.mc172;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -65,7 +67,9 @@ public class MineTweakerCommand implements ICommand {
|
||||
"minetweaker oredict",
|
||||
" Outputs all ore dictionary entries in the game to the minetweaker log",
|
||||
"minetweaker oredict <name>",
|
||||
" Outputs all items in the given ore dictionary entry to the minetweaker log"
|
||||
" Outputs all items in the given ore dictionary entry to the minetweaker log",
|
||||
"minetweaker mods",
|
||||
" Outputs all active mod IDs in the game"
|
||||
/* "minetweaker name <id>[:<meta>]",
|
||||
" Prints the unlocalized name of the specified item," +
|
||||
" can be used as item or block name",
|
||||
@@ -194,6 +198,13 @@ public class MineTweakerCommand implements ICommand {
|
||||
}
|
||||
}
|
||||
sendChatMessage(icommandsender, "List generated; see minetweaker.log in your minecraft dir");
|
||||
} else if (arguments[0].equals("mods")) {
|
||||
List<ModContainer> mods = Loader.instance().getActiveModList();
|
||||
MineTweakerAPI.logger.logCommand("Mods list:");
|
||||
for (ModContainer mod : mods) {
|
||||
sendChatMessage(icommandsender, mod.getModId());
|
||||
MineTweakerAPI.logger.logCommand("Mod: " + mod.getModId());
|
||||
}
|
||||
}
|
||||
|
||||
/*if (arguments[0].equals("name")) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.EventHandler;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
@@ -77,11 +78,13 @@ public class MineTweakerMod {
|
||||
MineTweakerRegistry.getClasses(classes);
|
||||
|
||||
outer: for (Class cls : classes) {
|
||||
for (Annotation annotation : cls.getAnnotationsByType(ModOnly.class)) {
|
||||
String[] value = ((ModOnly) annotation).value();
|
||||
for (String mod : value) {
|
||||
if (!Loader.isModLoaded(mod)) {
|
||||
continue outer; // skip this class
|
||||
for (Annotation annotation : cls.getAnnotations()) {
|
||||
if (annotation instanceof ModOnly) {
|
||||
String[] value = ((ModOnly) annotation).value();
|
||||
for (String mod : value) {
|
||||
if (!Loader.isModLoaded(mod)) {
|
||||
continue outer; // skip this class
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package minetweaker.mods.ic2;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
import minetweaker.mods.ic2.expand.ItemExpansion;
|
||||
import minetweaker.mods.ic2.machines.Compressor;
|
||||
@@ -19,11 +20,15 @@ import minetweaker.mods.ic2.machines.ThermalCentrifuge;
|
||||
*/
|
||||
public class ClassRegistry {
|
||||
public static void register() {
|
||||
MineTweakerAPI.registerClass(ItemExpansion.class);
|
||||
|
||||
MineTweakerAPI.registerClass(Compressor.class);
|
||||
MineTweakerAPI.registerClass(Extractor.class);
|
||||
MineTweakerAPI.registerClass(Macerator.class);
|
||||
MineTweakerAPI.registerClass(ThermalCentrifuge.class);
|
||||
if (Loader.isModLoaded("IC2")) {
|
||||
MineTweakerAPI.logger.logInfo("Loading IC2 support");
|
||||
|
||||
MineTweakerAPI.registerClass(ItemExpansion.class);
|
||||
|
||||
MineTweakerAPI.registerClass(Compressor.class);
|
||||
MineTweakerAPI.registerClass(Extractor.class);
|
||||
MineTweakerAPI.registerClass(Macerator.class);
|
||||
MineTweakerAPI.registerClass(ThermalCentrifuge.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package minetweaker.mods.nei;
|
||||
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import minetweaker.MineTweakerAPI;
|
||||
|
||||
/**
|
||||
@@ -14,6 +15,10 @@ import minetweaker.MineTweakerAPI;
|
||||
*/
|
||||
public class ClassRegistry {
|
||||
public static void register() {
|
||||
MineTweakerAPI.registerClass(NEI.class);
|
||||
if (Loader.isModLoaded("NotEnoughItems")) {
|
||||
MineTweakerAPI.logger.logInfo("Loading NEI support");
|
||||
|
||||
MineTweakerAPI.registerClass(NEI.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ package stanhebben.zenscript.type;
|
||||
import stanhebben.zenscript.annotations.CompareType;
|
||||
import stanhebben.zenscript.annotations.OperatorType;
|
||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||
import stanhebben.zenscript.compiler.IEnvironmentMethod;
|
||||
import stanhebben.zenscript.expression.Expression;
|
||||
import stanhebben.zenscript.expression.ExpressionCompareGeneric;
|
||||
import stanhebben.zenscript.expression.ExpressionInvalid;
|
||||
|
||||
@@ -114,7 +114,7 @@ public class JavaMethod {
|
||||
this.method = method;
|
||||
|
||||
returnType = types.getType(method.getGenericReturnType());
|
||||
parameterTypes = new ZenType[method.getParameterCount()];
|
||||
parameterTypes = new ZenType[method.getParameterTypes().length];
|
||||
optional = new boolean[parameterTypes.length];
|
||||
for (int i = 0; i < parameterTypes.length; i++) {
|
||||
parameterTypes[i] = types.getType(method.getGenericParameterTypes()[i]);
|
||||
@@ -173,7 +173,7 @@ public class JavaMethod {
|
||||
int result = PRIORITY_HIGH;
|
||||
if (arguments.length > parameterTypes.length) {
|
||||
if (method.isVarArgs()) {
|
||||
ZenType arrayType = parameterTypes[method.getParameterCount() - 1];
|
||||
ZenType arrayType = parameterTypes[method.getParameterTypes().length - 1];
|
||||
ZenType baseType = ((ZenTypeArray) arrayType).getBaseType();
|
||||
for (int i = parameterTypes.length - 1; i < arguments.length; i++) {
|
||||
ZenType argType = arguments[i].getType();
|
||||
@@ -205,7 +205,7 @@ public class JavaMethod {
|
||||
|
||||
int checkUntil = arguments.length;
|
||||
if (arguments.length == parameterTypes.length && method.isVarArgs()) {
|
||||
ZenType arrayType = parameterTypes[method.getParameterCount() - 1];
|
||||
ZenType arrayType = parameterTypes[method.getParameterTypes().length - 1];
|
||||
ZenType baseType = ((ZenTypeArray) arrayType).getBaseType();
|
||||
ZenType argType = arguments[arguments.length - 1].getType();
|
||||
|
||||
@@ -265,8 +265,8 @@ public class JavaMethod {
|
||||
return arguments;
|
||||
}
|
||||
|
||||
Expression[] result = new Expression[method.getParameterCount()];
|
||||
for (int i = arguments.length; i < method.getParameterCount(); i++) {
|
||||
Expression[] result = new Expression[method.getParameterTypes().length];
|
||||
for (int i = arguments.length; i < method.getParameterTypes().length; i++) {
|
||||
result[i] = parameterTypes[i].defaultValue(position);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user