Advertisement
Guest User

redone

a guest
Jan 11th, 2014
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None
  1. package HungerInfinity.Doooogle.me;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  12. import org.bukkit.event.player.PlayerJoinEvent;
  13.  
  14. public class HungerCurrency implements Listener, CommandExecutor{
  15.  
  16. public HungerCore plugin;
  17. public HungerCurrency(HungerCore plugin){
  18.  
  19. this.plugin = plugin;
  20.  
  21. }
  22.  
  23. HashMap<String, Integer> money = new HashMap<String, Integer>();
  24.  
  25. @EventHandler
  26. public void onJoin(PlayerJoinEvent event){
  27.  
  28. Player player = event.getPlayer();
  29. if(!money.containsKey(player.getName())){
  30.  
  31. money.put(player.getName(), 100);
  32.  
  33. plugin.getConfig().set("money", money);
  34.  
  35. if(money.containsKey(player.getName())){
  36.  
  37. player.sendMessage("Added to the HashMap!");
  38.  
  39. }
  40.  
  41. }
  42.  
  43. }
  44.  
  45. @EventHandler
  46. public void onHit(EntityDamageByEntityEvent event){
  47.  
  48. Player damager = (Player)event.getEntity();
  49.  
  50. if(money.containsKey(damager.getName())){
  51.  
  52. money.put(damager.getName(), money.get(damager.getName()) + 5);
  53.  
  54. }
  55.  
  56. Player player = (Player)event.getEntity();
  57.  
  58. if(money.containsKey(player.getName())){
  59.  
  60. money.put(player.getName(), money.get(damager.getName()) - 5);
  61.  
  62. }
  63.  
  64. }
  65.  
  66. @Override
  67. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  68.  
  69. if(cmd.getName().equalsIgnoreCase("money")){
  70.  
  71. if(money.containsKey(sender.getName())){
  72.  
  73. int amount = money.get(sender.getName());
  74.  
  75. sender.sendMessage(amount + " dollars in bank!");
  76.  
  77. return true;
  78.  
  79. } else{
  80.  
  81. sender.sendMessage("Not in HashMap!");
  82.  
  83. }
  84.  
  85.  
  86. }
  87.  
  88. return false;
  89. }
  90.  
  91.  
  92.  
  93.  
  94. }
Advertisement
RAW Paste Data Copied
Advertisement