Solved Saving player name to config help plz and get prize

Discussion in 'Plugin Development' started by Guinomus, Dec 23, 2013.

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

    Guinomus

    When someone kills the boss enderdragon. He earns a certain amount of money.
    And his name is saved to the config.
    But it is not working ;-;

    Code:
    Prize: 10000
    Winner:
    My config

    Code:java
    1. @EventHandler
    2. public void onEntityDeathEvent(EntityDeathEvent event)
    3. {
    4. if (event.getEntity().getKiller() instanceof Player)
    5. {
    6. Player player = (Player) event.getEntity().getKiller();
    7. EntityType type = event.getEntityType();
    8.  
    9. // Example for checking damaged mob
    10. if (type == EntityType.ENDER_DRAGON)
    11. {
    12. Bukkit.broadcastMessage(ChatColor.DARK_PURPLE + "§l "+ player.getName() + ChatColor.GOLD + " §lKilled enderdragon and won the fearless tag!");
    13. Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "newtag clear " + getConfig().getString(player.getName(), "Winner."));
    14. Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "newtag set &c&lFearless " + player.getName());
    15. EconomyResponse r = econ.withdrawPlayer(player.getName(), getConfig().getInt("Prize."));
    16. getConfig().set(player.getName(), "Winner.");
    17. }
    18. }
    19. }
    20.  
    21. }

    Code.
     
  2. Offline

    adde

    To check if the entity is something:
    Code:java
    1.  
    2. if(type instanceof EnderDragon)
    3.  

    The give money is deposit, now withdraw.
    Also, it's better if you use vault economy so the plugin works with every big economy plugin.
    You will have to set the PLAYER to the string. In this case you set the path "playername" to "Winner."
    Code:java
    1.  
    2. Use getConfig().set("Winner", player.getName());
    3.  
     
Thread Status:
Not open for further replies.

Share This Page