Advertisement
Guest User

Plugin class

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