Update implementer
This commit is contained in:
parent
d3c382947d
commit
3ed1ef0624
|
@ -10,7 +10,7 @@ import java.util.Set;
|
|||
|
||||
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/potion/PotionType",
|
||||
"org/bukkit/entity/EntityType",
|
||||
|
|
|
@ -57,13 +57,16 @@ public class InventoryImplementer implements Implementer {
|
|||
if (t instanceof LocalizedException) {
|
||||
ArclightImplementer.LOGGER.error(MARKER, ((LocalizedException) t).node(), ((LocalizedException) t).args());
|
||||
} else {
|
||||
ArclightImplementer.LOGGER.error(t);
|
||||
ArclightImplementer.LOGGER.error(MARKER, "Error processing class", t);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (ret != null) return ret > 1;
|
||||
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 {
|
||||
try {
|
||||
byte[] array;
|
||||
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(typeName + ".class");
|
||||
if (stream == null) throw LocalizedException.checked("implementer.not-found", typeName);
|
||||
byte[] array = ByteStreams.toByteArray(stream);
|
||||
if (stream != null) {
|
||||
array = ByteStreams.toByteArray(stream);
|
||||
} else {
|
||||
array = transformerLoader.buildTransformedClassNodeFor(Type.getObjectType(typeName).getClassName());
|
||||
}
|
||||
ClassNode node = new ClassNode();
|
||||
new ClassReader(array).accept(node, ClassReader.SKIP_CODE);
|
||||
return node;
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
byte[] bytes = transformerLoader.buildTransformedClassNodeFor(Type.getObjectType(typeName).getClassName());
|
||||
ClassNode node = new ClassNode();
|
||||
new ClassReader(bytes).accept(node, ClassReader.SKIP_CODE);
|
||||
return node;
|
||||
} catch (Throwable t) {
|
||||
throw LocalizedException.checked("implementer.not-found", typeName);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
ArclightImplementer.LOGGER.debug("implementer.not-found", typeName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package io.izzel.arclight.boot.asm;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import cpw.mods.modlauncher.serviceapi.ILaunchPluginService;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
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();
|
||||
private static final Marker MARKER = MarkerManager.getMarker("SWITCH_TABLE");
|
||||
private static final Set<String> ENUMS = ImmutableSet.<String>builder()
|
||||
.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();
|
||||
private static final Set<String> ENUMS = EnumDefinalizer.ENUM;
|
||||
|
||||
@Override
|
||||
public byte[] apply(byte[] bytes) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user