Solved Strange behavior about iron and gold pressure plates

Discussion in 'Plugin Development' started by Asgernohns, Jul 6, 2014.

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

    Asgernohns

    Hello all Bukkit developers! :)

    If i listen on stone and wooden pressure plates in PlayerInteractEvent it goes normal and fire once.
    But if i try the same, on a golden or an iron pressure plate it just keep firing over and over again?
    Is this my fault or is it a bug, in the bukkit api?

    Code: (it's not finish)
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4.  
    5. if(e.getClickedBlock().getType() == Material.WALL_SIGN || e.getClickedBlock().getType() == Material.SIGN_POST){
    6. if(e.getAction() == Action.RIGHT_CLICK_BLOCK){
    7. if(registerMode.containsKey(p.getName())){
    8. Block sign = e.getClickedBlock();
    9. p.sendMessage(ChatColor.GREEN+"Succesfully registred!");
    10. registeredSigns.put(registerMode.get(p.getName()), sign.getLocation());
    11. registerMode.remove(p.getName());
    12. e.setCancelled(true);
    13. }
    14. }
    15. }
    16.  
    17.  
    18.  
    19. if(e.getAction() == Action.PHYSICAL){
    20. System.out.println("physical");
    21. if(e.getClickedBlock().getType() == Material.IRON_PLATE ||
    22. e.getClickedBlock().getType() == Material.WOOD_PLATE ||
    23. e.getClickedBlock().getType() == Material.GOLD_PLATE ||
    24. e.getClickedBlock().getType() == Material.STONE_PLATE){
    25. System.out.println("its a plate");
    26. Block b = e.getClickedBlock();
    27.  
    28. Block optionA1 = b.getRelative(1,-1,0);
    29. Block optionA2 = b.getRelative(-1,-1,0);
    30. Block optionA3 = b.getRelative(0,-1,1);
    31. Block optionA4 = b.getRelative(0,-1,-1);
    32.  
    33. Block optionB1 = b.getRelative(0,-2,0);
    34.  
    35. Block optionC1 = b.getRelative(1,0,0);
    36. Block optionC2 = b.getRelative(-1,0,0);
    37. Block optionC3 = b.getRelative(0,0,1);
    38. Block optionC4 = b.getRelative(0,0,-1);
    39.  
    40.  
    41. //Options A
    42. if(optionA1.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    43. System.out.println("Post or wall");
    44. String name = null;
    45. if(registeredSigns.containsValue(optionA1.getLocation())){
    46. System.out.println("registred");
    47. for(Entry<String, Location> en: registeredSigns.entrySet()){
    48. if(en.getValue() == optionA1.getLocation()){
    49. name = en.getKey();
    50. break;
    51. }
    52.  
    53. }
    54. //getConfig().getString(name+".command")
    55. p.performCommand(getConfig().getString("test.command"));
    56. }
    57.  
    58. }else if(optionA2.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    59.  
    60. }else if(optionA3.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    61.  
    62. }else if(optionA4.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    63.  
    64. }
    65.  
    66.  
    67. //Options B
    68. else if(optionB1.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    69.  
    70. }
    71.  
    72.  
    73. //Options C
    74. else if(optionC1.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    75.  
    76. }else if(optionC2.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    77.  
    78. }else if(optionC3.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    79.  
    80. }else if(optionC4.getType() == Material.SIGN_POST || optionA1.getType() == Material.WALL_SIGN){
    81.  
    82. }
    83.  
    84.  
    85.  
    86.  
    87.  
    88.  
    89. }
    90. }
    91. }


    timtower do you know it?

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

    timtower Administrator Administrator Moderator

    Asgernohns never worked with pressure plates.
     
  3. Offline

    Asgernohns

    timtower What can i then do? to listen on iron/gold pressure plates? no options?
     
  4. Offline

    Necrodoom

    Actually wait for someone who knows to help you.
     
  5. Online

    timtower Administrator Administrator Moderator

    Asgernohns You are already doing what I can think off.
     
  6. Offline

    Asgernohns

    Sorry i misunderstood his post :D
    i thought he meant listening on pressure plates never worked
     
  7. Offline

    Asgernohns

  8. Offline

    Asgernohns

    Hey everybody! i figured it out my self :D!

    The solution was to instead of using a PlayerInteractEvent, i used a PlayerMoveEvent.
    if getFrom() and getTo() still is on the same block, and if getTo().getBlock().getType() is equal to an iron_plate, gold_plate, stone_plate or wood_plate material, then fire a piece of code . :)
     
Thread Status:
Not open for further replies.

Share This Page