Advertisement
Guest User

PlayerConnection.java

a guest
Jul 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 113.22 KB | None | 0 0
  1. package net.minecraft.server.v1_7_R4;
  2. import java.io.DataInputStream;
  3. import java.io.UnsupportedEncodingException;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.HashSet;
  7. import java.util.Iterator;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.concurrent.ExecutionException;
  11. import net.badlion.gspigot.protocol107.PacketPlayInVehicleMove;
  12. import net.minecraft.util.com.google.common.primitives.Doubles;
  13. import net.minecraft.util.io.netty.buffer.Unpooled;
  14. import org.bukkit.Bukkit;
  15. import org.bukkit.Location;
  16. import org.bukkit.craftbukkit.v1_7_R4.SpigotTimings;
  17. import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
  18. import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
  19. import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftInventoryView;
  20. import org.bukkit.craftbukkit.v1_7_R4.util.CraftChatMessage;
  21. import org.bukkit.craftbukkit.v1_7_R4.util.LazyPlayerSet;
  22. import org.bukkit.craftbukkit.v1_7_R4.util.Waitable;
  23. import org.bukkit.entity.Player;
  24. import org.bukkit.event.Event;
  25. import org.bukkit.event.block.Action;
  26. import org.bukkit.event.block.SignChangeEvent;
  27. import org.bukkit.event.inventory.ClickType;
  28. import org.bukkit.event.inventory.CraftItemEvent;
  29. import org.bukkit.event.inventory.InventoryAction;
  30. import org.bukkit.event.inventory.InventoryClickEvent;
  31. import org.bukkit.event.inventory.InventoryCreativeEvent;
  32. import org.bukkit.event.inventory.InventoryType;
  33. import org.bukkit.event.player.AsyncPlayerChatEvent;
  34. import org.bukkit.event.player.GCheatEvent;
  35. import org.bukkit.event.player.PlayerAnimationEvent;
  36. import org.bukkit.event.player.PlayerAttackEvent;
  37. import org.bukkit.event.player.PlayerChatEvent;
  38. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  39. import org.bukkit.event.player.PlayerInteractEntityEvent;
  40. import org.bukkit.event.player.PlayerItemHeldEvent;
  41. import org.bukkit.event.player.PlayerKickEvent;
  42. import org.bukkit.event.player.PlayerMoveEvent;
  43. import org.bukkit.event.player.PlayerTeleportEvent;
  44. import org.bukkit.event.player.PlayerToggleFlightEvent;
  45. import org.bukkit.event.player.PlayerToggleSneakEvent;
  46. import org.bukkit.event.player.PlayerToggleSprintEvent;
  47. import org.bukkit.inventory.Inventory;
  48. import org.bukkit.inventory.InventoryView;
  49. import org.bukkit.inventory.Recipe;
  50. import org.bukkit.util.NumberConversions;
  51. import org.spigotmc.SpigotConfig;
  52.  
  53. public class PlayerConnection implements PacketPlayInListener {
  54.   private static final Logger c = LogManager.getLogger();
  55.   public final NetworkManager networkManager;
  56.   private final MinecraftServer minecraftServer;
  57.   public EntityPlayer player;
  58.   private int e;
  59.   private int f;
  60.   private boolean g;
  61.   private int h;
  62.   private long i;
  63.   private static Random j = new Random();
  64.   private long k;
  65.   private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle"); private int x; private IntHashMap n; private double y; private double z; private double q; public boolean checkMovement; private boolean processedDisconnect; private final CraftServer server; private int lastTick; private int lastDropTick; private int dropCount; private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 36; private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 49; private double lastPosX; private double lastPosY; private double lastPosZ; private float lastPitch; private float lastYaw; private boolean justTeleported; private boolean hasMoved; Long lastPacket; private Item lastMaterial;
  66.  
  67.   public PlayerConnection(MinecraftServer minecraftserver, NetworkManager networkmanager, EntityPlayer entityplayer) { this.n = new IntHashMap();
  68.  
  69.  
  70.    
  71.     this.checkMovement = true;
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.    
  86.     this.lastTick = MinecraftServer.currentTick;
  87.     this.lastDropTick = MinecraftServer.currentTick;
  88.     this.dropCount = 0;
  89.  
  90.  
  91.  
  92.    
  93.     this.lastPosX = Double.MAX_VALUE;
  94.     this.lastPosY = Double.MAX_VALUE;
  95.     this.lastPosZ = Double.MAX_VALUE;
  96.     this.lastPitch = Float.MAX_VALUE;
  97.     this.lastYaw = Float.MAX_VALUE;
  98.     this.justTeleported = false;
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.    
  114.     this.hackDebug = false;
  115.     this.lastKickTimestamp = 0L;
  116.     this.realPing = 0.0D;
  117.     this.totalPing = 0L;
  118.     this.packetsNotReceived = 0;
  119.     this.lastKeepAlivePacketReceivedTime = -1L;
  120.     this.lastPacketTypeReceived = '.';
  121.     this.lastGroundYValue = -1.0D;
  122.     this.tickToKickOn = -1L;
  123.     this.kickLocationX = -1.0D;
  124.     this.kickLocationY = -1.0D;
  125.     this.kickLocationZ = -1.0D;
  126.     this.explosionHitTime = 0;
  127.     this.highestYValueBeforeOnGroundSafely = -1.0D;
  128.     this.checkNextTickForFallDamage = false;
  129.     this.lastGroundYValueForGlideHackDetection = -1.0D;
  130.     this.numOfHoverPacketsCounted = 0;
  131.     this.numOfSpeedPacketsCounted = 0;
  132.     this.numOfConsistentSpeedPacketsCounted = 0;
  133.     this.lastSpeedMoved = -1.0D;
  134.     this.lastHitTime = -1L;
  135.     this.numOfNotHitPackets = 3;
  136.     this.maxHitSpeedPacketCount = 10;
  137.     this.maxNotHitSpeedPacketCount = 5;
  138.     this.lastSpeedTime = -1L;
  139.     this.maxSpeed = -1.0D;
  140.     this.numOfMovePacketsReceived = 0;
  141.     this.packetCountReset = false;
  142.     this.critFlag = false;
  143.     this.critDeltaY = -1.0D;
  144.     this.lastCritStrike = -1L;
  145.     this.lastAttackTime = -1L;
  146.     this.lastMovementPacketTick = MinecraftServer.currentTick;
  147.     this.lastMajorPacketProcessed = MinecraftServer.currentTick;
  148.     this.numberOfPacketsReceivedSinceLastMajorTick = 0L;
  149.     this.averageMaxPacketsPerSecond = 2.5D;
  150.     this.lastFuckedUpPacketReceivedTick = 0L;
  151.     this.lastHasPos = false;
  152.     this.lastHasLook = false;
  153.     this.lastCheckedFuckedUpPacketReceivedTick = 0L;
  154.     this.numberOfMorePacketStrikes = 0L;
  155.     this.processedMajorTick = false;
  156.     this.lastHitAccuracyTick = 0L;
  157.     this.highestHitAccuracy = 0.0F;
  158.     this.highestHits = 0;
  159.     this.highestSwings = 0;
  160.     this.lastBlockGlitchFromX = 0.0D;
  161.     this.lastBlockGlitchFromZ = 0.0D;
  162.     this.lastBlockGlitchToX = 0.0D;
  163.     this.lastBlockGlitchToZ = 0.0D;
  164.     this.movesReceived = 0L;
  165.  
  166.  
  167.    
  168.     this.lastValidX = -1.0D;
  169.     this.lastValidY = -1.0D;
  170.     this.lastValidZ = -1.0D;
  171.  
  172.  
  173.    
  174.     this.lastPacketsQueue = new LinkedList();
  175.     this.killAuraViolationsTypeA = 0;
  176.     this.killAuraViolationsTypeB = 0;
  177.     this.killAuraViolationsTypeC = new HashMap();
  178.     this.killAuraViolationsTypeD = new HashMap();
  179.     this.setOffTypeE = false;
  180.     this.lastCalculatedHalfSecondTime = 0L;
  181.     this.lastHalfSecondX = 0.0D;
  182.     this.lastHalfSecondY = -1.0D;
  183.     this.lastHalfSecondZ = 0.0D;
  184.  
  185.  
  186.  
  187.  
  188.    
  189.     this.keepAlives = new HashSet();
  190.  
  191.  
  192.    
  193.     this.lastHitMotionX = 10000.0D;
  194.     this.lastHitMotionY = 10000.0D;
  195.     this.lastHitMotionZ = 10000.0D;
  196.     this.lastMotionTick = 0L;
  197.     this.antiKBViolations = 0;
  198.  
  199.    
  200.     this.lastKAPacketTick = MinecraftServer.currentTick;
  201.     this.lastKAMovementPacket = MinecraftServer.currentTick;
  202.     this.lastNotificationTick = MinecraftServer.currentTick;
  203.  
  204.  
  205.    
  206.     this.lastAttackPlayerTime = 0L;
  207.     this.isDigging = false;
  208.     this.digHorizontalMovement = 0;
  209.     this.typeRStage = 0;
  210.     this.typeRThreshold = 0;
  211.     this.typeOStage = 0;
  212.     this.typeOThreshold = 0;
  213.     this.typePStage = 0;
  214.     this.typePThreshold = 0;
  215.     this.typePOther = 0;
  216.     this.typeQStage = 0;
  217.     this.typeQThreshold = 0;
  218.  
  219.  
  220.    
  221.     this.typeE2Swing = false;
  222.  
  223.  
  224.    
  225.     this.velocitiesSent = new ArrayList();
  226.     this.velocitySentTimes = new ArrayList();
  227.     this.positionSentTime = System.currentTimeMillis();
  228.     this.reducedKbAmount = 0;
  229.     this.miniJumpAmount = 0;
  230.  
  231.  
  232.    
  233.     this.horizontalSpeed = 1.0D;
  234.     this.newHorizontalSpeed = 0.0D;
  235.    
  236.     this.blockFriction = 0.0D;
  237.     this.blockFrictionX = Integer.MAX_VALUE;
  238.     this.blockFrictionY = Integer.MAX_VALUE;
  239.     this.blockFrictionZ = Integer.MAX_VALUE;
  240.     this.previousHorizontalMove = 0.0D;
  241.     this.flyTypeDAmount = 0;
  242.     this.speedTypeDAmount = 0;
  243.  
  244.  
  245.    
  246.     this.criticalTypeBStage = 0;
  247.    
  248.     this.criticalTypeBHeight = 0.0D;
  249.  
  250.  
  251.    
  252.     this.justSentSprint = false;
  253.     this.lastSprintViolationTime = System.currentTimeMillis();
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.  
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.  
  1589.  
  1590.  
  1591.  
  1592.  
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.  
  1599.  
  1600.  
  1601.  
  1602.  
  1603.  
  1604.  
  1605.  
  1606.  
  1607.  
  1608.  
  1609.  
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.    
  1683.     this.lastPlace = -1L;
  1684.     this.packets = 0;
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860.  
  1861.  
  1862.  
  1863.  
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.    
  2315.     this.lastPlayerHitIdTypeS = 0;
  2316.     this.playerHitsTypeS = 0;
  2317.     this.lastTypeSViolationTick = 0;
  2318.     this.fakePlayerHitsTypeS = new HashMap();
  2319.     this.prplzTypeB8 = System.currentTimeMillis();
  2320.     this.prplzTypeB9 = System.currentTimeMillis(); this.minecraftServer = minecraftserver; this.networkManager = networkmanager; networkmanager.a(this); this.player = entityplayer; entityplayer.playerConnection = this; this.server = minecraftserver.server; } public CraftPlayer getPlayer() { return (this.player == null) ? null : this.player.getBukkitEntity(); } private static final HashSet<Integer> invalidItems = new HashSet(Arrays.asList(new Integer[] { null, null, null, null, null, null, null, null, null, null,
  2321.           null, null, null, null, null, null, null, null, null, null,
  2322.           null, null, null, null, null, null, null, null, null, null,
  2323.           null, null, null, null, null, null, null, (new Integer[38][36] = (new Integer[38][35] = (new Integer[38][34] = (new Integer[38][33] = (new Integer[38][32] = (new Integer[38][31] = (new Integer[38][30] = (new Integer[38][29] = (new Integer[38][28] = (new Integer[38][27] = (new Integer[38][26] = (new Integer[38][25] = (new Integer[38][24] = (new Integer[38][23] = (new Integer[38][22] = (new Integer[38][21] = (new Integer[38][20] = (new Integer[38][19] = (new Integer[38][18] = (new Integer[38][17] = (new Integer[38][16] = (new Integer[38][15] = (new Integer[38][14] = (new Integer[38][13] = (new Integer[38][12] = (new Integer[38][11] = (new Integer[38][10] = (new Integer[38][9] = (new Integer[38][8] = (new Integer[38][7] = (new Integer[38][6] = (new Integer[38][5] = (new Integer[38][4] = (new Integer[38][3] = (new Integer[38][2] = (new Integer[38][1] = (new Integer[38][0] = Integer.valueOf(8)).valueOf(9)).valueOf(10)).valueOf(11)).valueOf(26)).valueOf(34)).valueOf(36)).valueOf(43)).valueOf(51)).valueOf(52)).valueOf(55)).valueOf(59)).valueOf(60)).valueOf(62)).valueOf(63)).valueOf(64)).valueOf(68)).valueOf(71)).valueOf(74)).valueOf(75)).valueOf(83)).valueOf(90)).valueOf(92)).valueOf(93)).valueOf(94)).valueOf(104)).valueOf(105)).valueOf(115)).valueOf(117)).valueOf(118)).valueOf(119)).valueOf(125)).valueOf(127)).valueOf(132)).valueOf(140)).valueOf(141)).valueOf(142)).valueOf(144) })); public boolean hackDebug; private long lastKickTimestamp; private double realPing; private long totalPing; private int packetsNotReceived; private long lastKeepAlivePacketReceivedTime; private char lastPacketTypeReceived; public double lastGroundYValue; private long tickToKickOn; private double kickLocationX; private double kickLocationY; private double kickLocationZ; public int explosionHitTime; public double highestYValueBeforeOnGroundSafely; public boolean checkNextTickForFallDamage; private double lastGroundYValueForGlideHackDetection; private int numOfHoverPacketsCounted; public int numOfSpeedPacketsCounted; public int numOfConsistentSpeedPacketsCounted; public double lastSpeedMoved; public long lastHitTime; public int numOfNotHitPackets; private int maxHitSpeedPacketCount; private int maxNotHitSpeedPacketCount; private long lastSpeedTime; private double maxSpeed; private int numOfMovePacketsReceived; private boolean packetCountReset; private boolean critFlag; private double critDeltaY; private long lastCritStrike; public long lastAttackTime; public long lastMovementPacketTick; public long lastMajorPacketProcessed; public long numberOfPacketsReceivedSinceLastMajorTick; public double averageMaxPacketsPerSecond; public long lastFuckedUpPacketReceivedTick; public boolean lastHasPos; public boolean lastHasLook; public long lastCheckedFuckedUpPacketReceivedTick; public long numberOfMorePacketStrikes; public boolean processedMajorTick; public long lastHitAccuracyTick; public float highestHitAccuracy; public int highestHits; public int highestSwings; private double lastBlockGlitchFromX; private double lastBlockGlitchFromZ; private double lastBlockGlitchToX; private double lastBlockGlitchToZ; public long movesReceived; private double lastValidX; private double lastValidY; private double lastValidZ; public Deque<Packet> lastPacketsQueue; public int killAuraViolationsTypeA; public int killAuraViolationsTypeB; public Map<Integer, List<Long>> killAuraViolationsTypeC; public Map<Integer, List<Long>> killAuraViolationsTypeD; public boolean setOffTypeE; public long lastCalculatedHalfSecondTime; public double lastHalfSecondX; public double lastHalfSecondY; public double lastHalfSecondZ; public boolean hasMovedInHalfSecond; public long playerTime; public Set<Integer> keepAlives; public double lastHitMotionX; public void a(PacketPlayInUseEntity packetplayinuseentity) { if (packetplayinuseentity.c() == null)
  2324.       return;  if (!this.player.isAlive())
  2325.       return;  WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
  2326.     Entity entity = packetplayinuseentity.a(worldserver);
  2327.    
  2328.     if (entity == this.player) {
  2329.      
  2330.       disconnect("Cannot interact with self!");
  2331.      
  2332.       return;
  2333.     }
  2334.    
  2335.     this.player.v();
  2336.    
  2337.     if (entity == null) {
  2338.       Integer realId = (Integer)(this.player.server.getPlayerList()).fakePlayerMap.get(Integer.valueOf(packetplayinuseentity.a));
  2339.       if (realId != null) {
  2340.         entity = this.player.world.getEntity(realId.intValue());
  2341.         long now = System.currentTimeMillis();
  2342.         Iterator<Long> iter = this.fakePlayerHitsTypeS.values().iterator();
  2343.         while (iter.hasNext()) {
  2344.           if (now - ((Long)iter.next()).longValue() > 3000L) {
  2345.             iter.remove();
  2346.           }
  2347.         }
  2348.         this.fakePlayerHitsTypeS.put(Long.valueOf(packetplayinuseentity.a << 32 | realId.intValue()), Long.valueOf(now));
  2349.         int count = 0;
  2350.         for (Iterator iterator = this.fakePlayerHitsTypeS.keySet().iterator(); iterator.hasNext(); ) { long l = ((Long)iterator.next()).longValue();
  2351.           if ((l & 0xFFFFFFFFL) == realId.intValue()) {
  2352.             count++;
  2353.           } }
  2354.        
  2355.         if (count == 8 &&
  2356.           now - this.prplzTypeB8 > 1000L) {
  2357.           Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, this.player.getName() + " is using Kill Aura Type T (" + count + ")"));
  2358.           this.prplzTypeB8 = now;
  2359.         }
  2360.        
  2361.         if (count == 9 &&
  2362.           now - this.prplzTypeB9 > 1000L) {
  2363.           Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, this.player.getName() + " is using Kill Aura Type T (" + count + ")"));
  2364.           this.prplzTypeB9 = now;
  2365.         }
  2366.       }
  2367.     }
  2368.  
  2369.    
  2370.     if (entity != null) {
  2371.      
  2372.       if (entity instanceof EntityPlayer && !(entity instanceof net.badlion.gspigot.EntityNPC)) {
  2373.         EntityPlayer targetPlayer = (EntityPlayer)(this.minecraftServer.getPlayerList()).uuidMap.get(((EntityPlayer)entity).uniqueID);
  2374.         if (targetPlayer == null) {
  2375.           return;
  2376.         }
  2377.       }
  2378.      
  2379.       boolean flag = this.player.hasLineOfSight(entity);
  2380.       double d0 = 36.0D;
  2381.      
  2382.       if (!flag) {
  2383.         d0 = 9.0D;
  2384.       }
  2385.      
  2386.       if (this.player.f(entity) < d0) {
  2387.         ItemStack itemInHand = this.player.inventory.getItemInHand();
  2388.         if (packetplayinuseentity.c() == EnumEntityUseAction.INTERACT) {
  2389.          
  2390.           boolean triggerTagUpdate = (itemInHand != null && itemInHand.getItem() == Items.NAME_TAG && entity instanceof EntityInsentient);
  2391.           boolean triggerChestUpdate = (itemInHand != null && itemInHand.getItem() == Item.getItemOf(Blocks.CHEST) && entity instanceof EntityHorse);
  2392.           boolean triggerLeashUpdate = (itemInHand != null && itemInHand.getItem() == Items.LEASH && entity instanceof EntityInsentient);
  2393.           PlayerInteractEntityEvent event = new PlayerInteractEntityEvent(getPlayer(), entity.getBukkitEntity());
  2394.           this.server.getPluginManager().callEvent(event);
  2395.          
  2396.           if (triggerLeashUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.LEASH))
  2397.           {
  2398.             sendPacket(new PacketPlayOutAttachEntity(true, entity, ((EntityInsentient)entity).getLeashHolder()));
  2399.           }
  2400.          
  2401.           if (triggerTagUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Items.NAME_TAG))
  2402.           {
  2403.             sendPacket(new PacketPlayOutEntityMetadata(entity, true));
  2404.           }
  2405.           if (triggerChestUpdate && (event.isCancelled() || this.player.inventory.getItemInHand() == null || this.player.inventory.getItemInHand().getItem() != Item.getItemOf(Blocks.CHEST))) {
  2406.             sendPacket(new PacketPlayOutEntityMetadata(entity, true));
  2407.           }
  2408.          
  2409.           if (event.isCancelled()) {
  2410.             return;
  2411.           }
  2412.  
  2413.          
  2414.           this.player.q(entity);
  2415.  
  2416.          
  2417.           if (itemInHand != null && itemInHand.count <= -1) {
  2418.             this.player.updateInventory(this.player.activeContainer);
  2419.           }
  2420.         }
  2421.         else if (packetplayinuseentity.c() == EnumEntityUseAction.ATTACK) {
  2422.           if (entity instanceof EntityItem || entity instanceof EntityExperienceOrb || entity instanceof EntityArrow || entity == this.player) {
  2423.             disconnect("Attempting to attack an invalid entity");
  2424.             this.minecraftServer.warning("Player " + this.player.getName() + " tried to attack an invalid entity");
  2425.            
  2426.             return;
  2427.           }
  2428.          
  2429.           PlayerAttackEvent event = new PlayerAttackEvent(this.player.getBukkitEntity());
  2430.           this.server.getPluginManager().callEvent(event);
  2431.  
  2432.  
  2433.          
  2434.           if (this.player.isBlocking()) {
  2435.             this.player.bA();
  2436.           }
  2437.  
  2438.          
  2439.           this.player.attack(entity);
  2440.  
  2441.          
  2442.           if (packetplayinuseentity.a == this.lastPlayerHitIdTypeS && packetplayinuseentity.a == entity.getId() && entity instanceof EntityPlayer && ((EntityPlayer)entity).fakePlayerGCheatEnabled() && entity.vehicle == null && this.playerTime - ((EntityPlayer)entity).fakeEntitySpawnTime > 0L && this.player.world.spigotConfig.fakePlayerGCheatEnabled) {
  2443.  
  2444.            
  2445.             if (this.lastTypeSViolationTick + 20 < MinecraftServer.currentTick &&
  2446.               ++this.playerHitsTypeS == 5) {
  2447.               Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.KILL_AURA, GCheatEvent.Level.ADMIN, this.player.getName() + " is using Kill Aura Type U (" + this.playerHitsTypeS + ")"));
  2448.               this.playerHitsTypeS = 0;
  2449.               this.lastTypeSViolationTick = MinecraftServer.currentTick;
  2450.             }
  2451.           } else {
  2452.            
  2453.             this.lastPlayerHitIdTypeS = packetplayinuseentity.a;
  2454.             this.playerHitsTypeS = 0;
  2455.           }
  2456.  
  2457.  
  2458.          
  2459.           if (itemInHand != null && itemInHand.count <= -1)
  2460.             this.player.updateInventory(this.player.activeContainer);
  2461.         }
  2462.       }
  2463.     }  }
  2464.  
  2465.  
  2466.   public double lastHitMotionY; public double lastHitMotionZ; public long lastMotionTick; public int antiKBViolations; public long lastKAPacketTick; public long lastKAMovementPacket; public long lastNotificationTick; public long lastAttackPlayerTime; public boolean isDigging; public int digHorizontalMovement; public int typeRStage; public int typeRThreshold; public int typeOStage; public int typeOThreshold; public int typePStage; public int typePThreshold; public int typePOther; public int typeQStage; public int typeQThreshold; public boolean typeE2Swing; public final List<PacketPlayOutEntityVelocity> velocitiesSent; public final List<Long> velocitySentTimes; public long positionSentTime; public int reducedKbAmount; public int miniJumpAmount; public double horizontalSpeed; public double newHorizontalSpeed; public long newHorizontalSpeedTime; public double blockFriction; public int blockFrictionX; public int blockFrictionY; public int blockFrictionZ; public double previousHorizontalMove; public int flyTypeDAmount;
  2467.   public int speedTypeDAmount;
  2468.  
  2469.   public void a(PacketPlayInClientCommand packetplayinclientcommand) { this.player.v();
  2470.     EnumClientCommand enumclientcommand = packetplayinclientcommand.c();
  2471.    
  2472.     switch (ClientCommandOrdinalWrapper.a[enumclientcommand.ordinal()])
  2473.     { case 1:
  2474.         if (this.player.viewingCredits) {
  2475.           this.minecraftServer.getPlayerList().changeDimension(this.player, 0, PlayerTeleportEvent.TeleportCause.END_PORTAL); break;
  2476.         }  if (this.player.r().getWorldData().isHardcore()) {
  2477.           if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) {
  2478.             this.player.playerConnection.disconnect("You have died. Game over, man, it's game over!");
  2479.             this.minecraftServer.U(); break;
  2480.           }
  2481.           GameProfileBanEntry gameprofilebanentry = new GameProfileBanEntry(this.player.getProfile(), (Date)null, "(You just lost the game)", (Date)null, "Death in Hardcore");
  2482.          
  2483.           this.minecraftServer.getPlayerList().getProfileBans().add(gameprofilebanentry);
  2484.           this.player.playerConnection.disconnect("You have died. Game over, man, it's game over!");
  2485.           break;
  2486.         }
  2487.         if (this.player.getHealth() > 0.0F) {
  2488.           return;
  2489.         }
  2490.        
  2491.         this.player = this.minecraftServer.getPlayerList().moveToWorld(this.player, 0, false);
  2492.         break;
  2493.  
  2494.      
  2495.       case 2:
  2496.         this.player.getStatisticManager().a(this.player);
  2497.         break;
  2498.      
  2499.       case 3:
  2500.         this.player.a(AchievementList.f); break; }  } public int criticalTypeBStage; public double criticalTypeBY; public double criticalTypeBHeight; public boolean justSentSprint; public long lastSprintViolationTime; private long lastPlace; private int packets; public int lastPlayerHitIdTypeS; public int playerHitsTypeS; public int lastTypeSViolationTick; public final Map<Long, Long> fakePlayerHitsTypeS; public long prplzTypeB8; public long prplzTypeB9; private boolean isSameSign(double d1, double d2) { return (((d1 < 0.0D) ? 1 : 0) == ((d2 < 0.0D) ? 1 : 0)); } private boolean isValidMotion(double d1, double d2) { return (Math.abs(d1 - d2) < 0.15D); } public void a() { if (this.networkManager.getVersion() >= 107) { double x = this.player.locX; double y = this.player.locY; double z = this.player.locZ; boolean onGround = this.player.onGround; this.player.i(); this.player.setLocation(x, y, z, this.player.yaw, this.player.pitch); this.player.onGround = onGround; }  this.g = false; this.e++; this.minecraftServer.methodProfiler.a("keepAlive"); if (this.e - this.k > 10L) { this.k = this.e; this.i = d(); this.h = (int)this.i; this.packetsNotReceived++; this.keepAlives.add(Integer.valueOf(this.h)); if (this.keepAlives.size() > 120 && isAntiCheatActivated()) { disconnect("Disconnected due to lag", true); return; }  sendPacket(new PacketPlayOutKeepAlive(this.h)); }  if (this.packetsNotReceived >= 40 && isAntiCheatActivated()) { disconnect("Disconnected due to lag", true); return; }  int spam; while ((spam = this.chatThrottle) > 0 && !chatSpamField.compareAndSet(this, spam, spam - 1)); if (this.x > 0) this.x--;  if (this.player.x() > 0L && this.minecraftServer.getIdleTimeout() > 0 && MinecraftServer.ar() - this.player.x() > (this.minecraftServer.getIdleTimeout() * 1000 * 60)) disconnect("You have been idle for too long!");  } public NetworkManager b() { return this.networkManager; } public void disconnect(String s) { disconnect(s, false); } public boolean isAntiCheatActivated() { return (SpigotConfig.enableAntiCheat && MinecraftServer.tps1Above19 && !this.player.getBukkitEntity().isBypassingGCheat()); } public void disconnect(String s, boolean anticheat) { if (anticheat) if ((MinecraftServer.getServer()).tps1.getAverage() <= 19.0D) return;   String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); if (this.server.getServer().isRunning()) this.server.getPluginManager().callEvent(event);  if (event.isCancelled()) return;  s = event.getReason(); ChatComponentText chatcomponenttext = new ChatComponentText(s); this.networkManager.handle(new PacketPlayOutKickDisconnect(chatcomponenttext), new GenericFutureListener[] { new PlayerConnectionFuture(this, chatcomponenttext) }); a(chatcomponenttext); this.networkManager.g(); } public void a(PacketPlayInSteerVehicle packetplayinsteervehicle) { this.player.a(packetplayinsteervehicle.c(), packetplayinsteervehicle.d(), packetplayinsteervehicle.e(), packetplayinsteervehicle.f()); } public void a(PacketPlayInFlying packetplayinflying) { if (Double.isNaN(packetplayinflying.x) || Double.isNaN(packetplayinflying.y) || Double.isNaN(packetplayinflying.z) || Double.isNaN(packetplayinflying.stance)) { c.warn(this.player.getName() + " was caught trying to crash the server with an invalid position."); getPlayer().kickPlayer("NaN in position (Hacking?)"); return; }  WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); boolean isAntiCheatActivated = isAntiCheatActivated(); if (isAntiCheatActivated && this.tickToKickOn != -1L && MinecraftServer.currentTick >= this.tickToKickOn) { disconnect("Flying is not enabled on this server", true); if (isDisconnected()) { String msg = String.format("%s was caught flying (Type B) at %.1f %.1f %.1f", new Object[] { this.player.getName(), Double.valueOf(this.kickLocationX), Double.valueOf(this.kickLocationY), Double.valueOf(this.kickLocationZ) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.FLY, GCheatEvent.Level.ADMIN, msg)); c.warn(this.player.getName() + " was kicked for flying!"); return; }  }  long numOfTicksSinceLastPacket = this.networkManager.ticksSinceLastPacket; if (isAntiCheatActivated && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && this.player.vehicle == null) if (SpigotConfig.enableMassPacketHacking && this.networkManager.currentTime - this.positionSentTime > 1000L) { if (this.lastFuckedUpPacketReceivedTick == MinecraftServer.currentTick && this.lastCheckedFuckedUpPacketReceivedTick != MinecraftServer.currentTick && packetplayinflying.hasPos != this.lastHasPos && packetplayinflying.hasLook != this.lastHasLook) { if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " has some double packet bug");  this.lastCheckedFuckedUpPacketReceivedTick = MinecraftServer.currentTick; } else { this.numberOfPacketsReceivedSinceLastMajorTick++; this.lastFuckedUpPacketReceivedTick = MinecraftServer.currentTick; this.lastHasPos = packetplayinflying.hasPos; this.lastHasLook = packetplayinflying.hasLook; }  if (this.hackDebug) { Bukkit.getLogger().info(numOfTicksSinceLastPacket + " " + this.numberOfPacketsReceivedSinceLastMajorTick); Bukkit.getLogger().info(packetplayinflying.x + " " + packetplayinflying.y + " " + packetplayinflying.z + " " + packetplayinflying.yaw + " " + packetplayinflying.pitch + packetplayinflying.hasPos + " " + packetplayinflying.hasLook + " " + packetplayinflying.stance); }  if (!this.processedMajorTick && this.lastMajorPacketProcessed + 20L < MinecraftServer.currentTick) { long diff = MinecraftServer.currentTick - this.lastMajorPacketProcessed; this.lastMajorPacketProcessed = MinecraftServer.currentTick; this.processedMajorTick = true; if (numOfTicksSinceLastPacket > 20L) { if (this.hackDebug) Bukkit.getLogger().info("Reset because we got a flood of packets.");  this.numberOfPacketsReceivedSinceLastMajorTick = 0L; this.lastFuckedUpPacketReceivedTick = 0L; this.lastCheckedFuckedUpPacketReceivedTick = 0L; this.lastHasPos = false; this.lastHasLook = false; }  if (numOfTicksSinceLastPacket <= 20L && this.numberOfPacketsReceivedSinceLastMajorTick / diff >= this.averageMaxPacketsPerSecond) { if (this.hackDebug) Bukkit.getLogger().info("Increased by 1 for timer.");  if (++this.numberOfMorePacketStrikes >= 3L) Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.TIMER, GCheatEvent.Level.ADMIN, this.player.getName() + " is mass packet hacking Type B VL" + this.numberOfPacketsReceivedSinceLastMajorTick));  } else if (this.numberOfMorePacketStrikes > 0L) { if (this.hackDebug) Bukkit.getLogger().info("Reduced by 1 for timer.");  this.numberOfMorePacketStrikes--; }  if (this.hackDebug) Bukkit.getLogger().info("Reset " + this.numberOfPacketsReceivedSinceLastMajorTick);  this.numberOfPacketsReceivedSinceLastMajorTick = 0L; this.lastFuckedUpPacketReceivedTick = 0L; this.lastCheckedFuckedUpPacketReceivedTick = 0L; this.lastHasPos = false; this.lastHasLook = false; } else if (MinecraftServer.currentTick % 20 != 0) { this.processedMajorTick = false; }  }   this.g = true; if (!this.player.viewingCredits) { if (!this.checkMovement) { double d0 = packetplayinflying.d() - this.z; if (packetplayinflying.c() == this.y && d0 * d0 < 0.01D && packetplayinflying.e() == this.q) this.checkMovement = true;  }  this.lastKAMovementPacket = MinecraftServer.currentTick; CraftPlayer craftPlayer = getPlayer(); if (!this.hasMoved) { Location curPos = craftPlayer.getLocation(); this.lastPosX = curPos.getX(); this.lastPosY = curPos.getY(); this.lastPosZ = curPos.getZ(); this.lastYaw = curPos.getYaw(); this.lastPitch = curPos.getPitch(); this.hasMoved = true; }  Location from = new Location(craftPlayer.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); Location to = craftPlayer.getLocation().clone(); if (packetplayinflying.hasPos && (!packetplayinflying.hasPos || packetplayinflying.y != -999.0D || packetplayinflying.stance != -999.0D)) { to.setX(packetplayinflying.x); to.setY(packetplayinflying.y); to.setZ(packetplayinflying.z); }  if (packetplayinflying.hasLook) { to.setYaw(packetplayinflying.yaw); to.setPitch(packetplayinflying.pitch); }  if (isAntiCheatActivated && !this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && this.player.vehicle == null) { if (this.lastMotionTick != 0L) if (this.lastMotionTick + 20L < MinecraftServer.currentTick) { this.lastMotionTick = 0L; this.lastHitMotionX = this.lastHitMotionY = this.lastHitMotionZ = 0.0D; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " reset kb check because long time");  if (this.lastKeepAlivePacketReceivedTime + 800L > this.networkManager.currentTime) { if (++this.antiKBViolations >= 3) { String msg = String.format("%s was caught using Anti-KB at %.1f %.1f %.1f", new Object[] { this.player.getName(), Double.valueOf(to.getX()), Double.valueOf(to.getY()), Double.valueOf(to.getZ()) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.ANTI_KB, GCheatEvent.Level.ADMIN, msg)); this.antiKBViolations = 0; }  } else if (this.hackDebug) { Bukkit.getLogger().info(this.player.getName() + " is lagging too much"); }  } else if (!packetplayinflying.i()) { this.lastMotionTick = 0L; this.lastHitMotionX = this.lastHitMotionY = this.lastHitMotionZ = 0.0D; if (this.antiKBViolations > 0) this.antiKBViolations--;  if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " reset because valid KB");  }   } else { this.lastMotionTick = 0L; this.lastHitMotionX = this.lastHitMotionY = this.lastHitMotionZ = 0.0D; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " reset because creative mode");  }  double delta = Math.pow(this.lastPosX - to.getX(), 2.0D) + Math.pow(this.lastPosY - to.getY(), 2.0D) + Math.pow(this.lastPosZ - to.getZ(), 2.0D); float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); float f4 = 0.0625F; AxisAlignedBB axisalignedbb = this.player.boundingBox.clone().grow(f4, f4, f4).a(0.0D, -0.55D, 0.0D); boolean touchingAir = !worldserver.c(axisalignedbb); if ((delta > 0.00390625D || deltaAngle > 10.0F) && this.checkMovement && !this.player.dead) { this.lastPosX = to.getX(); this.lastPosY = to.getY(); this.lastPosZ = to.getZ(); this.lastYaw = to.getYaw(); this.lastPitch = to.getPitch(); if (isAntiCheatActivated) { if (this.lastCalculatedHalfSecondTime + 500L < this.networkManager.currentTime) { this.lastCalculatedHalfSecondTime = this.networkManager.currentTime; this.lastHalfSecondX = to.getX(); this.lastHalfSecondY = to.getY(); this.lastHalfSecondZ = to.getZ(); double distanceSqrd = NumberConversions.square(to.getX() - from.getX()) + NumberConversions.square(to.getZ() - from.getZ()); if (this.hackDebug) Bukkit.getLogger().info("Distance moved " + Math.sqrt(distanceSqrd));  this.hasMovedInHalfSecond = (distanceSqrd >= 0.0225D); }  boolean justTeleported = (this.lastGroundYValue == -1.0D); if (!this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && this.player.vehicle == null) { if (this.player.onGround) { this.lastGroundYValue = from.getY(); this.numOfHoverPacketsCounted = 0; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " y position on ground: " + this.lastGroundYValue);  } else { if (worldserver.containsLiquidOrClimable(axisalignedbb)) { this.lastGroundYValue = from.getY(); if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " moved in the water/ladder/vine " + from.getY());  }  if (packetplayinflying.hasPos && to.getY() > 0.0D && to.getY() == from.getY() && touchingAir && this.networkManager.lastVehicleTick + 100L < MinecraftServer.currentTick) { this.numOfHoverPacketsCounted++; if (this.numOfHoverPacketsCounted >= 5) { String msg = String.format("%s is hovering. %.1f %.1f %.1f", new Object[] { this.player.getName(), Double.valueOf(to.getX()), Double.valueOf(to.getY()), Double.valueOf(to.getZ()) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.HOVER, GCheatEvent.Level.ADMIN, msg)); this.numOfHoverPacketsCounted = 0; }  } else { this.numOfHoverPacketsCounted = 0; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " reset hover.");  }  if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " is not on the ground and has y position " + from.getY());  }  if (this.lastHitTime + 1500L < this.networkManager.currentTime && this.explosionHitTime + 200 < MinecraftServer.currentTick && this.lastGroundYValue != -1.0D && to.getY() > this.lastGroundYValue + 6.0D && touchingAir) { String msg = String.format("%s was caught flying (Type C) at %.1f %.1f %.1f", new Object[] { this.player.getName(), Double.valueOf(to.getX()), Double.valueOf(to.getY()), Double.valueOf(to.getZ()) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.FLY, GCheatEvent.Level.ADMIN, msg)); }  }  if (this.lastGroundYValue + 1.0D < to.getY()) { this.killAuraViolationsTypeA = 0; this.killAuraViolationsTypeB = 0; }  if (!this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && this.player.vehicle == null) if (this.lastGroundYValue != -1.0D) { if (this.explosionHitTime + 200 < MinecraftServer.currentTick) { long packetDiff = (numOfTicksSinceLastPacket == 0L) ? 1L : numOfTicksSinceLastPacket; if (this.hackDebug) { Bukkit.getLogger().info(getPlayer().getName() + " moved " + Math.sqrt(NumberConversions.square(to.getX() - from.getX()) + NumberConversions.square(to.getZ() - from.getZ()))); Bukkit.getLogger().info(getPlayer().getName() + " deltaY " + Math.abs(to.getY() - from.getY())); Bukkit.getLogger().info(getPlayer().getName() + " num of ticks " + packetDiff); }  double limit = 0.42D; MobEffect mobeffect = this.player.getEffect(MobEffectList.FASTER_MOVEMENT); int amplification = (mobeffect != null) ? (mobeffect.getAmplifier() + 1) : 0; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " has speed " + amplification);  boolean speedIsActive = false; switch (amplification) { case 0: limit = 0.35D; break;case 1: limit = 0.39D; this.lastSpeedTime = this.networkManager.currentTime; speedIsActive = true; break;case 2: limit = 0.42D; this.lastSpeedTime = this.networkManager.currentTime; speedIsActive = true; break;default: limit = 0.35D + 0.05D * amplification; this.lastSpeedTime = this.networkManager.currentTime; speedIsActive = true; break; }  double speed = Math.sqrt(NumberConversions.square(to.getX() - from.getX()) + NumberConversions.square(to.getZ() - from.getZ())); if (this.lastKeepAlivePacketReceivedTime + 1000L > this.networkManager.currentTime) { double speedWithLag = speed / packetDiff; if (speedWithLag > limit) { if (speedWithLag >= this.lastSpeedMoved) { if (!speedIsActive && this.networkManager.currentTime < this.lastSpeedTime + 2000L) { if (this.hackDebug) Bukkit.getLogger().severe("[" + this.networkManager.currentTime + "] " + this.player.getName() + " was given grace period.");  } else { boolean isFalsePositive = false; double roundedFromX = Math.round(from.getX() * 10000.0D) / 10000.0D; double roundedFromZ = Math.round(from.getZ() * 10000.0D) / 10000.0D; double roundedToX = Math.round(to.getX() * 10000.0D) / 10000.0D; double roundedToZ = Math.round(to.getZ() * 10000.0D) / 10000.0D; if (roundedFromX == roundedToX || roundedFromZ == roundedToZ) { isFalsePositive = true; if (this.hackDebug) Bukkit.getLogger().severe("[" + this.networkManager.currentTime + "] " + this.player.getName() + " false positive 1");  } else if (this.lastBlockGlitchFromX == roundedFromX || this.lastBlockGlitchFromZ == roundedFromZ || this.lastBlockGlitchFromX == roundedToX || this.lastBlockGlitchFromZ == roundedToX) { isFalsePositive = true; if (this.hackDebug) Bukkit.getLogger().severe("[" + this.networkManager.currentTime + "] " + this.player.getName() + " false positive 2");  } else if (this.lastBlockGlitchToX == roundedFromX || this.lastBlockGlitchToZ == roundedFromZ || this.lastBlockGlitchToX == roundedToX || this.lastBlockGlitchToZ == roundedToX) { isFalsePositive = true; if (this.hackDebug) Bukkit.getLogger().severe("[" + this.networkManager.currentTime + "] " + this.player.getName() + " false positive 2");  }  if (!isFalsePositive) { this.lastBlockGlitchFromX = roundedFromX; this.lastBlockGlitchFromZ = roundedFromZ; this.lastBlockGlitchToX = roundedToX; this.lastBlockGlitchToZ = roundedToZ; if (this.hackDebug) Bukkit.getLogger().severe("[" + this.networkManager.currentTime + "] " + this.player.getName() + " was caught sprint hacking with distance " + (speed / packetDiff));  if (++this.numOfSpeedPacketsCounted >= ((this.lastHitTime + 1500L > this.networkManager.currentTime) ? this.maxHitSpeedPacketCount : this.maxNotHitSpeedPacketCount)) { Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.DEBUG, GCheatEvent.Level.ADMIN, this.player.getName() + " is speed hacking. ADebug " + from.getX() + " " + from.getY() + " " + from.getZ())); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.DEBUG, GCheatEvent.Level.ADMIN, this.player.getName() + " is speed hacking. ADebug2 " + to.getX() + " " + to.getY() + " " + to.getZ())); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.SPEED, GCheatEvent.Level.ADMIN, this.player.getName() + " is speed hacking. Type C VL " + (Math.round(speedWithLag / limit * 10.0D) / 10.0D))); this.numOfSpeedPacketsCounted = 0; }  } else { this.numOfSpeedPacketsCounted = 0; }  }  } else if (++this.numOfNotHitPackets >= 3) { this.numOfSpeedPacketsCounted = 0; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " was reset to not being hit 1.");  }  } else { if (++this.numOfNotHitPackets >= 3) { this.numOfSpeedPacketsCounted = 0; if (this.hackDebug) Bukkit.getLogger().info(this.player.getName() + " was reset to not being hit 2.");  }  if (this.lastHitTime + 1500L < this.networkManager.currentTime) this.lastHitTime = -1L;  }  } else if (this.hackDebug) { Bukkit.getLogger().info(this.player.getName() + " is lagging."); }  this.lastSpeedMoved = speed / packetDiff; } else if (this.hackDebug) { Bukkit.getLogger().info(getPlayer().getName() + " is immune from explosion."); }  } else if (this.hackDebug) { Bukkit.getLogger().info(getPlayer().getName() + " just teleported."); }   this.lastPacketTypeReceived = 'f'; if (this.lastValidX == -1.0D) { this.lastValidX = from.getX(); this.lastValidY = from.getY(); this.lastValidZ = from.getZ(); }  }  if ((this.isDigging && to.getX() != this.player.locX) || to.getZ() != this.player.locZ) this.digHorizontalMovement++;  if (SpigotConfig.playerMoveEventEnabled) { PlayerMoveEvent event = new PlayerMoveEvent(craftPlayer, from, to); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { this.player.playerConnection.sendPacket(new PacketPlayOutPosition(from.getX(), from.getY() + 1.6200000047683716D, from.getZ(), from.getYaw(), from.getPitch(), false)); return; }  if (!to.equals(event.getTo()) && !event.isCancelled()) { this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN); return; }  }  if (!from.equals(getPlayer().getLocation()) && this.justTeleported) { this.justTeleported = false; return; }  } else if (this.lastCalculatedHalfSecondTime + 500L < this.networkManager.currentTime) { this.lastCalculatedHalfSecondTime = this.networkManager.currentTime; this.hasMovedInHalfSecond = false; }  if (this.checkMovement && !this.player.dead) { if (this.player.frozen) { float yaw = this.player.yaw; float pitch = this.player.pitch; if (packetplayinflying.hasLook) { yaw = packetplayinflying.yaw; pitch = packetplayinflying.pitch; }  this.player.setLocation(this.player.locX, this.player.locY, this.player.locZ, yaw, pitch); this.minecraftServer.getPlayerList().d(this.player); return; }  if (this.player.vehicle != null) { float f = this.player.yaw; float f1 = this.player.pitch; this.player.vehicle.ac(); double d1 = this.player.locX; double d2 = this.player.locY; double d3 = this.player.locZ; if (packetplayinflying.k()) { f = packetplayinflying.g(); f1 = packetplayinflying.h(); }  this.player.onGround = packetplayinflying.i(); if (this.networkManager.getVersion() < 107) this.player.i();  this.player.V = 0.0F; this.player.setLocation(d1, d2, d3, f, f1); if (this.player.vehicle != null) this.player.vehicle.ac();  this.minecraftServer.getPlayerList().d(this.player); if (this.checkMovement) { this.y = this.player.locX; this.z = this.player.locY; this.q = this.player.locZ; }  worldserver.playerJoinedWorld(this.player); return; }  if (this.player.isSleeping()) { if (this.networkManager.getVersion() < 107) this.player.i();  this.player.setLocation(this.y, this.z, this.q, this.player.yaw, this.player.pitch); worldserver.playerJoinedWorld(this.player); return; }  double d0 = this.player.locY; this.y = this.player.locX; this.z = this.player.locY; this.q = this.player.locZ; double d1 = this.player.locX; double d2 = this.player.locY; double d3 = this.player.locZ; float f2 = this.player.yaw; float f3 = this.player.pitch; boolean onGround = this.player.onGround; if (packetplayinflying.j() && packetplayinflying.d() == -999.0D && packetplayinflying.f() == -999.0D) packetplayinflying.a(false);  if (packetplayinflying.j()) { d1 = packetplayinflying.c(); d2 = packetplayinflying.d(); d3 = packetplayinflying.e(); double d4 = packetplayinflying.f() - packetplayinflying.d(); if (!this.player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) { disconnect("Illegal stance"); c.warn(this.player.getName() + " had an illegal stance: " + d4); return; }  if (Math.abs(packetplayinflying.c()) > 3.2E7D || Math.abs(packetplayinflying.e()) > 3.2E7D) { disconnect("Illegal position"); return; }  }  if (packetplayinflying.k()) { f2 = packetplayinflying.g(); f3 = packetplayinflying.h(); }  if (this.networkManager.getVersion() < 107) this.player.i();  this.player.V = 0.0F; this.player.setLocation(this.y, this.z, this.q, f2, f3); if (!this.checkMovement) return;  double d4 = d1 - this.player.locX; double d5 = d2 - this.player.locY; double d6 = d3 - this.player.locZ; double d7 = Math.max(Math.abs(d4), Math.abs(this.player.motX)); double d8 = Math.max(Math.abs(d5), Math.abs(this.player.motY)); double d9 = Math.max(Math.abs(d6), Math.abs(this.player.motZ)); double d10 = d7 * d7 + d8 * d8 + d9 * d9; if (d10 > SpigotConfig.movedTooQuicklyThreshold && this.checkMovement && (!this.minecraftServer.N() || !this.minecraftServer.M().equals(this.player.getName()))) { c.warn(this.player.getName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); return; }  AxisAlignedBB preBB = getBoundingBoxRounded(); boolean flag = worldserver.getCubes(this.player, preBB).isEmpty(); if (this.player.onGround && !packetplayinflying.i() && d5 > 0.0D) this.player.applyExhaustion(0.2F);  if (!this.player.abilities.canFly && !this.minecraftServer.getAllowFlight()) { boolean teleport = (this.networkManager.currentTime - this.positionSentTime < 5000L); double horizontalSpeed = this.horizontalSpeed; double blockFriction = this.blockFriction; if (onGround) { horizontalSpeed *= 1.3D; blockFriction *= 0.91D; horizontalSpeed *= 0.16277136D / blockFriction * blockFriction * blockFriction; if (isAntiCheatActivated && !packetplayinflying.i() && d5 > 1.0E-4D) { horizontalSpeed += 0.2D; MobEffect jumpBoost = this.player.getEffect(MobEffectList.JUMP); if (!teleport && !this.player.world.c(this.player.boundingBox.grow(0.5D, 0.249D, 0.5D).d(0.0D, 0.25D, 0.0D)) && jumpBoost == null) { double kb = 0.0D; for (PacketPlayOutEntityVelocity packet : this.velocitiesSent) { double packetY = packet.c / 8000.0D; if (packetY > 0.0D && (kb == 0.0D || packetY < kb)) kb = packetY;  }  if (kb == 0.0D && d5 < 0.15D) { if (this.miniJumpAmount += 20 > 70) { this.miniJumpAmount = 0; String msg = String.format("%s uses minijumps (%.3f) at %.1f,%.1f,%.1f", new Object[] { this.player.getName(), Double.valueOf(d5), Double.valueOf(d1), Double.valueOf(d2), Double.valueOf(d3) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.CRIT, GCheatEvent.Level.ADMIN, msg)); }  } else if (d5 < 0.41999998688697815D) { if (kb > 0.1D && d5 < kb * 0.99D && this.reducedKbAmount += 30 > 35) { long percent = Math.round(100.0D * d5 / kb); String msg = String.format("%s reduces their KB (%d%% %.2f/%.2f)", new Object[] { this.player.getName(), Long.valueOf(percent), Double.valueOf(d5), Double.valueOf(kb) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.ANTI_KB, GCheatEvent.Level.ADMIN, msg)); }  }  }  }  } else { horizontalSpeed = 0.026D; blockFriction = 0.91D; }  if (d4 != 0.0D || d6 != 0.0D) { double horizontalMove = Math.sqrt(d4 * d4 + d6 * d6); if (this.player.inWater) horizontalSpeed *= 3.0D;  if (isAntiCheatActivated && !teleport) { double speedup = (horizontalMove - this.previousHorizontalMove) / horizontalSpeed; if (speedup > 1.1D) { double kbSqrd = 0.0D; for (PacketPlayOutEntityVelocity packet : this.velocitiesSent) { double x = packet.b / 8000.0D; double z = packet.d / 8000.0D; double xz = x * x + z * z; if (xz > kbSqrd) kbSqrd = xz;  }  if (kbSqrd != 0.0D) { horizontalSpeed += Math.sqrt(kbSqrd); speedup = (horizontalMove - this.previousHorizontalMove) / horizontalSpeed; }  }  if (speedup > 1.1D) { boolean blocksNear = this.player.world.c(this.player.boundingBox.grow(1.5D, 1.5D, 1.5D)); if (!blocksNear) { if (this.flyTypeDAmount += 20 > 90) { this.flyTypeDAmount = 0; String msg = String.format("%s was caught flying Type D (%d%%) at %.1f,%.1f,%.1f", new Object[] { this.player.getName(), Integer.valueOf((int)(100.0D * speedup)), Double.valueOf(d1), Double.valueOf(d2), Double.valueOf(d3) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.FLY, GCheatEvent.Level.ADMIN, msg)); }  } else if (speedup > 1.5D && this.speedTypeDAmount += 20 > 90) { this.speedTypeDAmount = 0; String msg = String.format("%s was caught speeding Type D (%d%%) at %.1f,%.1f,%.1f", new Object[] { this.player.getName(), Integer.valueOf((int)(100.0D * speedup)), Double.valueOf(d1), Double.valueOf(d2), Double.valueOf(d3) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.SPEED, GCheatEvent.Level.ADMIN, msg)); }  }  }  this.previousHorizontalMove = horizontalMove * blockFriction; int blockX = NumberConversions.floor(d1); int blockY = NumberConversions.floor(d2); int blockZ = NumberConversions.floor(d3); if (blockX != this.blockFrictionX || blockY != this.blockFrictionY || blockZ != this.blockFrictionZ) { this.blockFriction = (this.player.world.getType(blockX, blockY - 1, blockZ)).frictionFactor; this.blockFrictionX = blockX; this.blockFrictionY = blockY; this.blockFrictionZ = blockZ; }  }  }  this.player.move(d4, d5, d6); this.player.onGround = packetplayinflying.i(); this.player.checkMovement(d4, d5, d6); double d11 = d5; d4 = d1 - this.player.locX; d5 = d2 - this.player.locY; if (d5 > -0.5D || d5 < 0.5D) d5 = 0.0D;  d6 = d3 - this.player.locZ; d10 = d4 * d4 + d5 * d5 + d6 * d6; boolean flag1 = false; if (d10 > SpigotConfig.movedWronglyThreshold && !this.player.isSleeping() && !this.player.playerInteractManager.isCreative()) { flag1 = true; c.warn(this.player.getName() + " moved wrongly!"); }  this.player.setLocation(d1, d2, d3, f2, f3); double dx = this.y - d1; double dy = this.z - d2; double dz = this.q - d3; if (!this.player.playerInteractManager.isCreative() && (dx != 0.0D || dy != 0.0D || dz != 0.0D)) { double m = Math.max(Math.max(Math.abs(dx) / 0.6000000238418579D, Math.abs(dy) / 1.6200000047683716D), Math.abs(dz) / 0.6000000238418579D) / 0.99D; dx /= m; dy /= m; dz /= m; AxisAlignedBB bb = getBoundingBoxRounded(); for (int i = 0; i < m; i++) { List<AxisAlignedBB> list = worldserver.getCubes(this.player, bb); if (!list.isEmpty()) for (AxisAlignedBB collision : list) { if (!preBB.b(collision)) { if (i > 0 && m > 2.0D) if (dx == 0.0D && dz == 0.0D) { String msg = String.format("%s tries to VClip %.1f blocks at %.1f,%.1f,%.1f", new Object[] { this.player.getName(), Double.valueOf(d2 - this.z), Double.valueOf(this.y), Double.valueOf(this.z), Double.valueOf(this.q) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.PHASE, GCheatEvent.Level.ADMIN, msg)); } else { String msg = String.format("%s is trying to phase at %.1f,%.1f,%.1f", new Object[] { this.player.getName(), Double.valueOf(this.y), Double.valueOf(this.z), Double.valueOf(this.q) }); Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.PHASE, GCheatEvent.Level.ADMIN, msg)); }   a(this.y, this.z, this.q, f2, f3); return; }  }   bb.d(dx, dy, dz); }  }  if (this.flyTypeDAmount > 0) this.flyTypeDAmount--;  if (this.speedTypeDAmount > 0) this.speedTypeDAmount--;  if (this.miniJumpAmount > 0) this.miniJumpAmount--;  if (this.reducedKbAmount > 0) this.reducedKbAmount--;  if (!this.minecraftServer.getAllowFlight() && !this.player.abilities.canFly && touchingAir && !this.player.frozen) { if (d11 >= -0.03125D) { this.f++; if (this.f > 80) { Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.HOVER, GCheatEvent.Level.ADMIN, this.player.getName() + " was kicked for floating too long!")); c.warn(this.player.getName() + " was kicked for floating too long!"); disconnect("Flying is not enabled on this server"); return; }  }  } else { this.f = 0; }  this.player.onGround = packetplayinflying.i(); this.minecraftServer.getPlayerList().d(this.player); this.player.b(this.player.locY - d0, packetplayinflying.i()); } else if (this.e % 20 == 0) { a(this.y, this.z, this.q, this.player.yaw, this.player.pitch); }  }  } private AxisAlignedBB getBoundingBoxRounded() { AxisAlignedBB bb = this.player.boundingBox.clone(); bb.a = Math.round(bb.a * 1000000.0D) / 1000000.0D; bb.b = Math.round(bb.b * 1000000.0D) / 1000000.0D; bb.c = Math.round(bb.c * 1000000.0D) / 1000000.0D; bb.d = Math.round(bb.d * 1000000.0D) / 1000000.0D; bb.e = Math.round(bb.e * 1000000.0D) / 1000000.0D; bb.f = Math.round(bb.f * 1000000.0D) / 1000000.0D; return bb; } public void a(double d0, double d1, double d2, float f, float f1) { CraftPlayer craftPlayer = getPlayer(); Location from = craftPlayer.getLocation(); Location to = new Location(getPlayer().getWorld(), d0, d1, d2, f, f1); PlayerTeleportEvent event = new PlayerTeleportEvent(craftPlayer, from, to, PlayerTeleportEvent.TeleportCause.UNKNOWN); this.server.getPluginManager().callEvent(event); from = event.getFrom(); to = event.isCancelled() ? from : event.getTo(); teleport(to); } public void teleport(Location dest) { double d0 = dest.getX(); double d1 = dest.getY(); double d2 = dest.getZ(); float f = dest.getYaw(); float f1 = dest.getPitch(); if (Float.isNaN(f)) f = 0.0F;  if (Float.isNaN(f1)) f1 = 0.0F;  this.lastPosX = d0; this.lastPosY = d1; this.lastPosZ = d2; this.lastYaw = f; this.lastPitch = f1; this.justTeleported = true; this.checkMovement = false; this.y = d0; this.z = d1; this.q = d2; this.player.setLocation(d0, d1, d2, f, f1); if (this.player.frozen) { this.player.playerConnection.sendPacket(new PacketPlayOutEntityTeleport(this.player.freezeEntityId, MathHelper.floor(d0 * 32.0D), MathHelper.floor(d1 * 32.0D), MathHelper.floor(d2 * 32.0D), false, false, true, null)); this.checkMovement = true; } else { this.player.playerConnection.sendPacket(new PacketPlayOutPosition(d0, d1 + 1.6200000047683716D, d2, f, f1, false)); }  this.lastGroundYValue = -1.0D; if (this.player.bossBarMessage != null) { String message = this.player.bossBarMessage; this.player.removeBossBar(); this.player.setBossBar(message, this.player.bossBarHealth); }  } public void a(PacketPlayInBlockDig packetplayinblockdig) { if (!this.player.isAlive()) return;  WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); if (this.hackDebug) Bukkit.getLogger().info(getPlayer().getName() + " sent dig value " + packetplayinblockdig.g());  if (getPlayer().getGameMode() == GameMode.SURVIVAL) if (packetplayinblockdig.g() == 0) { this.isDigging = true; this.typeRThreshold = 0; this.digHorizontalMovement = 0; } else if (packetplayinblockdig.g() == 1 || packetplayinblockdig.g() == 2) { this.isDigging = false; }   this.player.v(); if (packetplayinblockdig.g() == 4) { if (this.lastDropTick != MinecraftServer.currentTick) { this.dropCount = 0; this.lastDropTick = MinecraftServer.currentTick; } else { this.dropCount++; if (this.dropCount >= 20) { Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.INVENTORY, GCheatEvent.Level.ADMIN, this.player.getName() + " dropped their items too quickly!")); c.warn(this.player.getName() + " dropped their items too quickly!"); disconnect("You dropped your items too quickly (Hacking?)"); return; }  }  this.player.a(false); } else if (packetplayinblockdig.g() == 3) { this.player.a(true); } else if (packetplayinblockdig.g() == 5) { this.player.bA(); } else { boolean flag = false; if (packetplayinblockdig.g() == 0) flag = true;  if (packetplayinblockdig.g() == 1) flag = true;  if (packetplayinblockdig.g() == 2) flag = true;  int i = packetplayinblockdig.c(); int j = packetplayinblockdig.d(); int k = packetplayinblockdig.e(); if (flag) { double d0 = this.player.locX - i + 0.5D; double d1 = this.player.locY - j + 0.5D + 1.5D; double d2 = this.player.locZ - k + 0.5D; double d3 = d0 * d0 + d1 * d1 + d2 * d2; if (d3 > 36.0D) return;  if (j >= this.minecraftServer.getMaxBuildHeight()) return;  }  if (packetplayinblockdig.g() == 0) { if (!this.minecraftServer.a(worldserver, i, j, k, this.player)) { this.player.playerInteractManager.dig(i, j, k, packetplayinblockdig.f()); } else { CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, i, j, k, packetplayinblockdig.f(), this.player.inventory.getItemInHand()); this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); TileEntity tileentity = worldserver.getTileEntity(i, j, k); if (tileentity != null) this.player.playerConnection.sendPacket(tileentity.getUpdatePacket());  }  } else if (packetplayinblockdig.g() == 2) { this.player.playerInteractManager.a(i, j, k); if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver));  } else if (packetplayinblockdig.g() == 1) { this.player.playerInteractManager.c(i, j, k); if (worldserver.getType(i, j, k).getMaterial() != Material.AIR) this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver));  }  }  } public void a(PacketPlayInBlockPlace packetplayinblockplace) { if (packetplayinblockplace.hand == 1) return;  boolean throttled = false; if (this.lastPlace != -1L && packetplayinblockplace.timestamp - this.lastPlace < 30L && this.packets++ >= 4) { throttled = true; } else if (packetplayinblockplace.timestamp - this.lastPlace >= 30L || this.lastPlace == -1L) { this.lastPlace = packetplayinblockplace.timestamp; this.packets = 0; }  WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension); if (!this.player.isAlive()) return;  if (packetplayinblockplace.getFace() == 255) { if (packetplayinblockplace.getItemStack() != null && packetplayinblockplace.getItemStack().getItem() == this.lastMaterial && this.lastPacket != null && packetplayinblockplace.timestamp - this.lastPacket.longValue() < 100L) { this.lastPacket = null; return; }  if (this.networkManager.getVersion() >= 107 && this.lastPacket != null && packetplayinblockplace.timestamp - this.lastPacket.longValue() < 100L) { this.lastPacket = null; return; }  } else { this.lastMaterial = (packetplayinblockplace.getItemStack() == null) ? null : packetplayinblockplace.getItemStack().getItem(); this.lastPacket = Long.valueOf(packetplayinblockplace.timestamp); }  boolean always = false; ItemStack itemstack = this.player.inventory.getItemInHand(); boolean flag = false; int i = packetplayinblockplace.c(); int j = packetplayinblockplace.d(); int k = packetplayinblockplace.e(); int l = packetplayinblockplace.getFace(); this.player.v(); if (packetplayinblockplace.getFace() == 255) { if (itemstack == null) return;  int itemstackAmount = itemstack.count; if (!throttled) { PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(this.player, Action.RIGHT_CLICK_AIR, itemstack); if (event.useItemInHand() != Event.Result.DENY) this.player.playerInteractManager.useItem(this.player, this.player.world, itemstack);  }  always = (itemstack.count != itemstackAmount || itemstack.getItem() == Item.getItemOf(Blocks.WATER_LILY)); } else if (packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight() - 1 && (packetplayinblockplace.getFace() == 1 || packetplayinblockplace.d() >= this.minecraftServer.getMaxBuildHeight())) { ChatMessage chatmessage = new ChatMessage("build.tooHigh", new Object[] { Integer.valueOf(this.minecraftServer.getMaxBuildHeight()) }); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutChat(chatmessage)); flag = true; } else { Location eyeLoc = getPlayer().getEyeLocation(); double reachDistance = NumberConversions.square(eyeLoc.getX() - i) + NumberConversions.square(eyeLoc.getY() - j) + NumberConversions.square(eyeLoc.getZ() - k); if (reachDistance > ((getPlayer().getGameMode() == GameMode.CREATIVE) ? 49 : 36)) return;  if (throttled || !this.player.playerInteractManager.interact(this.player, worldserver, itemstack, i, j, k, l, packetplayinblockplace.h(), packetplayinblockplace.i(), packetplayinblockplace.j())) always = true;  flag = true; }  if (flag) { this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); if (l == 0) j--;  if (l == 1) j++;  if (l == 2) k--;  if (l == 3) k++;  if (l == 4) i--;  if (l == 5) i++;  this.player.playerConnection.sendPacket(new PacketPlayOutBlockChange(i, j, k, worldserver)); }  itemstack = this.player.inventory.getItemInHand(); if (itemstack != null && itemstack.count <= 0) { this.player.inventory.items[this.player.inventory.itemInHandIndex] = null; itemstack = null; }  if (itemstack == null || itemstack.n() == 0) { this.player.g = true; this.player.inventory.items[this.player.inventory.itemInHandIndex] = ItemStack.b(this.player.inventory.items[this.player.inventory.itemInHandIndex]); Slot slot = this.player.activeContainer.getSlot(this.player.inventory, this.player.inventory.itemInHandIndex); this.player.activeContainer.b(); this.player.g = false; if (!ItemStack.matches(this.player.inventory.getItemInHand(), packetplayinblockplace.getItemStack()) || always) sendPacketProtocolHack(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, slot.rawSlotIndex, this.player.inventory.getItemInHand()));  }  } public void a(IChatBaseComponent ichatbasecomponent) { if (this.processedDisconnect) return;  this.processedDisconnect = true; c.info(this.player.getName() + " lost connection: " + ichatbasecomponent.c()); this.minecraftServer.az(); this.player.n(); String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); if (quitMessage != null && quitMessage.length() > 0) this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));  if (this.minecraftServer.N() && this.player.getName().equals(this.minecraftServer.M())) { c.info("Stopping singleplayer server as player logged out"); this.minecraftServer.safeShutdown(); }  } public void sendPacketProtocolHack(Packet packet) { if (this.networkManager.getVersion() >= 17) { if (packet instanceof PacketPlayOutWindowItems) { PacketPlayOutWindowItems items = (PacketPlayOutWindowItems)packet; if (this.player.activeContainer instanceof ContainerEnchantTable && this.player.activeContainer.windowId == items.a) { ItemStack[] old = items.b; items.b = new ItemStack[old.length + 1]; items.b[0] = old[0]; System.arraycopy(old, 1, items.b, 2, old.length - 1); items.b[1] = new ItemStack(Items.INK_SACK, 3, 4); }  } else if (packet instanceof PacketPlayOutSetSlot) { PacketPlayOutSetSlot items = (PacketPlayOutSetSlot)packet; if (this.player.activeContainer instanceof ContainerEnchantTable && this.player.activeContainer.windowId == items.a) if (items.b >= 1) items.b++;   }  if (this.networkManager.getVersion() >= 107) if (packet instanceof PacketPlayOutWindowItems) { PacketPlayOutWindowItems items = (PacketPlayOutWindowItems)packet; if (this.player.activeContainer instanceof ContainerBrewingStand && this.player.activeContainer.windowId == items.a) { ItemStack[] old = items.b; items.b = new ItemStack[old.length + 1]; System.arraycopy(old, 0, items.b, 0, 4); System.arraycopy(old, 4, items.b, 5, old.length - 4); items.b[4] = new ItemStack(Items.BLAZE_POWDER); }  } else if (packet instanceof PacketPlayOutSetSlot) { PacketPlayOutSetSlot items = (PacketPlayOutSetSlot)packet; if (this.player.activeContainer instanceof ContainerBrewingStand && this.player.activeContainer.windowId == items.a && items.b >= 4) items.b++;  }   }  if (packet instanceof PacketPlayOutChat) { PacketPlayOutChat packetplayoutchat = (PacketPlayOutChat)packet; EnumChatVisibility enumchatvisibility = this.player.getChatFlags(); if (enumchatvisibility == EnumChatVisibility.HIDDEN) return;  if (enumchatvisibility == EnumChatVisibility.SYSTEM && !packetplayoutchat.d()) return;  }  if (packet == null) return;  if (packet instanceof PacketPlayOutSpawnPosition) { PacketPlayOutSpawnPosition packet6 = (PacketPlayOutSpawnPosition)packet; this.player.compassTarget = new Location(getPlayer().getWorld(), packet6.x, packet6.y, packet6.z); }  try { this.networkManager.handle(packet, new GenericFutureListener[0]); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); crashreportsystemdetails.a("Packet class", new CrashReportConnectionPacketClass(this, packet)); throw new ReportedException(crashreport); }  } public void sendPacket(Packet packet) { if (packet == null) return;  if (packet instanceof PacketPlayOutEntityVelocity && ((PacketPlayOutEntityVelocity)packet).a == this.player.getId()) { this.velocitiesSent.add((PacketPlayOutEntityVelocity)packet); this.velocitySentTimes.add(Long.valueOf(System.currentTimeMillis())); }  if (packet instanceof PacketPlayOutPosition) this.positionSentTime = System.currentTimeMillis();  try { this.networkManager.handle(packet, new GenericFutureListener[0]); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Sending packet"); CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Packet being sent"); crashreportsystemdetails.a("Packet class", new CrashReportConnectionPacketClass(this, packet)); throw new ReportedException(crashreport); }  } public void a(PacketPlayInHeldItemSlot packetplayinhelditemslot) { if (!this.player.isAlive()) return;  if (packetplayinhelditemslot.c() >= 0 && packetplayinhelditemslot.c() < PlayerInventory.getHotbarSize()) { PlayerItemHeldEvent event = new PlayerItemHeldEvent(getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.c()); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { sendPacket(new PacketPlayOutHeldItemSlot(this.player.inventory.itemInHandIndex)); this.player.v(); return; }  this.player.inventory.itemInHandIndex = packetplayinhelditemslot.c(); this.player.v(); } else { Bukkit.getPluginManager().callEvent(new GCheatEvent(this.player.getBukkitEntity(), GCheatEvent.Type.INVENTORY, GCheatEvent.Level.ADMIN, this.player.getName() + " invalid hotbar selection.")); c.warn(this.player.getName() + " tried to set an invalid carried item"); disconnect("Invalid hotbar selection (Hacking?)"); }  } public void a(PacketPlayInChat packetplayinchat) { if (!this.player.isAlive() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) { ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); sendPacketProtocolHack(new PacketPlayOutChat(chatmessage)); } else { this.player.v(); String s = packetplayinchat.c(); s = StringUtils.normalizeSpace(s); for (int i = 0; i < s.length(); i++) { if (!SharedConstants.isAllowedChatCharacter(s.charAt(i))) { if (packetplayinchat.a()) { Waitable waitable = new Waitable() { protected Object evaluate() { PlayerConnection.this.disconnect("Illegal characters in chat"); return null; } }
  2501.               ; this.minecraftServer.processQueue.add(waitable); try { waitable.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new RuntimeException(e); }  } else { disconnect("Illegal characters in chat"); }  return; }  }  if (!packetplayinchat.a()) { try { this.minecraftServer.server.playerCommandState = true; handleCommand(s); } finally { this.minecraftServer.server.playerCommandState = false; }  } else if (s.isEmpty()) { c.warn(this.player.getName() + " tried to send an empty message"); } else if (getPlayer().isConversing()) { final String message = s; this.minecraftServer.processQueue.add(new Waitable() { protected Object evaluate() { PlayerConnection.this.getPlayer().acceptConversationInput(message); return null; } }
  2502.           ); } else if (this.player.getChatFlags() == EnumChatVisibility.SYSTEM) { ChatMessage chatmessage = new ChatMessage("chat.cannotSend", new Object[0]); chatmessage.getChatModifier().setColor(EnumChatFormat.RED); sendPacketProtocolHack(new PacketPlayOutChat(chatmessage)); } else { chat(s, true); }  boolean counted = true; for (String exclude : SpigotConfig.spamExclusions) { if (exclude != null && s.startsWith(exclude)) { counted = false; break; }  }  if (counted && chatSpamField.addAndGet(this, 20) > 200 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) if (packetplayinchat.a()) { Waitable waitable = new Waitable() { protected Object evaluate() { PlayerConnection.this.disconnect("disconnect.spam"); return null; } }
  2503.             ; this.minecraftServer.processQueue.add(waitable); try { waitable.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new RuntimeException(e); }  } else { disconnect("disconnect.spam"); }   }  } public void chat(String s, boolean async) { if (s.isEmpty() || this.player.getChatFlags() == EnumChatVisibility.HIDDEN) return;  if (!async && s.startsWith("/")) { handleCommand(s); } else if (this.player.getChatFlags() != EnumChatVisibility.SYSTEM) { CraftPlayer craftPlayer = getPlayer(); AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, craftPlayer, s, new LazyPlayerSet()); this.server.getPluginManager().callEvent(event); if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { final PlayerChatEvent queueEvent = new PlayerChatEvent(craftPlayer, event.getMessage(), event.getFormat(), event.getRecipients()); queueEvent.setCancelled(event.isCancelled()); Waitable waitable = new Waitable() {
  2504.             protected Object evaluate() { Bukkit.getPluginManager().callEvent(queueEvent); if (queueEvent.isCancelled()) return null;  String message = String.format(queueEvent.getFormat(), new Object[] { queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage() }); this.this$0.minecraftServer.console.sendMessage(message); if (((LazyPlayerSet)queueEvent.getRecipients()).isLazy()) { for (Object player : (this.this$0.minecraftServer.getPlayerList()).players) ((EntityPlayer)player).sendMessage(CraftChatMessage.fromString(message));  } else { for (Player player : queueEvent.getRecipients()) player.sendMessage(message);  }  return null; }
  2505.           }; if (async) { this.minecraftServer.processQueue.add(waitable); } else { waitable.run(); }  try { waitable.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw new RuntimeException("Exception processing chat event", e.getCause()); }  } else { if (event.isCancelled()) return;  s = String.format(event.getFormat(), new Object[] { event.getPlayer().getDisplayName(), event.getMessage() }); this.minecraftServer.console.sendMessage(s); if (((LazyPlayerSet)event.getRecipients()).isLazy()) { for (Object recipient : (this.minecraftServer.getPlayerList()).players) ((EntityPlayer)recipient).sendMessage(CraftChatMessage.fromString(s));  } else { for (Player recipient : event.getRecipients()) recipient.sendMessage(s);  }  }  }  } private void handleCommand(String s) { SpigotTimings.playerCommandTimer.startTiming(); if (SpigotConfig.logCommands) { this; c.info(this.player.getName() + " issued server command: " + s); }  CraftPlayer player = getPlayer(); PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet()); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) { SpigotTimings.playerCommandTimer.stopTiming(); return; }  try { if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) { SpigotTimings.playerCommandTimer.stopTiming(); return; }  } catch (CommandException ex) { player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command"); Logger.getLogger(PlayerConnection.class.getName()).log(Level.SEVERE, null, ex); SpigotTimings.playerCommandTimer.stopTiming(); return; }  SpigotTimings.playerCommandTimer.stopTiming(); } public void a(PacketPlayInArmAnimation packetplayinarmanimation) { if (!this.player.isAlive()) return;  this.player.v(); if (packetplayinarmanimation.d() == 1) { float f = 1.0F; float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f; float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f; double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * f; double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * f + 1.62D - this.player.height; double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * f; Vec3D vec3d = Vec3D.a(d0, d1, d2); float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F); float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F); float f5 = -MathHelper.cos(-f1 * 0.017453292F); float f6 = MathHelper.sin(-f1 * 0.017453292F); float f7 = f4 * f5; float f8 = f3 * f5; double d3 = (this.player.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE) ? 5.0D : 4.5D; Vec3D vec3d1 = vec3d.add(f7 * d3, f6 * d3, f8 * d3); MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false); if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());  PlayerAnimationEvent event = new PlayerAnimationEvent(getPlayer()); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) return;  this.player.ba(); }  } public void a(PacketPlayInEntityAction packetplayinentityaction) { if (!this.player.isAlive()) return;  this.player.v(); if (packetplayinentityaction.d() == 1 || packetplayinentityaction.d() == 2) { PlayerToggleSneakEvent event = new PlayerToggleSneakEvent(getPlayer(), (packetplayinentityaction.d() == 1) ? 1 : 0); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) return;  }  if (packetplayinentityaction.d() == 4 || packetplayinentityaction.d() == 5) { PlayerToggleSprintEvent event = new PlayerToggleSprintEvent(getPlayer(), (packetplayinentityaction.d() == 4) ? 1 : 0); this.server.getPluginManager().callEvent(event); if (event.isCancelled()) return;  }  if (packetplayinentityaction.d() == 1) { this.player.setSneaking(true); } else if (packetplayinentityaction.d() == 2) { this.player.setSneaking(false); } else if (packetplayinentityaction.d() == 4) { this.player.setSprinting(true); if (this.player.isBlocking()) this.player.bA();  } else if (packetplayinentityaction.d() == 5) { this.player.setSprinting(false); } else if (packetplayinentityaction.d() == 3) { this.player.a(false, true, true); } else if (packetplayinentityaction.d() == 6) { if (this.player.vehicle != null && this.player.vehicle instanceof EntityHorse) ((EntityHorse)this.player.vehicle).w(packetplayinentityaction.e());  } else if (packetplayinentityaction.d() == 7 && this.player.vehicle != null && this.player.vehicle instanceof EntityHorse) { ((EntityHorse)this.player.vehicle).g(this.player); }  } public void a(PacketPlayInCloseWindow packetplayinclosewindow) { if (!this.player.isAlive())
  2506.       return;
  2507.     CraftEventFactory.handleInventoryCloseEvent(this.player);
  2508.    
  2509.     this.player.m(); }
  2510.  
  2511.  
  2512.   public void a(PacketPlayInWindowClick packetplayinwindowclick) {
  2513.     if (!this.player.isAlive())
  2514.       return;
  2515.     this.player.v();
  2516.     if (!this.player.activeContainer.a(this.player))
  2517.       return;  if (this.player.activeContainer.windowId == packetplayinwindowclick.c() && this.player.activeContainer.c(this.player)) {
  2518.      
  2519.       if (packetplayinwindowclick.d() < -1 && packetplayinwindowclick.d() != -999) {
  2520.         return;
  2521.       }
  2522.      
  2523.       InventoryView inventory = this.player.activeContainer.getBukkitView();
  2524.      
  2525.       if (this.networkManager.getVersion() >= 17)
  2526.       {
  2527.         if (this.player.activeContainer instanceof ContainerEnchantTable) {
  2528.          
  2529.           if (packetplayinwindowclick.slot == 1) {
  2530.            
  2531.             this.player.updateInventory(this.player.activeContainer); return;
  2532.           }
  2533.           if (packetplayinwindowclick.slot > 1)
  2534.           {
  2535.             packetplayinwindowclick.slot--;
  2536.           }
  2537.         }
  2538.       }
  2539.  
  2540.  
  2541.      
  2542.       if (this.networkManager.getVersion() >= 107) {
  2543.        
  2544.         if (this.player.activeContainer instanceof ContainerBrewingStand) {
  2545.           if (packetplayinwindowclick.slot == 4) {
  2546.             this.player.updateInventory(this.player.activeContainer);
  2547.             return;
  2548.           }
  2549.           if (packetplayinwindowclick.slot > 4) {
  2550.             packetplayinwindowclick.slot--;
  2551.           }
  2552.         }
  2553.        
  2554.         if (packetplayinwindowclick.c() == 0 && packetplayinwindowclick.slot == 45) {
  2555.           this.player.updateInventory(this.player.activeContainer);
  2556.          
  2557.           return;
  2558.         }
  2559.       }
  2560.      
  2561.       InventoryType.SlotType type = CraftInventoryView.getSlotType(inventory, packetplayinwindowclick.d());
  2562.      
  2563.       InventoryClickEvent event = null;
  2564.       ClickType click = ClickType.UNKNOWN;
  2565.       InventoryAction action = InventoryAction.UNKNOWN;
  2566.      
  2567.       ItemStack itemstack = null;
  2568.      
  2569.       if (packetplayinwindowclick.d() == -1) {
  2570.         type = InventoryType.SlotType.OUTSIDE;
  2571.         click = (packetplayinwindowclick.e() == 0) ? ClickType.WINDOW_BORDER_LEFT : ClickType.WINDOW_BORDER_RIGHT;
  2572.         action = InventoryAction.NOTHING;
  2573.       } else if (packetplayinwindowclick.h() == 0) {
  2574.         if (packetplayinwindowclick.e() == 0) {
  2575.           click = ClickType.LEFT;
  2576.         } else if (packetplayinwindowclick.e() == 1) {
  2577.           click = ClickType.RIGHT;
  2578.         }
  2579.         if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) {
  2580.           action = InventoryAction.NOTHING;
  2581.           if (packetplayinwindowclick.d() == -999) {
  2582.             if (this.player.inventory.getCarried() != null) {
  2583.               action = (packetplayinwindowclick.e() == 0) ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR;
  2584.             }
  2585.           } else {
  2586.             Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2587.             if (slot != null) {
  2588.               ItemStack clickedItem = slot.getItem();
  2589.               ItemStack cursor = this.player.inventory.getCarried();
  2590.               if (clickedItem == null) {
  2591.                 if (cursor != null) {
  2592.                   action = (packetplayinwindowclick.e() == 0) ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE;
  2593.                 }
  2594.               } else if (slot.isAllowed(this.player)) {
  2595.                 if (cursor == null) {
  2596.                   action = (packetplayinwindowclick.e() == 0) ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF;
  2597.                 } else if (slot.isAllowed(cursor)) {
  2598.                   if (clickedItem.doMaterialsMatch(cursor) && ItemStack.equals(clickedItem, cursor)) {
  2599.                     int toPlace = (packetplayinwindowclick.e() == 0) ? cursor.count : 1;
  2600.                     toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.count);
  2601.                     toPlace = Math.min(toPlace, slot.inventory.getMaxStackSize() - clickedItem.count);
  2602.                     if (toPlace == 1) {
  2603.                       action = InventoryAction.PLACE_ONE;
  2604.                     } else if (toPlace == cursor.count) {
  2605.                       action = InventoryAction.PLACE_ALL;
  2606.                     } else if (toPlace < 0) {
  2607.                       action = (toPlace != -1) ? InventoryAction.PICKUP_SOME : InventoryAction.PICKUP_ONE;
  2608.                     } else if (toPlace != 0) {
  2609.                       action = InventoryAction.PLACE_SOME;
  2610.                     }
  2611.                   } else if (cursor.count <= slot.getMaxStackSize()) {
  2612.                     action = InventoryAction.SWAP_WITH_CURSOR;
  2613.                   }
  2614.                 } else if (cursor.getItem() == clickedItem.getItem() && (!cursor.usesData() || cursor.getData() == clickedItem.getData()) && ItemStack.equals(cursor, clickedItem) &&
  2615.                   clickedItem.count >= 0 &&
  2616.                   clickedItem.count + cursor.count <= cursor.getMaxStackSize()) {
  2617.                  
  2618.                   action = InventoryAction.PICKUP_ALL;
  2619.                 }
  2620.              
  2621.               }
  2622.            
  2623.             }
  2624.           }
  2625.         }
  2626.       } else if (packetplayinwindowclick.h() == 1) {
  2627.         if (packetplayinwindowclick.e() == 0) {
  2628.           click = ClickType.SHIFT_LEFT;
  2629.         } else if (packetplayinwindowclick.e() == 1) {
  2630.           click = ClickType.SHIFT_RIGHT;
  2631.         }
  2632.         if (packetplayinwindowclick.e() == 0 || packetplayinwindowclick.e() == 1) {
  2633.           if (packetplayinwindowclick.d() < 0) {
  2634.             action = InventoryAction.NOTHING;
  2635.           } else {
  2636.             Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2637.             if (slot != null && slot.isAllowed(this.player) && slot.hasItem()) {
  2638.               action = InventoryAction.MOVE_TO_OTHER_INVENTORY;
  2639.             } else {
  2640.               action = InventoryAction.NOTHING;
  2641.             }
  2642.           }
  2643.         }
  2644.       } else if (packetplayinwindowclick.h() == 2) {
  2645.         if (packetplayinwindowclick.e() >= 0 && packetplayinwindowclick.e() < 9) {
  2646.           click = ClickType.NUMBER_KEY;
  2647.           Slot clickedSlot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2648.           if (clickedSlot.isAllowed(this.player)) {
  2649.             ItemStack hotbar = this.player.inventory.getItem(packetplayinwindowclick.e());
  2650.             boolean canCleanSwap = (hotbar == null || (clickedSlot.inventory == this.player.inventory && clickedSlot.isAllowed(hotbar)));
  2651.             if (clickedSlot.hasItem()) {
  2652.               if (canCleanSwap) {
  2653.                 action = InventoryAction.HOTBAR_SWAP;
  2654.               } else {
  2655.                 int firstEmptySlot = this.player.inventory.getFirstEmptySlotIndex();
  2656.                 if (firstEmptySlot > -1) {
  2657.                   action = InventoryAction.HOTBAR_MOVE_AND_READD;
  2658.                 } else {
  2659.                   action = InventoryAction.NOTHING;
  2660.                 }
  2661.               }
  2662.             } else if (!clickedSlot.hasItem() && hotbar != null && clickedSlot.isAllowed(hotbar)) {
  2663.               action = InventoryAction.HOTBAR_SWAP;
  2664.             } else {
  2665.               action = InventoryAction.NOTHING;
  2666.             }
  2667.           } else {
  2668.             action = InventoryAction.NOTHING;
  2669.           }
  2670.          
  2671.           event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e());
  2672.         }
  2673.       } else if (packetplayinwindowclick.h() == 3) {
  2674.         if (packetplayinwindowclick.e() == 2) {
  2675.           click = ClickType.MIDDLE;
  2676.           if (packetplayinwindowclick.d() == -999) {
  2677.             action = InventoryAction.NOTHING;
  2678.           } else {
  2679.             Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2680.             if (slot != null && slot.hasItem() && this.player.abilities.canInstantlyBuild && this.player.inventory.getCarried() == null) {
  2681.               action = InventoryAction.CLONE_STACK;
  2682.             } else {
  2683.               action = InventoryAction.NOTHING;
  2684.             }
  2685.           }
  2686.         } else {
  2687.           click = ClickType.UNKNOWN;
  2688.           action = InventoryAction.UNKNOWN;
  2689.         }
  2690.       } else if (packetplayinwindowclick.h() == 4) {
  2691.         if (packetplayinwindowclick.d() >= 0) {
  2692.           if (packetplayinwindowclick.e() == 0) {
  2693.             click = ClickType.DROP;
  2694.             Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2695.             if (slot != null && slot.hasItem() && slot.isAllowed(this.player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
  2696.               action = InventoryAction.DROP_ONE_SLOT;
  2697.             } else {
  2698.               action = InventoryAction.NOTHING;
  2699.             }
  2700.           } else if (packetplayinwindowclick.e() == 1) {
  2701.             click = ClickType.CONTROL_DROP;
  2702.             Slot slot = this.player.activeContainer.getSlot(packetplayinwindowclick.d());
  2703.             if (slot != null && slot.hasItem() && slot.isAllowed(this.player) && slot.getItem() != null && slot.getItem().getItem() != Item.getItemOf(Blocks.AIR)) {
  2704.               action = InventoryAction.DROP_ALL_SLOT;
  2705.             } else {
  2706.               action = InventoryAction.NOTHING;
  2707.             }
  2708.           }
  2709.         } else {
  2710.          
  2711.           click = ClickType.LEFT;
  2712.           if (packetplayinwindowclick.e() == 1) {
  2713.             click = ClickType.RIGHT;
  2714.           }
  2715.           action = InventoryAction.NOTHING;
  2716.         }
  2717.       } else if (packetplayinwindowclick.h() == 5) {
  2718.         itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), packetplayinwindowclick.e(), 5, this.player);
  2719.       } else if (packetplayinwindowclick.h() == 6) {
  2720.         click = ClickType.DOUBLE_CLICK;
  2721.         action = InventoryAction.NOTHING;
  2722.         if (packetplayinwindowclick.d() >= 0 && this.player.inventory.getCarried() != null) {
  2723.           ItemStack cursor = this.player.inventory.getCarried();
  2724.           action = InventoryAction.NOTHING;
  2725.          
  2726.           if (inventory.getTopInventory().contains(Material.getMaterial(Item.getId(cursor.getItem()))) || inventory.getBottomInventory().contains(Material.getMaterial(Item.getId(cursor.getItem())))) {
  2727.             action = InventoryAction.COLLECT_TO_CURSOR;
  2728.           }
  2729.         }
  2730.       }
  2731.  
  2732.      
  2733.       if (packetplayinwindowclick.h() != 5) {
  2734.         CraftItemEvent craftItemEvent; if (click == ClickType.NUMBER_KEY) {
  2735.           event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e());
  2736.         } else {
  2737.           event = new InventoryClickEvent(inventory, type, packetplayinwindowclick.d(), click, action);
  2738.         }
  2739.        
  2740.         Inventory top = inventory.getTopInventory();
  2741.         if (packetplayinwindowclick.d() == 0 && top instanceof CraftingInventory) {
  2742.           Recipe recipe = ((CraftingInventory)top).getRecipe();
  2743.           if (recipe != null) {
  2744.             if (click == ClickType.NUMBER_KEY) {
  2745.               craftItemEvent = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, action, packetplayinwindowclick.e());
  2746.             } else {
  2747.               craftItemEvent = new CraftItemEvent(recipe, inventory, type, packetplayinwindowclick.d(), click, action);
  2748.             }
  2749.           }
  2750.         }
  2751.        
  2752.         this.server.getPluginManager().callEvent(craftItemEvent);
  2753.        
  2754.         switch (craftItemEvent.getResult()) {
  2755.           case ALLOW:
  2756.           case DEFAULT:
  2757.             itemstack = this.player.activeContainer.clickItem(packetplayinwindowclick.d(), packetplayinwindowclick.e(), packetplayinwindowclick.h(), this.player);
  2758.             break;
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.  
  2769.          
  2770.           case DENY:
  2771.             switch (action) {
  2772.              
  2773.               case ALLOW:
  2774.               case DEFAULT:
  2775.               case DENY:
  2776.               case null:
  2777.               case null:
  2778.               case null:
  2779.                 this.player.updateInventory(this.player.activeContainer);
  2780.                 break;
  2781.              
  2782.               case null:
  2783.               case null:
  2784.               case null:
  2785.               case null:
  2786.               case null:
  2787.               case null:
  2788.               case null:
  2789.                 this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried()));
  2790.                 this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.d(), this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem()));
  2791.                 break;
  2792.              
  2793.               case null:
  2794.               case null:
  2795.                 this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, packetplayinwindowclick.d(), this.player.activeContainer.getSlot(packetplayinwindowclick.d()).getItem()));
  2796.                 break;
  2797.              
  2798.               case null:
  2799.               case null:
  2800.               case null:
  2801.                 this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(-1, -1, this.player.inventory.getCarried()));
  2802.                 break;
  2803.             }
  2804.  
  2805.  
  2806.            
  2807.             return;
  2808.         }
  2809.  
  2810.      
  2811.       }
  2812.       if (ItemStack.matches(packetplayinwindowclick.g(), itemstack)) {
  2813.         this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), packetplayinwindowclick.f(), true));
  2814.         this.player.g = true;
  2815.         this.player.activeContainer.b();
  2816.         this.player.broadcastCarriedItem();
  2817.         this.player.g = false;
  2818.       } else {
  2819.         this.n.a(this.player.activeContainer.windowId, Short.valueOf(packetplayinwindowclick.f()));
  2820.         this.player.playerConnection.sendPacket(new PacketPlayOutTransaction(packetplayinwindowclick.c(), packetplayinwindowclick.f(), false));
  2821.         this.player.activeContainer.a(this.player, false);
  2822.         ArrayList arraylist = new ArrayList();
  2823.        
  2824.         for (int i = 0; i < this.player.activeContainer.c.size(); i++) {
  2825.           arraylist.add(((Slot)this.player.activeContainer.c.get(i)).getItem());
  2826.         }
  2827.        
  2828.         this.player.a(this.player.activeContainer, arraylist);
  2829.  
  2830.        
  2831.         if (type == InventoryType.SlotType.RESULT && itemstack != null) {
  2832.           this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(this.player.activeContainer.windowId, false, itemstack));
  2833.         }
  2834.       }
  2835.     }
  2836.   }
  2837.  
  2838.  
  2839.   public void a(PacketPlayInEnchantItem packetplayinenchantitem) {
  2840.     this.player.v();
  2841.     if (this.player.activeContainer.windowId == packetplayinenchantitem.c() && this.player.activeContainer.c(this.player)) {
  2842.       this.player.activeContainer.a(this.player, packetplayinenchantitem.d());
  2843.       this.player.activeContainer.b();
  2844.     }
  2845.   }
  2846.  
  2847.   public void a(PacketPlayInSetCreativeSlot packetplayinsetcreativeslot) {
  2848.     if (this.player.playerInteractManager.isCreative()) {
  2849.       boolean flag = (packetplayinsetcreativeslot.c() < 0);
  2850.       ItemStack itemstack = packetplayinsetcreativeslot.getItemStack();
  2851.       boolean flag1 = (packetplayinsetcreativeslot.c() >= 1 && packetplayinsetcreativeslot.c() < 36 + PlayerInventory.getHotbarSize());
  2852.      
  2853.       boolean flag2 = (itemstack == null || (itemstack.getItem() != null && (!invalidItems.contains(Integer.valueOf(Item.getId(itemstack.getItem()))) || !SpigotConfig.filterCreativeItems)));
  2854.       boolean flag3 = (itemstack == null || (itemstack.getData() >= 0 && itemstack.count <= 64 && itemstack.count > 0));
  2855.  
  2856.      
  2857.       if (flag || (flag1 && !ItemStack.matches(this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem(), packetplayinsetcreativeslot.getItemStack()))) {
  2858.        
  2859.         CraftPlayer craftPlayer = this.player.getBukkitEntity();
  2860.         CraftInventoryView craftInventoryView = new CraftInventoryView(craftPlayer, craftPlayer.getInventory(), this.player.defaultContainer);
  2861.         ItemStack item = CraftItemStack.asBukkitCopy(packetplayinsetcreativeslot.getItemStack());
  2862.        
  2863.         InventoryType.SlotType type = InventoryType.SlotType.QUICKBAR;
  2864.         if (flag) {
  2865.           type = InventoryType.SlotType.OUTSIDE;
  2866.         } else if (packetplayinsetcreativeslot.c() < 36) {
  2867.           if (packetplayinsetcreativeslot.c() >= 5 && packetplayinsetcreativeslot.c() < 9) {
  2868.             type = InventoryType.SlotType.ARMOR;
  2869.           } else {
  2870.             type = InventoryType.SlotType.CONTAINER;
  2871.           }
  2872.         }
  2873.         InventoryCreativeEvent event = new InventoryCreativeEvent(craftInventoryView, type, flag ? -999 : packetplayinsetcreativeslot.c(), item);
  2874.         this.server.getPluginManager().callEvent(event);
  2875.        
  2876.         itemstack = CraftItemStack.asNMSCopy(event.getCursor());
  2877.        
  2878.         switch (event.getResult()) {
  2879.          
  2880.           case ALLOW:
  2881.             flag2 = flag3 = true;
  2882.             break;
  2883.  
  2884.  
  2885.          
  2886.           case DENY:
  2887.             if (packetplayinsetcreativeslot.c() >= 0) {
  2888.               this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(this.player.defaultContainer.windowId, packetplayinsetcreativeslot.c(), this.player.defaultContainer.getSlot(packetplayinsetcreativeslot.c()).getItem()));
  2889.               this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(-1, -1, null));
  2890.             }
  2891.             return;
  2892.         }
  2893.  
  2894.      
  2895.       }
  2896.       if (flag1 && flag2 && flag3) {
  2897.         if (itemstack == null) {
  2898.           this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), (ItemStack)null);
  2899.         } else {
  2900.           this.player.defaultContainer.setItem(packetplayinsetcreativeslot.c(), itemstack);
  2901.         }
  2902.        
  2903.         this.player.defaultContainer.a(this.player, true);
  2904.       } else if (flag && flag2 && flag3 && this.x < 200) {
  2905.         this.x += 20;
  2906.         EntityItem entityitem = this.player.drop(itemstack, true);
  2907.        
  2908.         if (entityitem != null) {
  2909.           entityitem.e();
  2910.        
  2911.         }
  2912.      
  2913.       }
  2914.       else if (flag1) {
  2915.  
  2916.        
  2917.         this.player.playerConnection.sendPacketProtocolHack(new PacketPlayOutSetSlot(false, packetplayinsetcreativeslot
  2918.              
  2919.               .c(), this.player.defaultContainer
  2920.               .getSlot(packetplayinsetcreativeslot.c()).getItem()));
  2921.       }
  2922.     }
  2923.   }
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.   public void a(PacketPlayInTransaction packetplayintransaction) {
  2930.     if (!this.player.isAlive())
  2931.       return;  if (!this.player.activeContainer.a(this.player))
  2932.       return;  Short oshort = (Short)this.n.get(this.player.activeContainer.windowId);
  2933.    
  2934.     if (oshort != null && packetplayintransaction.d() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.c() && !this.player.activeContainer.c(this.player)) {
  2935.       this.player.activeContainer.a(this.player, true);
  2936.     }
  2937.   }
  2938.  
  2939.   public void a(PacketPlayInUpdateSign packetplayinupdatesign) {
  2940.     if (!this.player.isAlive())
  2941.       return;
  2942.     this.player.v();
  2943.     WorldServer worldserver = this.minecraftServer.getWorldServer(this.player.dimension);
  2944.    
  2945.     if (worldserver.isLoaded(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e())) {
  2946.       TileEntity tileentity = worldserver.getTileEntity(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e());
  2947.      
  2948.       if (tileentity instanceof TileEntitySign) {
  2949.         TileEntitySign tileentitysign = (TileEntitySign)tileentity;
  2950.        
  2951.         if (!tileentitysign.a() || tileentitysign.b() != this.player) {
  2952.           this.minecraftServer.warning("Player " + this.player.getName() + " just tried to change non-editable sign");
  2953.           sendPacket(new PacketPlayOutUpdateSign(packetplayinupdatesign.c(), packetplayinupdatesign.d(), packetplayinupdatesign.e(), tileentitysign.lines));
  2954.          
  2955.           return;
  2956.         }
  2957.       }
  2958.      
  2959.       int j;
  2960.      
  2961.       for (j = 0; j < 4; j++) {
  2962.         boolean flag = true;
  2963.         packetplayinupdatesign.f()[j] = packetplayinupdatesign.f()[j].replaceAll("���", "").replaceAll("���", "");
  2964.        
  2965.         if (packetplayinupdatesign.f()[j].length() > 15) {
  2966.           flag = false;
  2967.         } else {
  2968.           for (int i = 0; i < packetplayinupdatesign.f()[j].length(); i++) {
  2969.             if (!SharedConstants.isAllowedChatCharacter(packetplayinupdatesign.f()[j].charAt(i))) {
  2970.               flag = false;
  2971.             }
  2972.           }
  2973.         }
  2974.        
  2975.         if (!flag) {
  2976.           packetplayinupdatesign.f()[j] = "!?";
  2977.         }
  2978.       }
  2979.      
  2980.       if (tileentity instanceof TileEntitySign) {
  2981.         j = packetplayinupdatesign.c();
  2982.         int k = packetplayinupdatesign.d();
  2983.        
  2984.         int i = packetplayinupdatesign.e();
  2985.         TileEntitySign tileentitysign1 = (TileEntitySign)tileentity;
  2986.  
  2987.        
  2988.         Player player = this.server.getPlayer(this.player);
  2989.         SignChangeEvent event = new SignChangeEvent((CraftBlock)player.getWorld().getBlockAt(j, k, i), this.server.getPlayer(this.player), packetplayinupdatesign.f());
  2990.         this.server.getPluginManager().callEvent(event);
  2991.        
  2992.         if (!event.isCancelled()) {
  2993.           tileentitysign1.lines = CraftSign.sanitizeLines(event.getLines());
  2994.           tileentitysign1.isEditable = false;
  2995.         }
  2996.  
  2997.  
  2998.        
  2999.         tileentitysign1.update();
  3000.         worldserver.notify(j, k, i);
  3001.       }
  3002.     }
  3003.   }
  3004.  
  3005.  
  3006.   public void a(PacketPlayInKeepAlive packetplayinkeepalive) {
  3007.     this.lastPacketTypeReceived = 'k';
  3008.    
  3009.     boolean catchingUp = false;
  3010.    
  3011.     if (this.lastKeepAlivePacketReceivedTime == -1L) {
  3012.       this.lastKeepAlivePacketReceivedTime = this.networkManager.currentTime;
  3013.     } else if (this.lastKeepAlivePacketReceivedTime + 2000L < this.networkManager.currentTime) {
  3014.      
  3015.       catchingUp = true;
  3016.       this.lastKeepAlivePacketReceivedTime += 550L;
  3017.     } else {
  3018.       this.lastKeepAlivePacketReceivedTime = this.networkManager.currentTime;
  3019.     }
  3020.  
  3021.    
  3022.     this.packetsNotReceived--;
  3023.  
  3024.    
  3025.     if (this.player.isAlive() && !this.player.sleeping && this.lastKAPacketTick + 20L > MinecraftServer.currentTick && this.lastKAMovementPacket + 100L < MinecraftServer.currentTick &&
  3026.       this.lastNotificationTick + 20L < MinecraftServer.currentTick) {
  3027.       this.lastNotificationTick = MinecraftServer.currentTick;
  3028.     }
  3029.  
  3030.  
  3031.    
  3032.     this.lastKAPacketTick = MinecraftServer.currentTick;
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.    
  3045.     if (packetplayinkeepalive.c() == this.h) {
  3046.       int i = (int)(d() - this.i);
  3047.      
  3048.       this.player.ping = (this.player.ping * 3 + i) / 4;
  3049.     }
  3050.   }
  3051.  
  3052.  
  3053.   private long d() { return System.nanoTime() / 1000000L; }
  3054.  
  3055.  
  3056.  
  3057.   public void a(PacketPlayInAbilities packetplayinabilities) {
  3058.     if (this.player.abilities.canFly && this.player.abilities.isFlying != packetplayinabilities.isFlying()) {
  3059.       PlayerToggleFlightEvent event = new PlayerToggleFlightEvent(this.server.getPlayer(this.player), packetplayinabilities.isFlying());
  3060.       this.server.getPluginManager().callEvent(event);
  3061.       if (!event.isCancelled()) {
  3062.         this.player.abilities.isFlying = packetplayinabilities.isFlying();
  3063.       } else {
  3064.         this.player.updateAbilities();
  3065.       }
  3066.     }
  3067.   }
  3068.  
  3069.  
  3070.  
  3071.   public void a(PacketPlayInTabComplete packetplayintabcomplete) {
  3072.     if (chatSpamField.addAndGet(this, 20) > 400 && !this.minecraftServer.getPlayerList().isOp(this.player.getProfile())) {
  3073.       disconnect("disconnect.spam");
  3074.      
  3075.       return;
  3076.     }
  3077.     ArrayList arraylist = Lists.newArrayList();
  3078.     Iterator iterator = this.minecraftServer.a(this.player, packetplayintabcomplete.c()).iterator();
  3079.    
  3080.     while (iterator.hasNext()) {
  3081.       String s = (String)iterator.next();
  3082.      
  3083.       arraylist.add(s);
  3084.     }
  3085.    
  3086.     this.player.playerConnection.sendPacket(new PacketPlayOutTabComplete((String[])arraylist.toArray(new String[arraylist.size()])));
  3087.   }
  3088.  
  3089.  
  3090.   public void a(PacketPlayInSettings packetplayinsettings) { this.player.a(packetplayinsettings); }
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.   public void a(PacketPlayInCustomPayload packetplayincustompayload) {
  3099.     if (packetplayincustompayload.length <= 0) {
  3100.       return;
  3101.     }
  3102.  
  3103.    
  3104.     if ("MC|BEdit".equals(packetplayincustompayload.c())) {
  3105.       packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e()), this.networkManager.getVersion());
  3106.      
  3107.       try {
  3108.         ItemStack itemstack = packetdataserializer.c();
  3109.         if (itemstack != null) {
  3110.           if (!ItemBookAndQuill.a(itemstack.getTag())) {
  3111.             throw new IOException("Invalid book tag!");
  3112.           }
  3113.          
  3114.           ItemStack itemstack1 = this.player.inventory.getItemInHand();
  3115.           if (itemstack1 == null) {
  3116.             return;
  3117.           }
  3118.          
  3119.           if (itemstack.getItem() == Items.BOOK_AND_QUILL && itemstack.getItem() == itemstack1.getItem()) {
  3120.             CraftEventFactory.handleEditBookEvent(this.player, itemstack);
  3121.           }
  3122.  
  3123.          
  3124.           return;
  3125.         }
  3126.       } catch (Exception exception) {
  3127.         c.error("Couldn't handle book info", exception);
  3128.         disconnect("Invalid book data!");
  3129.        
  3130.         return;
  3131.       } finally {
  3132.         packetdataserializer.release();
  3133.       }
  3134.       return;
  3135.     }
  3136.     if ("MC|BSign".equals(packetplayincustompayload.c())) {
  3137.       packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e()), this.networkManager.getVersion());
  3138.      
  3139.       try {
  3140.         ItemStack itemstack = packetdataserializer.c();
  3141.         if (itemstack != null) {
  3142.           if (!ItemWrittenBook.a(itemstack.getTag())) {
  3143.             throw new IOException("Invalid book tag!");
  3144.           }
  3145.          
  3146.           ItemStack itemstack1 = this.player.inventory.getItemInHand();
  3147.           if (itemstack1 == null) {
  3148.             return;
  3149.           }
  3150.          
  3151.           if (itemstack.getItem() == Items.WRITTEN_BOOK && itemstack1.getItem() == Items.BOOK_AND_QUILL) {
  3152.             CraftEventFactory.handleEditBookEvent(this.player, itemstack);
  3153.           }
  3154.  
  3155.          
  3156.           return;
  3157.         }
  3158.       } catch (Throwable exception1) {
  3159.         c.error("Couldn't sign book", exception1);
  3160.         disconnect("Invalid book data!");
  3161.        
  3162.         return;
  3163.       } finally {
  3164.         packetdataserializer.release();
  3165.       }
  3166.  
  3167.      
  3168.       return;
  3169.     }
  3170.  
  3171.    
  3172.     if ("MC|TrSel".equals(packetplayincustompayload.c())) {
  3173.       try {
  3174.         DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e()));
  3175.         int i = datainputstream.readInt();
  3176.         Container container = this.player.activeContainer;
  3177.        
  3178.         if (container instanceof ContainerMerchant) {
  3179.           ((ContainerMerchant)container).e(i);
  3180.         }
  3181.       }
  3182.       catch (Throwable exception2) {
  3183.         c.error("Couldn't select trade", exception2);
  3184.         disconnect("Invalid trade data!");
  3185.       }
  3186.    
  3187.     } else if ("MC|AdvCdm".equals(packetplayincustompayload.c())) {
  3188.       if (!this.minecraftServer.getEnableCommandBlock()) {
  3189.         this.player.sendMessage(new ChatMessage("advMode.notEnabled", new Object[0]));
  3190.       } else if (this.player.a(2, "") && this.player.abilities.canInstantlyBuild) {
  3191.         packetdataserializer = new PacketDataSerializer(Unpooled.wrappedBuffer(packetplayincustompayload.e()));
  3192.        
  3193.         try {
  3194.           byte b0 = packetdataserializer.readByte();
  3195.           CommandBlockListenerAbstract commandblocklistenerabstract = null;
  3196.          
  3197.           if (b0 == 0) {
  3198.             TileEntity tileentity = this.player.world.getTileEntity(packetdataserializer.readInt(), packetdataserializer.readInt(), packetdataserializer.readInt());
  3199.            
  3200.             if (tileentity instanceof TileEntityCommand) {
  3201.               commandblocklistenerabstract = ((TileEntityCommand)tileentity).getCommandBlock();
  3202.             }
  3203.           } else if (b0 == 1) {
  3204.             Entity entity = this.player.world.getEntity(packetdataserializer.readInt());
  3205.            
  3206.             if (entity instanceof EntityMinecartCommandBlock) {
  3207.               commandblocklistenerabstract = ((EntityMinecartCommandBlock)entity).getCommandBlock();
  3208.             }
  3209.           }
  3210.          
  3211.           String s = packetdataserializer.c(packetdataserializer.readableBytes());
  3212.          
  3213.           if (commandblocklistenerabstract != null) {
  3214.             commandblocklistenerabstract.setCommand(s);
  3215.             commandblocklistenerabstract.e();
  3216.             this.player.sendMessage(new ChatMessage("advMode.setCommand.success", new Object[] { s }));
  3217.           }
  3218.        
  3219.         } catch (Throwable exception3) {
  3220.           c.error("Couldn't set command block", exception3);
  3221.           disconnect("Invalid CommandBlock data!");
  3222.         } finally {
  3223.          
  3224.           packetdataserializer.release();
  3225.         }
  3226.       } else {
  3227.         this.player.sendMessage(new ChatMessage("advMode.notAllowed", new Object[0]));
  3228.       }
  3229.     } else if ("MC|Beacon".equals(packetplayincustompayload.c())) {
  3230.       if (this.player.activeContainer instanceof ContainerBeacon) {
  3231.         try {
  3232.           DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(packetplayincustompayload.e()));
  3233.           int i = datainputstream.readInt();
  3234.           int j = datainputstream.readInt();
  3235.           ContainerBeacon containerbeacon = (ContainerBeacon)this.player.activeContainer;
  3236.           Slot slot = containerbeacon.getSlot(0);
  3237.          
  3238.           if (slot.hasItem()) {
  3239.             slot.a(1);
  3240.             TileEntityBeacon tileentitybeacon = containerbeacon.e();
  3241.            
  3242.             tileentitybeacon.d(i);
  3243.             tileentitybeacon.e(j);
  3244.             tileentitybeacon.update();
  3245.           }
  3246.        
  3247.         } catch (Throwable exception4) {
  3248.           c.error("Couldn't set beacon", exception4);
  3249.           disconnect("Invalid beacon data!");
  3250.         }
  3251.      
  3252.       }
  3253.     } else if ("MC|ItemName".equals(packetplayincustompayload.c()) && this.player.activeContainer instanceof ContainerAnvil) {
  3254.       ContainerAnvil containeranvil = (ContainerAnvil)this.player.activeContainer;
  3255.      
  3256.       if (packetplayincustompayload.e() != null && packetplayincustompayload.e().length >= 1) {
  3257.         String s1 = SharedConstants.a(new String(packetplayincustompayload.e(), Charsets.UTF_8));
  3258.        
  3259.         if (s1.length() <= 30) {
  3260.           containeranvil.a(s1);
  3261.         }
  3262.       } else {
  3263.         containeranvil.a("");
  3264.       }
  3265.    
  3266.     }
  3267.     else if (packetplayincustompayload.c().equals("REGISTER")) {
  3268.       try {
  3269.         String channels = new String(packetplayincustompayload.e(), "UTF8");
  3270.         for (String channel : channels.split("\000")) {
  3271.           getPlayer().addChannel(channel);
  3272.         }
  3273.       } catch (UnsupportedEncodingException ex) {
  3274.         throw new AssertionError(ex);
  3275.       }
  3276.     } else if (packetplayincustompayload.c().equals("UNREGISTER")) {
  3277.       try {
  3278.         String channels = new String(packetplayincustompayload.e(), "UTF8");
  3279.         for (String channel : channels.split("\000")) {
  3280.           getPlayer().removeChannel(channel);
  3281.         }
  3282.       } catch (UnsupportedEncodingException ex) {
  3283.         throw new AssertionError(ex);
  3284.       }
  3285.     } else {
  3286.       this.server.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packetplayincustompayload.c(), packetplayincustompayload.e());
  3287.     }
  3288.   }
  3289.  
  3290.  
  3291.  
  3292.   public void a(EnumProtocol enumprotocol, EnumProtocol enumprotocol1) {
  3293.     if (enumprotocol1 != EnumProtocol.PLAY) {
  3294.       throw new IllegalStateException("Unexpected change in protocol!");
  3295.     }
  3296.   }
  3297.  
  3298.  
  3299.  
  3300.   public boolean isDisconnected() { return (!this.player.joining && !NetworkManager.a(this.networkManager).config().isAutoRead()); }
  3301.  
  3302.  
  3303.  
  3304.  
  3305.   public void handleKeepAliveSync(PacketPlayInKeepAlive packet) {
  3306.     this.keepAlives.remove(Integer.valueOf(packet.c()));
  3307.  
  3308.  
  3309.    
  3310.     long latency = (1000 + this.keepAlives.size() * 1000);
  3311.     this.playerTime = this.networkManager.currentTime - latency;
  3312.    
  3313.     Iterator it = this.velocitySentTimes.iterator();
  3314.     int i = 0;
  3315.     while (it.hasNext()) {
  3316.       long ts = ((Long)it.next()).longValue();
  3317.       if (this.hackDebug) {
  3318.         Bukkit.getLogger().info("KA velocity - ts " + ts);
  3319.         Bukkit.getLogger().info("KA velocity - latency " + latency);
  3320.       }
  3321.  
  3322.      
  3323.       if (this.networkManager.currentTime - ts > latency) {
  3324.         it.remove();
  3325.         this.velocitiesSent.remove(i);
  3326.         continue;
  3327.       }
  3328.       i++;
  3329.     }
  3330.    
  3331.     if (this.newHorizontalSpeed != 0.0D &&
  3332.       this.networkManager.currentTime - this.newHorizontalSpeedTime > latency) {
  3333.       this.horizontalSpeed = this.newHorizontalSpeed;
  3334.       this.newHorizontalSpeed = 0.0D;
  3335.     }
  3336.   }
  3337.  
  3338.  
  3339.  
  3340.  
  3341.  
  3342.   public void updateMovementSpeed() {
  3343.     AttributeModifiable moveSpeed = (AttributeModifiable)this.player.getAttributeMap().a(GenericAttributes.d);
  3344.     double base = moveSpeed.b();
  3345.     double value = base;
  3346.     for (AttributeModifier modifier : moveSpeed.a(0)) {
  3347.       value += modifier.d();
  3348.     }
  3349.     for (AttributeModifier modifier : moveSpeed.a(1)) {
  3350.       value += modifier.d() * base;
  3351.     }
  3352.     for (AttributeModifier modifier : moveSpeed.a(2)) {
  3353.       if (modifier != EntityLiving.c) {
  3354.         value *= (1.0D + modifier.d());
  3355.       }
  3356.     }
  3357.    
  3358.     if (value < this.horizontalSpeed) {
  3359.       this.newHorizontalSpeed = value;
  3360.       this.newHorizontalSpeedTime = System.currentTimeMillis();
  3361.     } else {
  3362.       this.horizontalSpeed = value;
  3363.       this.newHorizontalSpeed = 0.0D;
  3364.     }
  3365.   }
  3366.  
  3367.  
  3368.  
  3369.   public void handleVehicleMove(PacketPlayInVehicleMove packet) {
  3370.     if (!Doubles.isFinite(packet.x) || !Doubles.isFinite(packet.y) || !Doubles.isFinite(packet.z) || !Floats.isFinite(packet.yaw) || !Floats.isFinite(packet.pitch)) {
  3371.       disconnect("Invalid move vehicle packet received");
  3372.       return;
  3373.     }
  3374.     Entity vehicle = this.player.vehicle;
  3375.     if (vehicle == null) {
  3376.       return;
  3377.     }
  3378.     double currentX = vehicle.locX;
  3379.     double currentY = vehicle.locY;
  3380.     double currentZ = vehicle.locZ;
  3381.     double dx = packet.x - currentX;
  3382.     double dy = packet.y - currentY;
  3383.     double dz = packet.z - currentZ;
  3384.     double moveSquared = dx * dx + dy * dy + dz * dz;
  3385.    
  3386.     if (moveSquared > SpigotConfig.movedTooQuicklyThreshold) {
  3387.       c.warn(this.player.getName() + " moves their vehicle (" + vehicle.getClass().getSimpleName() + ") too quickly! " + dx + ", " + dy + ", " + dz);
  3388.       sendPacket(new PacketPlayOutVehicleMove(vehicle));
  3389.      
  3390.       return;
  3391.     }
  3392.     boolean currentlyInBlock = !vehicle.world.getCubes(vehicle, vehicle.boundingBox.shrink(0.0625D, 0.0625D, 0.0625D)).isEmpty();
  3393.     boolean movedWrongly = false;
  3394.    
  3395.     vehicle.move(dx, dy, dz);
  3396.    
  3397.     if (vehicle.e(packet.x, packet.y, packet.z) > SpigotConfig.movedWronglyThreshold) {
  3398.       c.warn(this.player.getName() + " moves their vehicle (" + vehicle.getClass().getSimpleName() + ") wrongly!");
  3399.       movedWrongly = true;
  3400.     }
  3401.    
  3402.     vehicle.setLocation(packet.x, packet.y, packet.z, packet.yaw, packet.pitch);
  3403.    
  3404.     boolean destInBlock = !vehicle.world.getCubes(vehicle, vehicle.boundingBox.shrink(0.0625D, 0.0625D, 0.0625D)).isEmpty();
  3405.    
  3406.     if (!currentlyInBlock && (movedWrongly || destInBlock)) {
  3407.       vehicle.setLocation(currentX, currentY, currentZ, packet.yaw, packet.pitch);
  3408.       sendPacket(new PacketPlayOutVehicleMove(vehicle));
  3409.      
  3410.       return;
  3411.     }
  3412.     this.minecraftServer.getPlayerList().d(this.player);
  3413.   }
  3414.  
  3415.  
  3416.   public void handleUseItem(PacketPlayInUseItem packet) {
  3417.     if (packet.hand == 1) {
  3418.       if (this.player.isBlocking())
  3419.       {
  3420.         this.player.shieldBlocking = true;
  3421.       }
  3422.     } else {
  3423.       PacketPlayInBlockPlace place = new PacketPlayInBlockPlace();
  3424.       place.a = -1;
  3425.       place.b = -1;
  3426.       place.c = -1;
  3427.       place.d = 255;
  3428.       a(place);
  3429.     }
  3430.   }
  3431. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement