Update implementer
This commit is contained in:
parent
d3c382947d
commit
3ed1ef0624
@ -10,7 +10,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
public class EnumDefinalizer implements Implementer {
|
public class EnumDefinalizer implements Implementer {
|
||||||
|
|
||||||
private static final Set<String> ENUM = Set.of(
|
static final Set<String> ENUM = Set.of(
|
||||||
"org/bukkit/Material",
|
"org/bukkit/Material",
|
||||||
"org/bukkit/potion/PotionType",
|
"org/bukkit/potion/PotionType",
|
||||||
"org/bukkit/entity/EntityType",
|
"org/bukkit/entity/EntityType",
|
||||||
|
|||||||
@ -57,13 +57,16 @@ public class InventoryImplementer implements Implementer {
|
|||||||
if (t instanceof LocalizedException) {
|
if (t instanceof LocalizedException) {
|
||||||
ArclightImplementer.LOGGER.error(MARKER, ((LocalizedException) t).node(), ((LocalizedException) t).args());
|
ArclightImplementer.LOGGER.error(MARKER, ((LocalizedException) t).node(), ((LocalizedException) t).args());
|
||||||
} else {
|
} else {
|
||||||
ArclightImplementer.LOGGER.error(t);
|
ArclightImplementer.LOGGER.error(MARKER, "Error processing class", t);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInventoryClass(ClassNode node, ILaunchPluginService.ITransformerLoader transformerLoader) throws Throwable {
|
private boolean isInventoryClass(ClassNode node, ILaunchPluginService.ITransformerLoader transformerLoader) throws Throwable {
|
||||||
|
if (node == null) { // maybe runtime defined class
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Integer ret = map.get(node.name);
|
Integer ret = map.get(node.name);
|
||||||
if (ret != null) return ret > 1;
|
if (ret != null) return ret > 1;
|
||||||
Integer i = map.get(node.superName);
|
Integer i = map.get(node.superName);
|
||||||
@ -89,21 +92,19 @@ public class InventoryImplementer implements Implementer {
|
|||||||
|
|
||||||
private ClassNode findClass(String typeName, ILaunchPluginService.ITransformerLoader transformerLoader) throws Exception {
|
private ClassNode findClass(String typeName, ILaunchPluginService.ITransformerLoader transformerLoader) throws Exception {
|
||||||
try {
|
try {
|
||||||
|
byte[] array;
|
||||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(typeName + ".class");
|
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(typeName + ".class");
|
||||||
if (stream == null) throw LocalizedException.checked("implementer.not-found", typeName);
|
if (stream != null) {
|
||||||
byte[] array = ByteStreams.toByteArray(stream);
|
array = ByteStreams.toByteArray(stream);
|
||||||
|
} else {
|
||||||
|
array = transformerLoader.buildTransformedClassNodeFor(Type.getObjectType(typeName).getClassName());
|
||||||
|
}
|
||||||
ClassNode node = new ClassNode();
|
ClassNode node = new ClassNode();
|
||||||
new ClassReader(array).accept(node, ClassReader.SKIP_CODE);
|
new ClassReader(array).accept(node, ClassReader.SKIP_CODE);
|
||||||
return node;
|
return node;
|
||||||
} catch (Throwable e) {
|
} catch (ClassNotFoundException e) {
|
||||||
try {
|
ArclightImplementer.LOGGER.debug("implementer.not-found", typeName);
|
||||||
byte[] bytes = transformerLoader.buildTransformedClassNodeFor(Type.getObjectType(typeName).getClassName());
|
return null;
|
||||||
ClassNode node = new ClassNode();
|
|
||||||
new ClassReader(bytes).accept(node, ClassReader.SKIP_CODE);
|
|
||||||
return node;
|
|
||||||
} catch (Throwable t) {
|
|
||||||
throw LocalizedException.checked("implementer.not-found", typeName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
package io.izzel.arclight.boot.asm;
|
package io.izzel.arclight.boot.asm;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||||
import org.apache.logging.log4j.Marker;
|
import org.apache.logging.log4j.Marker;
|
||||||
import org.apache.logging.log4j.MarkerManager;
|
import org.apache.logging.log4j.MarkerManager;
|
||||||
@ -27,13 +26,7 @@ public class SwitchTableFixer implements Implementer, Function<byte[], byte[]> {
|
|||||||
|
|
||||||
public static final SwitchTableFixer INSTANCE = new SwitchTableFixer();
|
public static final SwitchTableFixer INSTANCE = new SwitchTableFixer();
|
||||||
private static final Marker MARKER = MarkerManager.getMarker("SWITCH_TABLE");
|
private static final Marker MARKER = MarkerManager.getMarker("SWITCH_TABLE");
|
||||||
private static final Set<String> ENUMS = ImmutableSet.<String>builder()
|
private static final Set<String> ENUMS = EnumDefinalizer.ENUM;
|
||||||
.add("org/bukkit/Material")
|
|
||||||
.add("org/bukkit/entity/EntityType")
|
|
||||||
.add("org/bukkit/World$Environment")
|
|
||||||
.add("org/bukkit/entity/Villager$Profession")
|
|
||||||
.add("org/bukkit/block/Biome")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] apply(byte[] bytes) {
|
public byte[] apply(byte[] bytes) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user