Fix PS compatibility on Java 16

This commit is contained in:
KennyTV 2021-05-15 09:28:18 +02:00
parent 1538ff5201
commit 4f9f3254be
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
6 changed files with 11 additions and 22 deletions

View File

@ -21,6 +21,8 @@ import com.viaversion.viaversion.ViaVersionPlugin;
import com.viaversion.viaversion.bukkit.handlers.BukkitDecodeHandler;
import com.viaversion.viaversion.bukkit.handlers.BukkitEncodeHandler;
import com.viaversion.viaversion.bukkit.util.NMSUtil;
import com.viaversion.viaversion.classgenerator.generated.BasicHandlerConstructor;
import com.viaversion.viaversion.classgenerator.generated.HandlerConstructor;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
@ -144,7 +146,7 @@ public class ClassGenerator {
}
}
}
return generated.toClass(HandlerConstructor.class.getClassLoader());
return generated.toClass(HandlerConstructor.class);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (CannotCompileException e) {
@ -153,7 +155,7 @@ public class ClassGenerator {
return null;
}
private static Class addPSCompatibility(ClassPool pool, Class input, Class superclass) {
private static void addPSCompatibility(ClassPool pool, Class input, Class superclass) {
boolean newPS = getOldPSPackage().equals("unknown");
String newName = "com.viaversion.viaversion.classgenerator.generated." + input.getSimpleName();
@ -193,13 +195,12 @@ public class ClassGenerator {
}
}
}
return generated.toClass(HandlerConstructor.class.getClassLoader());
generated.toClass(HandlerConstructor.class);
} catch (NotFoundException e) {
e.printStackTrace();
} catch (CannotCompileException e) {
e.printStackTrace();
}
return null;
}
private static Class makePSConnectListener(ClassPool pool, boolean newVersionMethod) {
@ -247,7 +248,7 @@ public class ClassGenerator {
// In any case, remove the packet listener and wrap up.
+ " connection.removePacketListener(this);\n"
+ "}", connectListenerClazz));
return connectListenerClazz.toClass(HandlerConstructor.class.getClassLoader());
return connectListenerClazz.toClass(HandlerConstructor.class);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -19,7 +19,7 @@ package com.viaversion.viaversion.bukkit.handlers;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.bukkit.classgenerator.ClassGenerator;
import com.viaversion.viaversion.bukkit.classgenerator.HandlerConstructor;
import com.viaversion.viaversion.classgenerator.generated.HandlerConstructor;
import com.viaversion.viaversion.connection.UserConnectionImpl;
import com.viaversion.viaversion.protocol.ProtocolPipelineImpl;
import io.netty.channel.Channel;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.bukkit.classgenerator;
package com.viaversion.viaversion.classgenerator.generated;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.bukkit.handlers.BukkitDecodeHandler;

View File

@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.bukkit.classgenerator;
package com.viaversion.viaversion.classgenerator.generated;
import com.viaversion.viaversion.api.connection.UserConnection;
import io.netty.handler.codec.ByteToMessageDecoder;

View File

@ -17,9 +17,7 @@
*/
package com.viaversion.viaversion.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@ -79,17 +77,7 @@ public class ConcurrentList<E> extends ArrayList<E> {
@Override
public Object clone() {
synchronized (lock) {
try {
ConcurrentList<E> clist = (ConcurrentList<E>) super.clone();
clist.modCount = 0;
Field f = ArrayList.class.getDeclaredField("elementData");
f.setAccessible(true);
f.set(clist, Arrays.copyOf((Object[]) f.get(this), this.size()));
return clist;
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
return super.clone();
}
}

View File

@ -6,7 +6,7 @@ adventure = "4.7.0"
gson = "2.8.6"
fastutil = "8.3.1"
openNBT = "2.0-SNAPSHOT"
javassist = "3.27.0-GA"
javassist = "3.28.0-GA"
# Common provided
netty = "4.0.20.Final"