CreeperPowerEvent called multiple times per creeper

Discussion in 'Plugin Development' started by Windows_i7_920, Mar 31, 2012.

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

    Windows_i7_920

    For some reason, I had to do a check in this event, or else the chat got spammed really bad. Which, means it must being getting called multiple times per creeper getting hit by lightning. I tested this on several builds, including the latest RB.

    Code:
        @EventHandler
        public void onCreeperPower(CreeperPowerEvent e)
        {
            if(!e.getEntity().isPowered())
            {
                String msg = "";
               
                msg = "&2[ACPL] A creeper has just been charged at: &e({x},{y},{z})&2 in world '&e{world}'&2!";
                msg = msg.replace("&", "ยง");
           
               
                msg = msg.replace("{world}", e.getEntity().getWorld().getName());
                msg = msg.replace("{x}", Integer.toString(e.getEntity().getLocation().getBlockX()));
                msg = msg.replace("{y}", Integer.toString(e.getEntity().getLocation().getBlockY()));
                msg = msg.replace("{z}", Integer.toString(e.getEntity().getLocation().getBlockZ()));
               
                Bukkit.getServer().broadcastMessage(msg);
            }
        }
     
  2. make an hashmap or something that remembers the creapers thats already hitted, to prevent doing another action whit the same vcreeper
     
Thread Status:
Not open for further replies.

Share This Page