Solved Need help

Discussion in 'Plugin Development' started by GreatMinerZ, Dec 15, 2013.

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

    GreatMinerZ

    Why won't this work? No errors.

    Code:java
    1. @EventHandler
    2. public void PlayerRightClick(PlayerInteractEvent event){
    3. Player player = event.getPlayer();
    4. Location elocation = player.getEyeLocation();
    5.  
    6. Boolean hasLaunched = false;
    7.  
    8. int Distance = 25;
    9.  
    10. if(player.getItemInHand().getType().equals(Material.BLAZE_POWDER)) {
    11. if(event.getAction() == Action.RIGHT_CLICK_AIR) {
    12. player.sendMessage("Dit werkt!");
    13.  
    14.  
    15. //Block iterator
    16. BlockIterator blocksToAdd = new BlockIterator(elocation, 0.0D, Distance);
    17. Location blockToAdd;
    18.  
    19. while(blocksToAdd.hasNext()){
    20. blockToAdd = blocksToAdd.next().getLocation();
    21. if(!hasLaunched){
    22. if(blockToAdd.getBlock().getType() == Material.AIR) {
    23.  
    24.  
    25. try {
    26. fplayer.playFirework(player.getWorld(), blockToAdd, fFirework);
    27. } catch (Exception e) {
    28. }
    29.  
    30. }
    31. }
    32. }
    33. }
    34. }
    35. }
     
  2. Offline

    Webster56

    Add some System.out.println inside your block to trace what blocks are being executed with which value, and since there aren't many comments, we quite don't know what is it supposed to do.

    Oh, and pritive types start with a lower case letter (boolean)
     
  3. Offline

    clienthax

    you shoudn't assume that the player has something in their hand either.
     
  4. Offline

    GreatMinerZ

    Webster56 How would i send the player a message when right clicking 'blaze powder' ?

    code:

    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(PlayerInteractEvent event) {
    3. Player player = event.getPlayer();
    4. Location elocation = player.getEyeLocation();
    5.  
    6. if (event.getAction() == Action.RIGHT_CLICK_AIR) {
    7. if (event.getPlayer().getItemInHand().getType() == Material.BLAZE_POWDER) {
    8. player.sendMessage("Test!");
    9.  
    10. //more code
     
  5. Offline

    Webster56

    I've heard there were issues with the right clicks in the air, but this should work. Try to add every right click related actions maybe.
     
  6. Offline

    sgavster

    Are your events registered?
     
  7. Offline

    GreatMinerZ

    sgavster I actually forgot about that.. It works now. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page