Can someone make me really easy plugin??

Discussion in 'Plugin Development' started by APPLEisROP, Apr 23, 2013.

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

    APPLEisROP

    So.. Can someone make me PlayerDeathEvent plugin that If you kill other player it will addChatMeassage With red (not DARK_RED) You killed "player". I can make it myself if someone posts me the code :p Im java kid so i cant do it xD I made something but I don't know what to import... :D And Im bad with listeners... :) Hope someone can make it I know its pretty easy if you know how to code!
    Code:
    package DeathMsg;
     
    import java.util.*;
    import org.bukkit.*;
    import org.bukkit.entity.Player;
    import org.bukkit.event.*;
    import org.bukkit.event.entity.EntityDeathEvent;
    import org.bukkit.event.entity.PlayerDeathEvent;
    import org.bukkit.plugin.*;
     
    public class DeathMsg {
     
    private Listener bl;
    private Object plugin;
     
    public void onEnable() {
        PluginManager pm = Bukkit.getPluginManager();
        pm.registerEvent(Event.Type.BLOCK_PLACE, this.bl, Event.Priority.Normal, this);
        pm.registerEvent(Event.Type.BLOCK_BREAK, this.bl, Event.Priority.Normal, this);
        pm.registerEvent(Event.Type.BLOCK_IGNITE, this.bl, Event.Priority.Normal, this);
        pm.registerEvent(Event.Type.ENTITY_DEATH, this.pl, Event.Priority.Normal, this);
        PluginDescriptionFile pdfFile = this.getDescription();
        this.logger.info(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled.");
     
    }
    public void onEntityDeath(EntityDeathEvent evt) {
        if (evt instanceof PlayerDeathEvent) {
            PlayerDeathEvent event = (PlayerDeathEvent)evt;
            Player dead = ((Object) event).getPlayer();
            Player killer = player.getKiller();
            String killername = killer.getDisplayName();
            String deadname = dead.getDisplayName();
            Bukkit.addChatMessage(ChatColor.RED + " " + deadname + " " + ChatColor.RED + "was killed by" + ChatColor.RED + " " + killername);
            if(plugin.inGame == true) {
            }
        }
    
    I made that^^^ xD Tell me if its not 100% wrong and how to fix... :p
    Give's 15 errors and even i would fix them I think it's not gonna work... :D
     
  2. Offline

    kreashenz

    APPLEisROP Instead of Bukkit.addChatMessage, why not use Bukkit.broadcastMessage(Message)
     
  3. Offline

    APPLEisROP

    Thanks, but still not fully fixed :p
     
  4. Offline

    Tzeentchful

    APPLEisROP
    First off you need to make it extend JavaPlugin for bukkit to be able to load it.
    And you are using the old event system which is very broken.
    You might want to go look at some more recent tutorials.
    Some of the more experienced devs on here (including myself) are doing an up to date tutorial series. You should go check it out.
     
    gomeow likes this.
  5. Offline

    unforgiven5232

    Sorry I'm on my phone so I hope u that the code is good enough

    @EventHandler
    public void deathMessage (PlayerDeathEvent){ // why register every entity. jist make it players
    Player dead = event.getEntity();
    Player killer =dead.getKiller();
    }


    Then add the stuff below that, so u were mostly correct just needed to change a few stuff. and at the top write
    pm.registerEvent(this, this);
    that should work
     
  6. Offline

    gomeow

    APPLEisROP
    You are using the old event system.
    You can look in my signature for some updated tutorials

    unforgiven5232
    You don't define event.
     
Thread Status:
Not open for further replies.

Share This Page