From a60e2522c952fa01639e306d700531d4f49befa1 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Mon, 8 Dec 2014 16:24:27 -0500 Subject: [PATCH] [TinyProtocol] Update to 1.8 --- Examples/TinyProtocol/pom.xml | 29 +++++---------- .../comphenix/tinyprotocol/ExamplePlugin.java | 6 ++-- .../comphenix/tinyprotocol/TinyProtocol.java | 36 +++++++++---------- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/Examples/TinyProtocol/pom.xml b/Examples/TinyProtocol/pom.xml index 7b12ec93..7bf3321c 100644 --- a/Examples/TinyProtocol/pom.xml +++ b/Examples/TinyProtocol/pom.xml @@ -3,32 +3,18 @@ 4.0.0 com.comphenix.tinyprotocol TinyProtocol - 0.1.0 + 0.2.0 TinyProtocol Intercept packets without ProtocolLib. - - - comphenix-releases - Comphenix Maven Releases - http://repo.comphenix.net/content/repositories/releases/ - - - comphenix-snapshots - Comphenix Maven Snapshots - http://repo.comphenix.net/content/repositories/snapshots/ - - - - md_5-repo - http://repo.md-5.net/content/repositories/public/ + spigot-repo + https://hub.spigotmc.org/nexus/content/groups/public/ - comphenix-rep - Comphenix Maven Releases - http://repo.comphenix.net/content/groups/public + shadowvolt-repo + http://ci.shadowvolt.com/plugin/repository/everything/ @@ -56,12 +42,13 @@ org.spigotmc spigot-api - 1.7.10-R0.1-SNAPSHOT + 1.8-R0.1-SNAPSHOT org.spigotmc spigot - 1.7.10-R0.1-SNAPSHOT + 1.8-R0.1-SNAPSHOT + provided diff --git a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/ExamplePlugin.java b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/ExamplePlugin.java index 1526a306..82b7da37 100644 --- a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/ExamplePlugin.java +++ b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/ExamplePlugin.java @@ -1,5 +1,7 @@ package com.comphenix.tinyprotocol; +import io.netty.channel.Channel; + import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.command.Command; @@ -10,8 +12,6 @@ import org.bukkit.plugin.java.JavaPlugin; import com.comphenix.tinyprotocol.Reflection.ConstructorInvoker; import com.comphenix.tinyprotocol.Reflection.FieldAccessor; -import net.minecraft.util.io.netty.channel.Channel; - public class ExamplePlugin extends JavaPlugin { // Chat packets private FieldAccessor CHAT_MESSAGE = Reflection.getField( @@ -86,7 +86,7 @@ public class ExamplePlugin extends JavaPlugin { sender.sendMessage(ChatColor.RED + "Can only be invoked by a player."); } return false; - } + } private void sendExplosion(Player player) { try { diff --git a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java index ab725e04..5bc8b8f3 100644 --- a/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/Examples/TinyProtocol/src/main/java/com/comphenix/tinyprotocol/TinyProtocol.java @@ -1,5 +1,14 @@ package com.comphenix.tinyprotocol; +import io.netty.channel.Channel; +import io.netty.channel.ChannelDuplexHandler; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.ChannelPromise; + import java.util.Collections; import java.util.List; import java.util.Map; @@ -8,17 +17,6 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; -import net.minecraft.util.com.mojang.authlib.GameProfile; -// These are not versioned, but they require CraftBukkit -import net.minecraft.util.io.netty.channel.Channel; -import net.minecraft.util.io.netty.channel.ChannelDuplexHandler; -import net.minecraft.util.io.netty.channel.ChannelFuture; -import net.minecraft.util.io.netty.channel.ChannelHandlerContext; -import net.minecraft.util.io.netty.channel.ChannelInboundHandlerAdapter; -import net.minecraft.util.io.netty.channel.ChannelInitializer; -import net.minecraft.util.io.netty.channel.ChannelPipeline; -import net.minecraft.util.io.netty.channel.ChannelPromise; - import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -33,6 +31,7 @@ import com.comphenix.tinyprotocol.Reflection.FieldAccessor; import com.comphenix.tinyprotocol.Reflection.MethodInvoker; import com.google.common.collect.Lists; import com.google.common.collect.MapMaker; +import com.mojang.authlib.GameProfile; /** * Represents a very tiny alternative to ProtocolLib in 1.7.2. @@ -83,7 +82,7 @@ public abstract class TinyProtocol { protected Plugin plugin; /** - * Construct a new instance of TinyProtocol, and start intercepting packets for all connected clients and future clients. + * Construct a new instance of TinyProtocol, and start intercepting packets for all connected clients and future clients. *

* You can construct multiple instances per plugin. * @param plugin - the plugin. @@ -146,7 +145,7 @@ public abstract class TinyProtocol { listener = new Listener() { @EventHandler(priority = EventPriority.LOWEST) public final void onPlayerLogin(PlayerLoginEvent e) { - if (closed) + if (closed) return; Channel channel = getChannel(e.getPlayer()); @@ -182,7 +181,7 @@ public abstract class TinyProtocol { List list = Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection); for (Object item : list) { - if (!ChannelFuture.class.isInstance(item)) + if (!ChannelFuture.class.isInstance(item)) break; // Channel future that contains the server connection @@ -204,6 +203,7 @@ public abstract class TinyProtocol { // Remove channel handler serverChannel.eventLoop().execute(new Runnable() { + @Override public void run() { try { pipeline.remove(serverChannelHandler); @@ -302,7 +302,7 @@ public abstract class TinyProtocol { } /** - * Add a custom channel handler to the given player's channel pipeline, + * Add a custom channel handler to the given player's channel pipeline, * allowing us to intercept sent and received packets. *

* This will automatically be called when a player has logged in. @@ -336,7 +336,7 @@ public abstract class TinyProtocol { channel.pipeline().addBefore("packet_handler", handlerName, interceptor); uninjectedChannels.remove(channel); } - return interceptor; + return interceptor; } catch (IllegalArgumentException e) { // Try again return (PacketInterceptor) channel.pipeline().get(handlerName); @@ -429,7 +429,7 @@ public abstract class TinyProtocol { * Channel handler that is inserted into the player's channel pipeline, allowing us to intercept sent and received packets. * @author Kristian */ - private final class PacketInterceptor extends ChannelDuplexHandler { + private final class PacketInterceptor extends ChannelDuplexHandler { // Updated by the login event public volatile Player player; @@ -450,7 +450,7 @@ public abstract class TinyProtocol { } } @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { + public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { try { msg = onPacketOutAsync(player, ctx.channel(), msg); } catch (Exception e) {