SPIGOT-4602: Cache reflection in decompile error workaround

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2019-02-02 09:57:26 +11:00
parent 8b6d75b06e
commit 69ea4f2bcd

View File

@ -1,23 +1,32 @@
--- a/net/minecraft/server/ArgumentParserSelector.java
+++ b/net/minecraft/server/ArgumentParserSelector.java
@@ -98,8 +98,14 @@
@@ -97,9 +97,23 @@
this(stringreader, true);
}
public ArgumentParserSelector(StringReader stringreader, boolean flag) {
- this.q = CriterionConditionValue.c.e;
- this.r = CriterionConditionValue.d.e;
+ // CraftBukkit start - decompile error
+ // CraftBukkit start - decompile error
+ private static final CriterionConditionValue.c DEFAULT_q;
+ private static final CriterionConditionValue.d DEFAULT_r;
+
+ static {
+ try {
+ this.q = (CriterionConditionValue.c) Class.forName("net.minecraft.server.CriterionConditionValue$c").getDeclaredField("e").get(null);
+ this.r = (CriterionConditionValue.d) Class.forName("net.minecraft.server.CriterionConditionValue$d").getDeclaredField("e").get(null);
+ DEFAULT_q = (CriterionConditionValue.c) Class.forName("net.minecraft.server.CriterionConditionValue$c").getDeclaredField("e").get(null);
+ DEFAULT_r = (CriterionConditionValue.d) Class.forName("net.minecraft.server.CriterionConditionValue$d").getDeclaredField("e").get(null);
+ } catch (Exception ex) {
+ throw new AssertionError(ex);
+ }
+ }
+
public ArgumentParserSelector(StringReader stringreader, boolean flag) {
- this.q = CriterionConditionValue.c.e;
- this.r = CriterionConditionValue.d.e;
+ this.q = DEFAULT_q;
+ this.r = DEFAULT_r;
+ // CraftBukkit end
this.y = CriterionConditionRange.a;
this.z = CriterionConditionRange.a;
this.A = (entity) -> {
@@ -126,7 +132,7 @@
@@ -126,7 +140,7 @@
axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x);
}
@ -26,7 +35,7 @@
if (this.s == null && this.t == null && this.u == null) {
function = (vec3d) -> {
@@ -187,8 +193,10 @@
@@ -187,8 +201,10 @@
};
}
@ -39,7 +48,7 @@
this.G = this::d;
if (!this.l.canRead()) {
throw ArgumentParserSelector.d.createWithContext(this.l);
@@ -431,6 +439,12 @@
@@ -431,6 +447,12 @@
}
public EntitySelector s() throws CommandSyntaxException {
@ -52,7 +61,7 @@
this.E = this.l.getCursor();
this.G = this::b;
if (this.l.canRead() && this.l.peek() == '@') {
@@ -439,7 +453,7 @@
@@ -439,7 +461,7 @@
}
this.l.skip();