Booster Pad

Discussion in 'Plugin Development' started by AlexHH251997, Nov 24, 2013.

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

    AlexHH251997

    Hello there,

    I am creating a booster pad plugin that I want to use that will give random amounts of coins to the player when stepping on a certain block. The only problem is when you step on that block it doesn't do what I need it to, I need it to make the noise and do the effect so I know that is has been carried out as my scoreboard is not showing up. I am wondering if my code to check if the player is on the block is not compiled correctly?
    Code:java
    1. @EventHandler
    2. public void onBooster(PlayerMoveEvent e){
    3. Player p = e.getPlayer();
    4. PlayingPlayer pp = pl.players.get(p);
    5. Random rand = new Random();
    6. int bronzeTokens = rand.nextInt(20) + 5;
    7. int silverTokens = rand.nextInt(45) + 5;
    8. int goldTokens = rand.nextInt(95) + 5;
    9. int lapisTokens = rand.nextInt(145) + 5;
    10. if(e.getFrom().getBlock().getType() == Material.REDSTONE_BLOCK){
    11. if(p.hasPermission("DTC.booster.bronze")){
    12. pp.addTokens(bronzeTokens);
    13. p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 0);
    14. p.getWorld().playSound(p.getLocation(), Sound.ORB_PICKUP, 75, 75);
    15. }else if(p.hasPermission("DTC.booster.silver")){
    16. pp.addTokens(silverTokens);
    17. p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 0);
    18. p.getWorld().playSound(p.getLocation(), Sound.ORB_PICKUP, 75, 75);
    19. }else if(p.hasPermission("DTC.booster.gold")){
    20. pp.addTokens(goldTokens);
    21. p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 0);
    22. p.getWorld().playSound(p.getLocation(), Sound.ORB_PICKUP, 75, 75);
    23. }else if(p.hasPermission("DTC.booster.lapis")){
    24. pp.addTokens(lapisTokens);
    25. p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 0);
    26. p.getWorld().playSound(p.getLocation(), Sound.ORB_PICKUP, 75, 75);
    27. }else{
    28. p.sendMessage(Error + "You do not own a booster.");
    29. p.sendMessage(Error + "Purchase a booster @ " + ChatColor.DARK_RED + "donate.buildcraftia.com");
    30. }
    31. }
    32. }

    If anyone could tell me what I am doing wrong and how to fix it I would be glad.

    Regards in advance,
    Alex Harris
     
  2. Offline

    1Rogue

    On a random (haha) note, your .nextInt() is off by one (see the previous post where I clarified that).

    Also, you're using .getFrom(), which I believe means to get the previous location of the player. Try .getTo();
     
  3. Offline

    AlexHH251997

    Still nothing with .getTo(); I'm going to go now anyway so I will read your reply tomorrow.

    Thanks.
     
Thread Status:
Not open for further replies.

Share This Page