Skip to content

Commit

Permalink
Merge pull request #58 from retrooper/dev
Browse files Browse the repository at this point in the history
1.7.2 Release
  • Loading branch information
retrooper authored Nov 2, 2020
2 parents d268224 + 4a3e89d commit 8e652f0
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 28 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.7.1</version>
<version>1.7.2</version>

<!-- You can build the project with this: "mvn clean compile assembly:single" -->
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, 1);
private static final PEVersion version = new PEVersion(1, 7, 2);

private static PacketEventsSettings settings = new PacketEventsSettings();

Expand Down Expand Up @@ -169,9 +169,8 @@ public static void stop() {
}

getAPI().getEventManager().unregisterAllListeners();

initialized = false;
NettyPacketManager.executorService.shutdownNow();
initialized = false;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@
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;

Expand All @@ -51,9 +48,4 @@ public void onEnable() {
PacketEvents.getAPI().getEventManager().registerListener(this);
PacketEvents.init(this);
}

@Override
public void onDisable() {
PacketEvents.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public Object write(Player player, Object channel, Object packet) {
}
break;
case "PacketStatusOutPong":
case "PacketStatusOutServerInfo":
final PacketStatusEvent packetStatusEvent = new PacketStatusEvent(channel, packet);
PacketEvents.getAPI().getEventManager().callEvent(packetStatusEvent);
interceptStatus(packetStatusEvent);
Expand Down Expand Up @@ -223,6 +224,7 @@ public void postWrite(Player player, Object packet) {
case "PacketLoginOutSetCompression":
case "PacketLoginOutSuccess":
case "PacketStatusOutPong":
case "PacketStatusOutServerInfo":
break;
default:
PacketEvents.getAPI().getEventManager().callEvent(new PostPacketSendEvent(player, packet));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,20 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
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;

Expand Down Expand Up @@ -252,7 +248,7 @@ public Object onPacketOutAsync(Player receiver, Channel channel, Object packet)
* @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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@

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();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 8e652f0

Please sign in to comment.