Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c0d932c48 | ||
|
|
c43d992619 | ||
|
|
c2e0fe6b4c | ||
|
|
14a783560c | ||
|
|
2767b99479 | ||
|
|
3d7a0d901f | ||
|
|
177e9b7f4e | ||
|
|
4711ede9bc | ||
|
|
6bd531efc0 | ||
|
|
d6f1bf972e | ||
|
|
3295b1fc89 | ||
|
|
f620e45a9c | ||
|
|
825b61a24e | ||
|
|
dc5d15ba85 |
No files matched your search
@@ -1,7 +1,7 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Report a bug to help us fix
|
||||
title: "[BUG REPORT]"
|
||||
about: Report bugs to help us improve our software.
|
||||
title: ""
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
@@ -10,11 +10,21 @@ assignees: ''
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
**Software brand**
|
||||
Please let us know what software you are using.
|
||||
Eg. Spigot 1.18.2, Paper 1.18.2, Tuinity 1.18.2, Pufferfish 1.18.2, etc...
|
||||
Make sure to mention the version of the software.
|
||||
|
||||
**Plugins**
|
||||
Please give us a list of your plugins. Sometimes we run into incompatibilities. Having an overview of the plugins on your server can really help identify the problem quicker.
|
||||
Eg. ViaVersion, ProtocolLib, HolographicDisplays
|
||||
You may also provide a screenshot.
|
||||
|
||||
**How To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
*Example:*
|
||||
1. Login on the 1.16.4 minecraft client.
|
||||
2. Join the server while it is still starting up.
|
||||
1. Join with the 1.18.2 vanilla minecraft client.
|
||||
2. Spam
|
||||
3. ....
|
||||
4. See error
|
||||
|
||||
@@ -24,18 +34,5 @@ A clear and concise description of what you expected to happen.
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**About your server (please complete the following information):**
|
||||
- Spigot: [eg. Paper or Tuinity]
|
||||
We only accept reports that are reproducible
|
||||
on one of the supported spigots.
|
||||
|
||||
- Server Version: [eg. 1.16.4]
|
||||
Feel free to report bugs for versions newer than 1.7.10, even if we
|
||||
don’t support them yet, but be aware that we might have already
|
||||
found the bug and fixed it in a dev build, just before you reported it.
|
||||
Please don’t get frustrated in such cases.
|
||||
|
||||
- Plugins List if possible: [eg. ViaVersion, ProtocolLib, HolographicDisplays]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -3,7 +3,7 @@
|
||||
[](https://github.com/retrooper/packetevents/blob/dev/LICENSE)
|
||||
[](https://jitpack.io/#retrooper/packetevents)
|
||||
|
||||
PacketEvents is an open-source Packet API. It has many cross-version packet-wrappers. You can process incoming and outgoing packets on the server. You can even send packets with our packet-wrappers. We are here to save you a ton of time.
|
||||
PacketEvents is a powerful packet library. Our packet wrappers are efficient and easy to use. We support many protocol versions. (1.8+)
|
||||
|
||||
### Resources
|
||||
* [SpigotMC](https://www.spigotmc.org/resources/packetevents-api.80279/)
|
||||
@@ -13,10 +13,6 @@ PacketEvents is an open-source Packet API. It has many cross-version packet-wrap
|
||||
### Setup
|
||||
[Learn more](https://github.com/retrooper/packetevents/wiki/1.-Setup)
|
||||
|
||||
### Contributing/Forking
|
||||
[Learn more](https://github.com/retrooper/packetevents/wiki/2.-Contributing-and-Forking)\
|
||||
Our discord server has a role for contributors and forkers.
|
||||
|
||||
### Sponsorships
|
||||
[](https://www.ej-technologies.com/products/jprofiler/overview.html)
|
||||
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.jetbrains:annotations:22.0.0'
|
||||
implementation 'org.jetbrains:annotations:23.0.0'
|
||||
|
||||
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
||||
@@ -66,7 +66,7 @@ dependencies {
|
||||
}
|
||||
|
||||
group = 'io.github.retrooper'
|
||||
version = '1.8.1'
|
||||
version = '1.8.4'
|
||||
description = 'packetevents'
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public final class PacketEvents implements Listener, EventManager {
|
||||
private static PacketEvents instance;
|
||||
private static Plugin plugin;
|
||||
private final PEVersion version = new PEVersion(1, 8, 1);
|
||||
private final PEVersion version = new PEVersion(1, 8, 4);
|
||||
private final EventManager eventManager = new PEEventManager();
|
||||
private final PlayerUtils playerUtils = new PlayerUtils();
|
||||
private final ServerUtils serverUtils = new ServerUtils();
|
||||
@@ -161,10 +161,12 @@ public final class PacketEvents implements Listener, EventManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void loadAsyncNewThread() {
|
||||
new Thread(this::load).start();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void loadAsync(ExecutorService executorService) {
|
||||
executorService.execute(this::load);
|
||||
}
|
||||
|
||||
@@ -18,8 +18,14 @@
|
||||
|
||||
package io.github.retrooper.packetevents;
|
||||
|
||||
import io.github.retrooper.packetevents.event.PacketListenerAbstract;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketPlayReceiveEvent;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.play.out.setslot.WrappedPacketOutSetSlot;
|
||||
import io.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PacketEventsPlugin extends JavaPlugin {
|
||||
@@ -37,6 +43,16 @@ public class PacketEventsPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
/*PacketEvents.get().getEventManager().registerListener(new PacketListenerAbstract() {
|
||||
@Override
|
||||
public void onPacketPlayReceive(PacketPlayReceiveEvent event) {
|
||||
if (event.getPacketId() == PacketType.Play.Client.USE_ENTITY) {
|
||||
ItemStack stack = new ItemStack(Material.STICK);
|
||||
WrappedPacketOutSetSlot setSlot = new WrappedPacketOutSetSlot(0, 2, stack);
|
||||
PacketEvents.get().getPlayerUtils().sendPacket(event.getPlayer(), setSlot);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
PacketEvents.get().init();
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -20,6 +20,7 @@ package io.github.retrooper.packetevents.injector.legacy;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
||||
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.io.netty.channel.ChannelDuplexHandler;
|
||||
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
|
||||
@@ -44,6 +45,11 @@ public class PlayerChannelHandlerLegacy extends ChannelDuplexHandler {
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
||||
if (packet instanceof ByteBuf) {
|
||||
//Ignore bytebufs!
|
||||
super.write(ctx, packet, promise);
|
||||
return;
|
||||
}
|
||||
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
||||
if (data.postAction != null) {
|
||||
promise.addListener(f -> {
|
||||
|
||||
+1
-3
@@ -25,7 +25,6 @@ import io.github.retrooper.packetevents.packetwrappers.NMSPacket;
|
||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.utils.list.ListWrapper;
|
||||
import io.github.retrooper.packetevents.utils.nms.NMSUtils;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.ChannelFuture;
|
||||
import net.minecraft.util.io.netty.channel.ChannelHandler;
|
||||
@@ -130,8 +129,7 @@ public class EarlyChannelInjectorLegacy implements EarlyInjector {
|
||||
WrappedPacket networkManagerWrapper = new WrappedPacket(new NMSPacket(networkManager), NMSUtils.networkManagerClass);
|
||||
Channel channel = (Channel) networkManagerWrapper.readObject(0, NMSUtils.nettyChannelClass);
|
||||
if (channel == null ||
|
||||
(!(channel.getClass().equals(NioSocketChannel.class))) &&
|
||||
!(channel.getClass().equals(EpollSocketChannel.class))) {
|
||||
(!channel.getClass().equals(NioSocketChannel.class))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -21,7 +21,6 @@ package io.github.retrooper.packetevents.injector.legacy.early;
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||
import io.github.retrooper.packetevents.utils.reflection.Reflection;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.ChannelInitializer;
|
||||
import net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel;
|
||||
@@ -49,8 +48,7 @@ public class PEChannelInitializerLegacy extends ChannelInitializer<Channel> {
|
||||
protected void initChannel(Channel channel) throws Exception {
|
||||
initChannelMethod.invoke(oldChannelInitializer, channel);
|
||||
PlayerChannelHandlerLegacy channelHandler = new PlayerChannelHandlerLegacy();
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)) {
|
||||
if (channel.pipeline().get("packet_handler") != null) {
|
||||
String handlerName = PacketEvents.get().getHandlerName();
|
||||
if (channel.pipeline().get(handlerName) != null) {
|
||||
|
||||
+1
-3
@@ -21,7 +21,6 @@ package io.github.retrooper.packetevents.injector.legacy.late;
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.injector.LateInjector;
|
||||
import io.github.retrooper.packetevents.injector.legacy.PlayerChannelHandlerLegacy;
|
||||
import io.netty.channel.epoll.EpollSocketChannel;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -42,8 +41,7 @@ public class LateChannelInjectorLegacy implements LateInjector {
|
||||
PlayerChannelHandlerLegacy playerChannelHandlerLegacy = new PlayerChannelHandlerLegacy();
|
||||
playerChannelHandlerLegacy.player = player;
|
||||
Channel channel = (Channel) PacketEvents.get().getPlayerUtils().getChannel(player);
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)) {
|
||||
channel.pipeline().addBefore("packet_handler", PacketEvents.get().getHandlerName(), playerChannelHandlerLegacy);
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -20,6 +20,7 @@ package io.github.retrooper.packetevents.injector.modern;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.processor.PacketProcessorInternal;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -44,6 +45,11 @@ public class PlayerChannelHandlerModern extends ChannelDuplexHandler {
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, Object packet, final ChannelPromise promise) throws Exception {
|
||||
if (packet instanceof ByteBuf) {
|
||||
//Ignore bytebufs!
|
||||
super.write(ctx, packet, promise);
|
||||
return;
|
||||
}
|
||||
PacketProcessorInternal.PacketData data = PacketEvents.get().getInternalPacketProcessor().write(player, ctx.channel(), packet);
|
||||
if (data.postAction != null) {
|
||||
promise.addListener(f -> {
|
||||
|
||||
+3
-2
@@ -39,12 +39,13 @@ public class PEChannelInitializerModern extends ChannelInitializer<Channel> {
|
||||
|
||||
public static void postInitChannel(Channel channel) {
|
||||
if (channel.getClass().equals(NioSocketChannel.class)
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
|| channel.getClass().equals(EpollSocketChannel.class)) {
|
||||
PlayerChannelHandlerModern channelHandler = new PlayerChannelHandlerModern();
|
||||
if (channel.pipeline().get("packet_handler") != null) {
|
||||
String handlerName = PacketEvents.get().getHandlerName();
|
||||
if (channel.pipeline().get(handlerName) != null) {
|
||||
PacketEvents.get().getPlugin().getLogger().warning("[PacketEvents] Attempted to initialize a channel twice!");
|
||||
//Just ignore this to support latest ProtocolLib snapshots.
|
||||
//PacketEvents.get().getPlugin().getLogger().warning("[PacketEvents] Attempted to initialize a channel twice!");
|
||||
} else {
|
||||
channel.pipeline().addBefore("packet_handler", handlerName, channelHandler);
|
||||
}
|
||||
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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 io.github.retrooper.packetevents.injector.modern.early;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.netty.channel.Channel;
|
||||
import net.kyori.adventure.key.Key;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
public class PaperChannelInjector {
|
||||
public static final boolean PAPER_INJECTION_METHOD = hasPaperInjectionMethod();
|
||||
|
||||
private PaperChannelInjector() {
|
||||
}
|
||||
|
||||
public static void setPaperChannelInitializeListener() throws ReflectiveOperationException {
|
||||
// Call io.papermc.paper.network.ChannelInitializeListenerHolder.addListener(net.kyori.adventure.key.Key, io.papermc.paper.network.ChannelInitializeListener)
|
||||
// Create an interface proxy of ChannelInitializeListener
|
||||
Class<?> listenerClass = Class.forName("io.papermc.paper.network.ChannelInitializeListener");
|
||||
Object channelInitializeListener = Proxy.newProxyInstance(EarlyChannelInjectorModern.class.getClassLoader(), new Class[]{listenerClass}, (proxy, method, args) -> {
|
||||
if (method.getName().equals("afterInitChannel")) {
|
||||
PEChannelInitializerModern.postInitChannel((Channel) args[0]);
|
||||
return null;
|
||||
}
|
||||
return method.invoke(proxy, args);
|
||||
});
|
||||
|
||||
Class<?> holderClass = Class.forName("io.papermc.paper.network.ChannelInitializeListenerHolder");
|
||||
Method addListenerMethod = holderClass.getDeclaredMethod("addListener", Key.class, listenerClass);
|
||||
Key key = Key.key(PacketEvents.get().getHandlerName().toLowerCase(), "injector");
|
||||
addListenerMethod.invoke(null, key, channelInitializeListener);
|
||||
}
|
||||
|
||||
public static void removePaperChannelInitializeListener() throws ReflectiveOperationException {
|
||||
Class<?> holderClass = Class.forName("io.papermc.paper.network.ChannelInitializeListenerHolder");
|
||||
Method addListenerMethod = holderClass.getDeclaredMethod("removeListener", Key.class);
|
||||
Key key = Key.key(PacketEvents.get().getHandlerName().toLowerCase(), "injector");
|
||||
addListenerMethod.invoke(null, key);
|
||||
}
|
||||
|
||||
private static boolean hasPaperInjectionMethod() {
|
||||
try {
|
||||
Class.forName("io.papermc.paper.network.ChannelInitializeListener");
|
||||
return true;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -71,7 +71,15 @@ public class WrappedPacketOutBlockChange extends WrappedPacket implements Sendab
|
||||
@Override
|
||||
protected void load() {
|
||||
getNMSBlockMethodCache = Reflection.getMethod(NMSUtils.iBlockDataClass, "getBlock", 0);
|
||||
if (getNMSBlockMethodCache == null) {
|
||||
Class<?> blockDataClass = NMSUtils.iBlockDataClass.getSuperclass();
|
||||
getNMSBlockMethodCache = Reflection.getMethod(blockDataClass, NMSUtils.blockClass, 0);
|
||||
}
|
||||
getNMSWorldTypeMethodCache = Reflection.getMethod(NMSUtils.nmsWorldClass, "getType", 0);
|
||||
if (getNMSWorldTypeMethodCache == null) {
|
||||
getNMSWorldTypeMethodCache = Reflection.getMethod(NMSUtils.nmsWorldClass,
|
||||
"getBlockStateIfLoaded", 0);
|
||||
}
|
||||
v_1_7_10 = version.isOlderThan(ServerVersion.v_1_8);
|
||||
v_1_17 = version.isNewerThanOrEquals(ServerVersion.v_1_17);
|
||||
if (v_1_17) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: packetevents
|
||||
version: 1.8.1
|
||||
version: 1.8.4
|
||||
main: io.github.retrooper.packetevents.PacketEventsPlugin
|
||||
author: retrooper
|
||||
softdepend:
|
||||
|
||||
Reference in new issue
Block a user