From 45952d37592573481d755d9b47a0caad98f4f5d6 Mon Sep 17 00:00:00 2001 From: Myles Date: Wed, 20 Apr 2016 00:50:44 +0100 Subject: [PATCH] Move Idle thread. --- .../ViaVersion/handlers/ViaDecodeHandler.java | 1 - .../protocol1_9to1_8/Protocol1_9TO1_8.java | 2 - .../protocol1_9to1_8}/ViaIdleThread.java | 2 +- .../packets/WorldPackets.java | 44 ++++++++++--------- 4 files changed, 25 insertions(+), 24 deletions(-) rename src/main/java/us/myles/ViaVersion/{ => protocols/protocol1_9to1_8}/ViaIdleThread.java (97%) diff --git a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java index 6c597c2b6..e8acbf654 100644 --- a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java +++ b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java @@ -6,7 +6,6 @@ import io.netty.handler.codec.ByteToMessageDecoder; import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.ViaVersion; -import us.myles.ViaVersion.api.ViaVersionAPI; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.type.Type; import us.myles.ViaVersion.exception.CancelException; diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9TO1_8.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9TO1_8.java index 238ecf582..3fe179b76 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9TO1_8.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/Protocol1_9TO1_8.java @@ -4,8 +4,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import org.bukkit.Bukkit; -import org.bukkit.inventory.ItemStack; -import us.myles.ViaVersion.ViaIdleThread; import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.ViaVersion; diff --git a/src/main/java/us/myles/ViaVersion/ViaIdleThread.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ViaIdleThread.java similarity index 97% rename from src/main/java/us/myles/ViaVersion/ViaIdleThread.java rename to src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ViaIdleThread.java index 4b4456614..393b3d1d2 100644 --- a/src/main/java/us/myles/ViaVersion/ViaIdleThread.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/ViaIdleThread.java @@ -1,4 +1,4 @@ -package us.myles.ViaVersion; +package us.myles.ViaVersion.protocols.protocol1_9to1_8; import io.netty.channel.ChannelHandlerContext; import org.bukkit.scheduler.BukkitRunnable; diff --git a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java index fdc1f1ccf..f2fcccc13 100644 --- a/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java +++ b/src/main/java/us/myles/ViaVersion/protocols/protocol1_9to1_8/packets/WorldPackets.java @@ -232,8 +232,12 @@ public class WorldPackets { @Override public void handle(PacketWrapper wrapper) throws Exception { int status = wrapper.get(Type.UNSIGNED_BYTE, 0); - if (status == 6) + if (status == 5) wrapper.cancel(); + if(status > 5){ + wrapper.set(Type.UNSIGNED_BYTE, 0, (short) (status - 1)); + } + System.out.println("SENDING ID: " + wrapper.get(Type.UNSIGNED_BYTE, 0)); } }); // Blocking @@ -251,25 +255,25 @@ public class WorldPackets { } }); // Digging patch (prevents it glitching) - handler(new PacketHandler() { - @Override - public void handle(PacketWrapper wrapper) throws Exception { - if(!ViaVersion.getConfig().isBlockBreakPatch()) return; - - EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); - final Position block = wrapper.get(Type.POSITION, 0); - int status = wrapper.get(Type.UNSIGNED_BYTE, 0); - if (status == 0) { - entityTracker.setCurrentlyDigging(null); - } - if (status == 1) { - entityTracker.setCurrentlyDigging(null); - } - if (status == 2) { - entityTracker.setCurrentlyDigging(block); - } - } - }); +// handler(new PacketHandler() { +// @Override +// public void handle(PacketWrapper wrapper) throws Exception { +// if(!ViaVersion.getConfig().isBlockBreakPatch()) return; +// +// EntityTracker entityTracker = wrapper.user().get(EntityTracker.class); +// final Position block = wrapper.get(Type.POSITION, 0); +// int status = wrapper.get(Type.UNSIGNED_BYTE, 0); +// if (status == 0) { +// entityTracker.setCurrentlyDigging(null); +// } +// if (status == 1) { +// entityTracker.setCurrentlyDigging(null); +// } +// if (status == 2) { +// entityTracker.setCurrentlyDigging(block); +// } +// } +// }); } });