Help me with my Plugin!

Discussion in 'Plugin Development' started by Huntiz, Jun 29, 2013.

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

    Huntiz

    I tried to do throw a Shuriken's, with a Nether Star, and it worked.
    But I tried it will do given damage monsters and people, it did not work, so I deleted.
    And I realized that you do something in PlayerMoveEvent, but did not understand what I need to do there.

    I want to do it will do 10 damage.
    And it will delete the Nether Star from hand and off the floor, to prevent duplicates.

    My code of MyPlayerListener:
    Code:java
    1. package com.gmail.grvhaim;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Material;
    7. import org.bukkit.World;
    8. import org.bukkit.block.Block;
    9. import org.bukkit.entity.Entity;
    10. import org.bukkit.entity.Item;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.EventHandler;
    13. import org.bukkit.event.Listener;
    14. import org.bukkit.event.block.Action;
    15. import org.bukkit.event.entity.EntityDamageEvent;
    16. import org.bukkit.event.player.PlayerInteractEvent;
    17. import org.bukkit.event.player.PlayerMoveEvent;
    18. import org.bukkit.inventory.ItemStack;
    19. import org.bukkit.scoreboard.DisplaySlot;
    20. import org.bukkit.scoreboard.Objective;
    21. import org.bukkit.scoreboard.Scoreboard;
    22. import org.bukkit.scoreboard.ScoreboardManager;
    23.  
    24. public class MyPlayerListener implements Listener {
    25.  
    26.  
    27. @EventHandler
    28. public void onPlayerInteract(PlayerInteractEvent event) {
    29. Player player = event.getPlayer();
    30. World world = player.getWorld();
    31. Block block = player.getTargetBlock(null, 50);
    32. Location location = block.getLocation();
    33. Location locationTeleport = new Location(world, location.getBlockX() - 2, location.getBlockY(), location.getBlockZ());
    34. int blockId = player.getItemInHand().getType().getId();
    35. if (blockId == 258 && event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
    36. if (block.getTypeId() != 0) {
    37. event.getPlayer().getWorld().strikeLightning(event.getPlayer().getTargetBlock(null, 200).getLocation());
    38. player.teleport(locationTeleport);
    39. }
    40. }
    41. if (blockId == 399 && event.getAction().equals(Action.RIGHT_CLICK_AIR)) {
    42. final Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.NETHER_STAR));
    43. item.setVelocity(player.getLocation().getDirection().multiply(2));
    44. }
    45. }
    46.  
    47. @EventHandler
    48. public void onDamage(EntityDamageEvent event) {
    49. Entity entity = event.getEntity();
    50. if (entity instanceof Player) {
    51. Player player = (Player)entity;
    52. if (WotGPlugin.hashmap.containsKey(player)) {
    53. event.setCancelled(true);
    54. }
    55. }
    56. }
    57.  
    58. @EventHandler
    59. public void onPlayerMove(PlayerMoveEvent event) {
    60. ScoreboardManager manager = Bukkit.getScoreboardManager();
    61. Scoreboard board = manager.getNewScoreboard();
    62. Objective objective = board.registerNewObjective("showhealth", "health");
    63. objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
    64. objective.setDisplayName("/ " + ChatColor.GREEN + "20");
    65. for (Player online : Bukkit.getOnlinePlayers()) {
    66. online.setScoreboard(board);
    67. online.setHealth(online.getHealth()); // Update their health
    68. }
    69. }
    70. }
    71.  
     
  2. Offline

    caseif

    EDIT: Removed

    This post contained the answer up until I saw your other post. Now I'm unwilling to help you. Honestly, double-posting is just kind of rude.
     
    NoLiver92 likes this.
  3. Offline

    Huntiz

    Sorry, I'm new here, I did not know that it shows other people rude.
    Please help me.
     
  4. Ok you forgot to register the hashmap
     
  5. Offline

    Huntiz

    Where I Forgot it? And where I need to put this?
     
  6. Offline

    MgMaor

    Ahmmmm.
    Copy from PvP Israel.
     
  7. Offline

    Huntiz

    Ori helps me a bit, my friend;).
     
  8. Underneath the Hashmap
     
  9. Offline

    zin0na5

    Answer in PM
     
  10. Offline

    MP5K

    Am i the only one around here who has no idea how you
    may you explain that to me :3
    i have never worked with the Scoreboard System :)
     
  11. Offline

    MgMaor


    [pig]
    Btw, Ori's soup are super dumb and buggy.
    Give it to him:
    Code:
    player.setHealth(player.getHealth() + 7 > player.getMaxHealth() ? player.getMaxHealth() : player.getHealth() + 7);
     
  12. Offline

    Huntiz

    Can you help me what I asked?
    "I want to do it will do 10 damage.
    And it will delete the Nether Star from hand and off the floor, to prevent duplicates."
     
Thread Status:
Not open for further replies.

Share This Page