Need help with player death event

Discussion in 'Plugin Development' started by anorexicPanda, Jul 19, 2012.

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

    Kodfod

    Any time =)

    And to get them to get there, just call the config x y z and world.
     
  2. Offline

    anorexicPanda

    Why do I want to save it to another file(config)? Can't I just change a variable?
     
  3. Offline

    Kodfod

    :confused: i dont know what you mean.... you would use getConfig().getInt(player + ".X") inside the teleport player part of the plugin is what i was saying
     
  4. Offline

    anorexicPanda

    What does that do?
     
  5. Offline

    Kodfod

    That would take them back to their last location =P
     
  6. Offline

    anorexicPanda

    But this: getConfig().getInt(player + ".X") is just calling from the file right? How do i set the config to have his location when he dies?
     
  7. Offline

    Kodfod

    You get that and put it into a var so lets say int x = getConfig().getInt(player + ".X");

    Then in the player.teleport(x, y, z, world)l you put it in the respective area.
     
  8. Offline

    anorexicPanda

    But how do I create the config file and edit its contents? Because doesn't that line access the variable "x" from the file "config"?
     
  9. Offline

    Kodfod

    okay. create a config.yml in your src (or where your plugin.yml is)
    then add the defaults(nothing in this case)
    Then on your onEnable() add this: this.getConfig().options.copyDefaults(true);
    Then: this.saveConfig();
     
  10. Offline

    anorexicPanda

    I have this but it says "The field MemoryConfiguration.options is not visible" for line 5:
    Code:
    1| public void onEnable(){
    2|    System.out.println("Plugin Enabled");
    3|    PluginManager pm = getServer().getPluginManager();
    4|    pm.registerEvents(this.PlayerListener, this);
    5|    this.getConfig().options.copyDefaults(true);
    6|    this.saveConfig();
    7|}
     
  11. Offline

    chaseoes

    Try removing this. from everything. You shouldn't need it since it's your main class.
     
  12. Offline

    anorexicPanda

    I still get the same error
     
  13. Offline

    andrutay

    PlayerDeathEvent has two player entities: The Player (The one killed) and the Killer (The one who kills):
    Review the following code.

    Code:java
    1. @EventHandler
    2. public void onPlayerDeath(PlayerDeathEvent event) {
    3. Player player = event.getEntity().getPlayer();
    4. //This is the player who is killed
    5.  
    6. Player killer = event.getEntity().getKiller();
    7. //This is the killer
    8.  
    9. //Now you can use "player" and "killer" like so: (Example)
    10.  
    11. killer.sendMessage("You killed " + player.getName() + "!"):
    12. //Sends the killer "You killed [player]!"
    13.  
    14. player.sendMessage(killer.getName() + " killed you!");
    15. //Sends the player "[killer] killed you!"
    16.  
     
Thread Status:
Not open for further replies.

Share This Page