Solved OnPlayerDeathevent problems

Discussion in 'Plugin Development' started by diamante0018, Sep 11, 2016.

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

    diamante0018

    Hi guys, I have a problem with this plugin it appears that the Lightning Bolt doesn't spawn at the Player Death Location, can you tell with it doesn't work


    Code:
    public class PlayerDeath extends JavaPlugin implements Listener {
        public void OnEnable() {
          Logger logger = Logger.getLogger("Player");
          PluginDescriptionFile cmdinfo = new PluginDescriptionFile("PlayerDeath", "1.0", "PlayerDeath");
          logger.info(cmdinfo.getName() + cmdinfo.getVersion() + "has benn enabled");
          }
        public void onDisable()  {
            Logger logger = Logger.getLogger("Player");
            PluginDescriptionFile cmdinfo = new PluginDescriptionFile("PlayerDeath", "1.0", "PlayerDeath");
            logger.info("The plugin " + cmdinfo.getName() + cmdinfo.getVersion() + " has been disabled");
         }
      
        @EventHandler(priority = EventPriority.HIGH)
        public void onPlayerDeath(PlayerDeathEvent event)  {
            Player player = event.getEntity();
            Location loc = player.getLocation();
            player.getWorld().strikeLightningEffect(loc);
            player.sendMessage(ChatColor.GOLD + "Your body has been electrocuted");
        }
    }
     
  2. Use Bukkit's Logger not Java's

    There is no need for this, Bukkit logs on enable already,

    This has no use, remove it.

    Don't make a variable you use once.
     
  3. Offline

    timtower Administrator Administrator Moderator

    @diamante0018 onEnable and onDisable start with lowercase.
    You never register the event.
     
  4. Offline

    diamante0018

    Thanks guy, I searched how to register an event and now it works :)
     
Thread Status:
Not open for further replies.

Share This Page