Advertisement
Guest User

.

a guest
May 29th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package me.monsterrdebeast;
  2.  
  3. import java.util.Iterator;
  4. import java.util.Set;
  5. import java.util.WeakHashMap;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.player.PlayerInteractEvent;
  9.  
  10. public abstract class Spell
  11. {
  12. public static WeakHashMap<Integer, Spell> spells = new WeakHashMap();
  13. private int id;
  14. private String name;
  15. private String displayName;
  16.  
  17. public Spell(String name, String displayName)
  18. {
  19. this.name = name.replaceAll(" ", "");
  20. this.displayName = (displayName != null ? displayName : this.name);
  21.  
  22. int id = 0;
  23. for (Iterator localIterator = spells.keySet().iterator(); localIterator.hasNext();)
  24. {
  25. int i = ((Integer)localIterator.next()).intValue();
  26. if (i > id) {
  27. id = i;
  28. }
  29. }
  30. id++;
  31. this.id = id;
  32.  
  33. spells.put(Integer.valueOf(id), this);
  34. }
  35.  
  36. public String getName()
  37. {
  38. return ChatColor.stripColor(this.name);
  39. }
  40.  
  41. public String getDisplayName()
  42. {
  43. return this.displayName;
  44. }
  45.  
  46. public int getSpellID()
  47. {
  48. return this.id;
  49. }
  50.  
  51. public abstract void onLeftClick(Player paramPlayer, PlayerInteractEvent paramPlayerInteractEvent);
  52.  
  53. public abstract String onSelect();
  54.  
  55. public static Spell getByID(int id)
  56. {
  57. for (Spell spell : spells.values()) {
  58. if (spell.id == id) {
  59. return spell;
  60. }
  61. }
  62. return null;
  63. }
  64.  
  65. public static Spell getByName(String name)
  66. {
  67. for (Spell spell : spells.values()) {
  68. if (ChatColor.stripColor(spell.name).equalsIgnoreCase(ChatColor.stripColor(name))) {
  69. return spell;
  70. }
  71. }
  72. return null;
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement