Minecraft Crashes (Packets involved)

Discussion in 'Plugin Development' started by vasil7112, May 4, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    vasil7112

    Dear Bukkit Developers,

    I have made a plugin that worked pretty normaly during th 1.7.2 and previous versions, but a user now complained about some crashes that he had. We went and a checked it and here is what we found.
    When a user tries to sleep, if another one is about 150 blocks close he gets kicked.

    Here are some codes and erros. Hope they help! :)

    Code:java
    1. package me.vasil7112.SleepyFeeling.Listeners;
    2.  
    3. import me.vasil7112.SleepyFeeling.SleepyFeeling;
    4. import net.minecraft.server.v1_7_R3.PacketPlayOutAnimation;
    5. import net.minecraft.server.v1_7_R3.PacketPlayOutBed;
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.ChatColor;
    8. import org.bukkit.Material;
    9. import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.block.Action;
    14. import org.bukkit.event.player.PlayerBedEnterEvent;
    15. import org.bukkit.event.player.PlayerInteractEvent;
    16.  
    17. public class PlayerSleepListener implements Listener{
    18.  
    19. private SleepyFeeling plugin;
    20.  
    21. public PlayerSleepListener(SleepyFeeling plugin){
    22. this.plugin = plugin;
    23. }
    24.  
    25.  
    26. @EventHandler
    27. public void onPlayerBedEnter(PlayerBedEnterEvent e){
    28. e.setCancelled(true);
    29. }
    30. @EventHandler
    31. public void onPlayerInteract(PlayerInteractEvent e) {
    32. final Player player = e.getPlayer();
    33.  
    34. if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    35. if(e.getClickedBlock().getType() == Material.BED_BLOCK){
    36. player.setSleepingIgnored(true);
    37. setSleeping(e.getPlayer(), e.getClickedBlock().getX(), e.getClickedBlock().getY(), e.getClickedBlock().getZ());
    38. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    39. @Override
    40. public void run() {
    41. if(plugin.Sleeping.contains(player)){
    42. exitBed(player);
    43. }
    44. }
    45. }, 20L * plugin.cConfig.getCustomConfig().getLong("Configuration.WaysToGetEnergy.Sleeping.AutoWakeUp"));
    46. }
    47. }
    48. }
    49.  
    50. public void setSleeping(Player c, int x, int y, int z) {
    51. PacketPlayOutBed bedpacket;
    52. try{
    53. bedpacket = new PacketPlayOutBed(((CraftPlayer) c).getHandle(), x, y, z);
    54. }catch(Exception e){
    55. plugin.getLogger().info(e.getMessage());
    56. return;
    57. }
    58. c.sendMessage(ChatColor.GREEN+"============["+ChatColor.GOLD+"SleepyFeeling"+ChatColor.GREEN+"]=============\n"+
    59. ChatColor.GREEN+"You are currently sleeping and fueling up with energy.\n" +
    60. ChatColor.GREEN+"You will automaticly leave the bed in " + " seconds.\n" +
    61. ChatColor.GREEN+"If you want to leave the bed earlier, just use the following command: \n"+
    62. ChatColor.GREEN+"/SleepyFeeling wakeup");
    63.  
    64. try{
    65. for (Player p : Bukkit.getOnlinePlayers()) {
    66. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bedpacket);
    67. }
    68. plugin.Sleeping.add(c);
    69. }catch(Exception e){
    70. plugin.getLogger().info(e.getMessage());
    71. return;
    72. }
    73. }
    74.  
    75. public void exitBed(Player player) {
    76. try{
    77. PacketPlayOutAnimation aniPacket = new PacketPlayOutAnimation(((CraftPlayer) player).getHandle(), 2);
    78. for (Player o : Bukkit.getOnlinePlayers()) {
    79. ((CraftPlayer) o).getHandle().playerConnection.sendPacket(aniPacket);
    80. }
    81. plugin.Sleeping.remove(player);
    82. if(plugin.cConfig.getCustomConfig().getBoolean("Configuration.Energy.EnergyNotifier.Constant")){
    83. if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("Chat")){
    84. plugin.SEU.showEnergyAmountChat(player);
    85. }else if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("Chat-%")){
    86. plugin.SEU.showEnergyPercentChat(player);
    87. }else if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("ToolTip")){
    88. plugin.SEU.showEnergyAmountBot(player);
    89. }else if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("ToolTip-%")){
    90. plugin.SEU.showEnergyPercentBot(player);
    91. }else if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("BossBar")){
    92. plugin.SEU.showEnergyAmountTop(player);
    93. }else if(plugin.cConfig.getCustomConfig().getString("Configuration.Energy.EnergyNotifier.Type").equalsIgnoreCase("BossBar-%")){
    94. plugin.SEU.showEnergyPercentTop(player);
    95. }else{
    96. plugin.SEU.showEnergyAmountChat(player);
    97. }
    98. }
    99. }catch(Exception e){
    100. plugin.getLogger().info(e.getMessage());
    101. return;
    102. }
    103. }
    104. }
    105.  



    Code:
    ---- Minecraft Crash Report ----
    // This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~]
     
    Time: 4/5/2014 2:35 μμ
    Description: Unexpected error
     
    java.lang.NullPointerException: Unexpected error
        at bln.a(SourceFile:493)
        at hp.a(SourceFile:47)
        at hp.a(SourceFile:12)
        at ej.a(SourceFile:174)
        at blq.e(SourceFile:212)
        at ban.p(SourceFile:1306)
        at ban.ak(SourceFile:774)
        at ban.f(SourceFile:728)
        at net.minecraft.client.main.Main.main(SourceFile:148)
     
     
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
     
    -- Head --
    Stacktrace:
        at bln.a(SourceFile:493)
        at hp.a(SourceFile:47)
        at hp.a(SourceFile:12)
        at ej.a(SourceFile:174)
        at blq.e(SourceFile:212)
     
    -- Affected level --
    Details:
        Level name: MpServer
        All players: 1 total; [blw['vasil7112'/147, l='MpServer', x=-479,47, y=72,62, z=-539,35]]
        Chunk stats: MultiplayerChunkCache: 428, 428
        Level seed: 0
        Level generator: ID 00 - default, ver 1. Features enabled: false
        Level generator options:
        Level spawn location: World: (4,64,108), Chunk: (at 4,4,12 in 0,6; contains blocks 0,0,96 to 15,255,111), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511)
        Level time: 1081140 game time, 1152324 day time
        Level dimension: 0
        Level storage version: 0x00000 - Unknown?
        Level weather: Rain time: 0 (now: true), thunder time: 0 (now: false)
        Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false
        Forced entities: 77 total; [blw['vasil7112'/147, l='MpServer', x=-479,47, y=72,62, z=-539,35], yp['Zombie'/953, l='MpServer', x=-469,50, y=54,00, z=-593,50], ym['Spider'/829, l='MpServer', x=-427,50, y=71,00, z=-582,50], xj['item.tile.dirt.default'/152, l='MpServer', x=-517,91, y=66,13, z=-519,88], xj['item.tile.dirt.default'/153, l='MpServer', x=-519,88, y=65,13, z=-517,94], xj['item.tile.dirt.default'/154, l='MpServer', x=-526,88, y=64,13, z=-513,88], wo['Sheep'/155, l='MpServer', x=-434,91, y=71,00, z=-539,94], wg['Cow'/156, l='MpServer', x=-511,75, y=63,00, z=-482,31], wg['Cow'/157, l='MpServer', x=-426,13, y=68,00, z=-508,81], yp['Zombie'/158, l='MpServer', x=-467,50, y=48,00, z=-598,06], wo['Sheep'/159, l='MpServer', x=-403,25, y=70,00, z=-528,19], yp['Zombie'/386, l='MpServer', x=-533,05, y=13,61, z=-540,72], wg['Cow'/148, l='MpServer', x=-456,84, y=71,00, z=-566,25], yp['Zombie'/809, l='MpServer', x=-402,50, y=69,00, z=-468,50], yp['Zombie'/149, l='MpServer', x=-470,00, y=44,00, z=-591,56], xj['item.tile.dirt.default'/150, l='MpServer', x=-517,13, y=67,13, z=-520,25], xj['item.tile.dirt.default'/151, l='MpServer', x=-518,78, y=65,13, z=-519,19], xy['Creeper'/926, l='MpServer', x=-463,50, y=30,00, z=-595,50], yk['Skeleton'/171, l='MpServer', x=-430,50, y=40,00, z=-608,69], yp['Zombie'/927, l='MpServer', x=-464,66, y=29,00, z=-604,95], yk['Skeleton'/170, l='MpServer', x=-436,50, y=41,00, z=-605,50], xy['Creeper'/169, l='MpServer', x=-505,50, y=38,00, z=-604,50], yk['Skeleton'/168, l='MpServer', x=-519,50, y=34,00, z=-583,50], wd['Bat'/175, l='MpServer', x=-460,75, y=42,10, z=-609,25], xy['Creeper'/174, l='MpServer', x=-466,50, y=44,00, z=-610,50], yp['Zombie'/173, l='MpServer', x=-538,50, y=32,00, z=-589,50], wo['Sheep'/172, l='MpServer', x=-435,59, y=64,00, z=-598,21], yk['Skeleton'/163, l='MpServer', x=-460,31, y=44,00, z=-607,31], yp['Zombie'/162, l='MpServer', x=-463,50, y=29,00, z=-602,50], wh['Horse'/161, l='MpServer', x=-537,94, y=67,00, z=-512,94], wg['Cow'/160, l='MpServer', x=-406,13, y=70,00, z=-524,97], yk['Skeleton'/167, l='MpServer', x=-518,50, y=34,00, z=-581,50], bnx['Proxwian'/237, l='MpServer', x=-488,37, y=71,01, z=-446,39], yp['Zombie'/166, l='MpServer', x=-512,50, y=33,00, z=-590,50], wg['Cow'/165, l='MpServer', x=-433,88, y=67,00, z=-467,03], xy['Creeper'/164, l='MpServer', x=-461,50, y=48,00, z=-606,94], yk['Skeleton'/424, l='MpServer', x=-436,50, y=71,00, z=-571,50], xy['Creeper'/534, l='MpServer', x=-432,50, y=68,00, z=-504,50], wf['Chicken'/190, l='MpServer', x=-551,53, y=64,00, z=-465,53], wg['Cow'/191, l='MpServer', x=-557,72, y=64,00, z=-466,75], yp['Zombie'/178, l='MpServer', x=-460,75, y=44,00, z=-609,78], yp['Zombie'/540, l='MpServer', x=-538,50, y=28,00, z=-532,50], xy['Creeper'/179, l='MpServer', x=-440,50, y=41,00, z=-615,50], yp['Zombie'/176, l='MpServer', x=-461,78, y=44,00, z=-609,13], xy['Creeper'/177, l='MpServer', x=-460,31, y=44,00, z=-610,69], wf['Chicken'/182, l='MpServer', x=-549,44, y=64,00, z=-474,44], yk['Skeleton'/180, l='MpServer', x=-440,50, y=41,00, z=-617,50], wo['Sheep'/181, l='MpServer', x=-441,92, y=67,00, z=-605,47], xy['Creeper'/205, l='MpServer', x=-547,72, y=44,00, z=-618,03], xy['Creeper'/476, l='MpServer', x=-535,50, y=73,00, z=-595,50], xy['Creeper'/206, l='MpServer', x=-554,88, y=39,00, z=-613,28], yk['Skeleton'/201, l='MpServer', x=-557,50, y=31,00, z=-616,50], xy['Creeper'/475, l='MpServer', x=-537,50, y=73,00, z=-595,50], wd['Bat'/203, l='MpServer', x=-550,09, y=45,10, z=-618,50], xz['Enderman'/202, l='MpServer', x=-557,00, y=31,00, z=-615,50], yk['Skeleton'/616, l='MpServer', x=-524,16, y=40,00, z=-526,53], yk['Skeleton'/617, l='MpServer', x=-518,28, y=40,00, z=-527,84], yp['Zombie'/193, l='MpServer', x=-399,22, y=42,00, z=-616,50], wg['Cow'/192, l='MpServer', x=-532,56, y=68,00, z=-617,63], yp['Zombie'/195, l='MpServer', x=-408,03, y=42,00, z=-617,56], yp['Zombie'/465, l='MpServer', x=-411,00, y=69,00, z=-555,44], yp['Zombie'/194, l='MpServer', x=-400,00, y=42,00, z=-616,50], yk['Skeleton'/220, l='MpServer', x=-558,50, y=47,00, z=-609,50], yk['Skeleton'/221, l='MpServer', x=-558,50, y=47,00, z=-610,50], yp['Zombie'/216, l='MpServer', x=-562,81, y=41,00, z=-611,47], yk['Skeleton'/633, l='MpServer', x=-421,50, y=26,00, z=-504,50], yp['Zombie'/452, l='MpServer', x=-403,50, y=21,00, z=-493,50], yp['Zombie'/632, l='MpServer', x=-422,50, y=26,00, z=-506,50], yp['Zombie'/451, l='MpServer', x=-406,50, y=21,00, z=-493,50], xy['Creeper'/985, l='MpServer', x=-518,14, y=38,00, z=-521,53], xy['Creeper'/229, l='MpServer', x=-504,50, y=72,00, z=-615,50], xy['Creeper'/588, l='MpServer', x=-556,50, y=23,00, z=-466,50], xz['Enderman'/589, l='MpServer', x=-555,50, y=23,00, z=-468,50], xy['Creeper'/226, l='MpServer', x=-504,50, y=72,00, z=-609,50], xy['Creeper'/710, l='MpServer', x=-499,50, y=20,00, z=-486,50], yk['Skeleton'/600, l='MpServer', x=-471,75, y=62,01, z=-461,53], xy['Creeper'/602, l='MpServer', x=-475,50, y=64,00, z=-467,50]]
        Retry entities: 0 total; []
        Server brand: CraftBukkit
        Server type: Non-integrated multiplayer server
    Stacktrace:
        at blr.a(SourceFile:289)
        at ban.b(SourceFile:1972)
        at ban.f(SourceFile:742)
        at net.minecraft.client.main.Main.main(SourceFile:148)
     
    -- System Details --
    Details:
        Minecraft Version: 1.7.9
        Operating System: Windows 7 (amd64) version 6.1
        Java Version: 1.7.0_07, Oracle Corporation
        Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
        Memory: 154553216 bytes (147 MB) / 423297024 bytes (403 MB) up to 954466304 bytes (910 MB)
        JVM Flags: 2 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1G
        AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
        IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95
        Launched Version: 1.7.9
        LWJGL: 2.9.1
        OpenGL: GeForce GTX 770/PCIe/SSE2 GL version 4.4.0, NVIDIA Corporation
        GL Caps: Using GL 1.3 multitexturing.
    Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
    Anisotropic filtering is supported and maximum anisotropy is 16.
    Shaders are available because OpenGL 2.1 is supported.
     
        Is Modded: Probably not. Jar signature remains and client brand is untouched.
        Type: Client (map_client.txt)
        Resource Packs: []
        Current Language: English (US)
        Profiler Position: N/A (disabled)
        Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
        Anisotropic Filtering: Off (1)
    Are you aware of any changes in bukkit packets that might caused it?

    Thanks alot for letting me know!

    Kind regards,
    vasil7112
     
  2. Offline

    RawCode

    comment lines about packet sending one by one before you will find invalid packet, then wwe will continue.
     
  3. vasil7112
    I'm pretty sure this is comming from mincraft and not from your plugin.
    I guess you have a mod that is instaled that may be uncompatible or maybe uncorectly installed.
    I could also be a problem with the game profile.


    Try making a new game profile.

    This is what I think. If this isn't it well... I'm sorry I can't help you more..
     
  4. Offline

    RawCode

    your code have only two lines about sending packets, its VERY hard to comment them and findout what cause issue...
     
  5. Offline

    Cirno

    I thought PacketPlayOutBed used entity ID, not the entity itself...

    edit: nvm, it doesn't.
     
  6. Offline

    vasil7112

    Hey there,
    I think you misunderstood. The hard part was not only commenting those lines but getting enough players to see what changes if there are more than 1 player.
    There we have the results : 1player = Works
    2 players = Problem
    2-10 players = Same problem
    10+ not tested, and not needed i think.

    Line with error :
    Code:
    ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bedpacket);
     
  7. Offline

    vasil7112

    Hmm i see
    Maybe it is because of the new Identification system? (UUID)
    I will debug it and be right back.

    No, the packet is not null

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  8. Offline

    vasil7112

  9. Offline

    vasil7112

Thread Status:
Not open for further replies.

Share This Page