Need help with Damage

Discussion in 'Plugin Development' started by HerobrineLivesHere, Nov 16, 2013.

Thread Status:
Not open for further replies.
  1. Hi!

    I am working on making diffrent wands and I want to have the mob realated and I need to make a Snowgolem gun but the snowball does 0 damage so I need to set the damage but I don't know how I do it. Here is my code:
    Show Spoiler

    package me.swecraft.testwand;
    import java.util.Arrays;
    import me.swecraft.testwand.MessageManager.MessageType;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.entity.Entity;
    import org.bukkit.entity.Fireball;
    import org.bukkit.entity.Player;
    import org.bukkit.entity.Snowball;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public enum Wands {
     GHAST("Ghast Gun", ChatColor.GRAY, new WandRunnable() {
      public void run(PlayerInteractEvent e) {
       Fireball fb = e.getPlayer().launchProjectile(Fireball.class);
     MEDIC("Medic Heal Gun", ChatColor.RED, new WandRunnable() {
      public void run(PlayerInteractEvent e) {
       for (Entity en : e.getPlayer().getNearbyEntities(10, 10, 10)) {
        if (en instanceof Player) {
         ((Player) en).addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 5, 1));
         MessageManager.getInstance().msg((Player) en, MessageType.INFO, ChatColor.DARK_PURPLE + "You have been given a regen effect by " + e.getPlayer().getName() + "!");
         MessageManager.getInstance().msg(e.getPlayer(), MessageType.INFO, ChatColor.DARK_PURPLE + "You have regened " + ((Player) en).getName() + "!");
     SNOWGOLEM("Snowgolem Gun", ChatColor.WHITE, new WandRunnable() {
      public void run(PlayerInteractEvent e) {
     private String name;
     private ChatColor color;
     private WandRunnable run;
     Wands(String name, ChatColor color, WandRunnable run) { = name;
      this.color = color; = run;
     public String getName() {
      return name;
     public ChatColor getColor() {
      return color;
     public String getFullName() {
      return color + name;
     public void run(PlayerInteractEvent e) {;
     public ItemStack createItemStack() {
      ItemStack i = new ItemStack(Material.STICK, 1);
      ItemMeta im = i.getItemMeta();
      im.setLore(Arrays.asList("A magic wand!"));
      return i;
     public static Wands forName(String name) {
      for (Wands w : Wands.values()) {
       if (w.getName().equalsIgnoreCase(name)) return w;
      return null;
    abstract class WandRunnable { public abstract void run(PlayerInteractEvent e); }

    Thanks. :)
  2. Offline


    Snowballs don't do damage... =P​

    EDIT: Oh... read more clearly now... you want it to do damage.
    SuperSniper1379 likes this.
  3. Yes, I have done if before but then it was in a seperate classes for each wand but I decided to drop that.
  4. Offline


    Well, you could make a new method for a player getting hit by a snowball, (I'm not really sure what event to use, but it shouldn't be hard to find) then check the damager's item in their hand and make it damage the victim however you like.
    SuperSniper1379 likes this.
Thread Status:
Not open for further replies.

Share This Page