Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e652f0c44 | ||
|
|
4a3e89d713 | ||
|
|
3dd6d1e0b9 | ||
|
|
f42e1ad71d | ||
|
|
b44f36185a | ||
|
|
1621adad02 | ||
|
|
d2682242ae | ||
|
|
0b26fe3266 | ||
|
|
0354ddf765 | ||
|
|
82e0d01c29 | ||
|
|
57b68f185c | ||
|
|
8f9b8c0433 | ||
|
|
27ced0fc36 |
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>io.github.retrooper</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.7</version>
|
||||
<version>1.7.2</version>
|
||||
|
||||
<!-- You can build the project with this: "mvn clean compile assembly:single" -->
|
||||
<build>
|
||||
|
||||
@@ -56,9 +56,9 @@ public final class PacketEvents implements Listener {
|
||||
|
||||
private static final PacketEventsAPI packetEventsAPI = new PacketEventsAPI();
|
||||
private static final PacketEvents instance = new PacketEvents();
|
||||
private static final ArrayList<Plugin> plugins = new ArrayList<Plugin>(1);
|
||||
private static final ArrayList<Plugin> plugins = new ArrayList<>(1);
|
||||
private static boolean loaded, initialized;
|
||||
private static final PEVersion version = new PEVersion(1, 7);
|
||||
private static final PEVersion version = new PEVersion(1, 7, 2);
|
||||
|
||||
private static PacketEventsSettings settings = new PacketEventsSettings();
|
||||
|
||||
@@ -169,9 +169,8 @@ public final class PacketEvents implements Listener {
|
||||
}
|
||||
|
||||
getAPI().getEventManager().unregisterAllListeners();
|
||||
|
||||
initialized = false;
|
||||
NettyPacketManager.executorService.shutdownNow();
|
||||
initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,8 +211,12 @@ public final class PacketEvents implements Listener {
|
||||
public void onLogin(PlayerLoginEvent e) {
|
||||
if (PacketEvents.getSettings().shouldInjectEarly()) {
|
||||
assert getAPI().packetManager.tinyProtocol != null;
|
||||
if (getAPI().packetManager.tinyProtocol.canInject(e.getPlayer())) {
|
||||
getAPI().packetManager.injectPlayer(e.getPlayer());
|
||||
try {
|
||||
if (getAPI().packetManager.tinyProtocol.canInject(e.getPlayer())) {
|
||||
getAPI().packetManager.injectPlayer(e.getPlayer());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
e.disallow(PlayerLoginEvent.Result.KICK_OTHER, "We are unable to inject you. Please try again!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,8 @@ import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.event.PacketListener;
|
||||
import io.github.retrooper.packetevents.event.annotation.PacketHandler;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketReceiveEvent;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketSendEvent;
|
||||
import io.github.retrooper.packetevents.event.impl.PlayerInjectEvent;
|
||||
import io.github.retrooper.packetevents.packettype.PacketType;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.animation.WrappedPacketOutAnimation;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.explosion.WrappedPacketOutExplosion;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.chat.WrappedPacketInChat;
|
||||
import io.github.retrooper.packetevents.utils.server.ServerVersion;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@@ -50,11 +47,5 @@ public class MainExample extends JavaPlugin implements PacketListener {
|
||||
useProtocolLibIfAvailable(true).checkForUpdates(true).injectEarly(true);
|
||||
PacketEvents.getAPI().getEventManager().registerListener(this);
|
||||
PacketEvents.init(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
PacketEvents.stop();
|
||||
}
|
||||
}
|
||||
@@ -182,6 +182,7 @@ public class PacketManager {
|
||||
}
|
||||
break;
|
||||
case "PacketStatusOutPong":
|
||||
case "PacketStatusOutServerInfo":
|
||||
final PacketStatusEvent packetStatusEvent = new PacketStatusEvent(channel, packet);
|
||||
PacketEvents.getAPI().getEventManager().callEvent(packetStatusEvent);
|
||||
interceptStatus(packetStatusEvent);
|
||||
@@ -223,6 +224,7 @@ public class PacketManager {
|
||||
case "PacketLoginOutSetCompression":
|
||||
case "PacketLoginOutSuccess":
|
||||
case "PacketStatusOutPong":
|
||||
case "PacketStatusOutServerInfo":
|
||||
break;
|
||||
default:
|
||||
PacketEvents.getAPI().getEventManager().callEvent(new PostPacketSendEvent(player, packet));
|
||||
|
||||
+6
-3
@@ -33,17 +33,20 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class NettyPacketManager {
|
||||
public static boolean v1_7_nettyMode = false;
|
||||
public static final boolean v1_7_nettyMode;
|
||||
public static final ExecutorService
|
||||
executorService =
|
||||
Executors.newFixedThreadPool(Math.max(Runtime.getRuntime().availableProcessors(), 64));
|
||||
|
||||
static {
|
||||
boolean v1_7_nettyMode1;
|
||||
try {
|
||||
Class.forName("io.netty.channel.Channel");
|
||||
Class.forName("net.minecraft.util.io.netty.channel.Channel");
|
||||
v1_7_nettyMode1 = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
v1_7_nettyMode = true;
|
||||
v1_7_nettyMode1 = false;
|
||||
}
|
||||
v1_7_nettyMode = v1_7_nettyMode1;
|
||||
}
|
||||
|
||||
private Plugin plugin;
|
||||
|
||||
+6
-2
@@ -109,12 +109,16 @@ public class TinyProtocol {
|
||||
}
|
||||
|
||||
public boolean canInject(Player player) {
|
||||
Object channel = getChannel(player);
|
||||
if(channel == null) {
|
||||
return false;
|
||||
}
|
||||
if (NettyPacketManager.v1_7_nettyMode) {
|
||||
TinyProtocol7 tp7 = (TinyProtocol7) tinyProt;
|
||||
return !tp7.uninjectedChannels.contains(getChannel(player));
|
||||
return !tp7.uninjectedChannels.contains(channel);
|
||||
} else {
|
||||
TinyProtocol8 tp8 = (TinyProtocol8) tinyProt;
|
||||
return !tp8.uninjectedChannels.contains(getChannel(player));
|
||||
return !tp8.uninjectedChannels.contains(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-5
@@ -27,12 +27,8 @@ import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.util.io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
@@ -252,7 +248,7 @@ public class TinyProtocol7 {
|
||||
* @return The packet to recieve instead, or NULL to cancel.
|
||||
*/
|
||||
public Object onPacketInAsync(Player sender, Channel channel, Object packet) {
|
||||
return PacketEvents.getAPI().packetManager.read(sender, channel,packet);
|
||||
return PacketEvents.getAPI().packetManager.read(sender, channel, packet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
-4
@@ -28,12 +28,8 @@ import io.github.retrooper.packetevents.packetmanager.tinyprotocol.Reflection.Me
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
|
||||
@@ -30,11 +30,12 @@ import java.util.Map;
|
||||
public class PacketType {
|
||||
public static class Status {
|
||||
public static final Map<Class<?>, Byte> packetIds = new HashMap<>();
|
||||
public static final byte PING = 0, PONG = 1;
|
||||
public static final byte PING = 0, PONG = 1, SERVER_INFO = 2;
|
||||
|
||||
public static void init() {
|
||||
packetIds.put(PacketTypeClasses.Status.PING, PING);
|
||||
packetIds.put(PacketTypeClasses.Status.PONG, PONG);
|
||||
packetIds.put(PacketTypeClasses.Status.SERVER_INFO, SERVER_INFO);
|
||||
}
|
||||
}
|
||||
public static class Login {
|
||||
|
||||
@@ -29,11 +29,12 @@ import io.github.retrooper.packetevents.utils.reflection.SubclassUtil;
|
||||
|
||||
public class PacketTypeClasses {
|
||||
public static class Status {
|
||||
public static Class<?> PING, PONG;
|
||||
public static Class<?> PING, PONG, SERVER_INFO;
|
||||
|
||||
public static void load() {
|
||||
PING = NMSUtils.getNMSClassWithoutException("PacketStatusInPing");
|
||||
PONG = NMSUtils.getNMSClassWithoutException("PacketStatusOutPong");
|
||||
SERVER_INFO = NMSUtils.getNMSClassWithoutException("PacketStatusOutServerInfo");
|
||||
PacketType.Status.init();
|
||||
}
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020 retrooper
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.vehiclemove;
|
||||
|
||||
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
|
||||
|
||||
public class WrappedPacketInVehicleMove extends WrappedPacket {
|
||||
public WrappedPacketInVehicleMove(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return readDouble(0);
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return readDouble(1);
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return readDouble(2);
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return readFloat(0);
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return readFloat(1);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public enum ServerVersion {
|
||||
this.protocolId = protocolId;
|
||||
}
|
||||
|
||||
public short toProtocolVersion() {
|
||||
public short getProtocolVersion() {
|
||||
return protocolId;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user