mcConfig.java 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. package com.gmail.nossr50;
  2. import java.util.*;
  3. import java.util.logging.Logger;
  4. import org.bukkit.block.Block;
  5. import org.bukkit.entity.Entity;
  6. public class mcConfig {
  7. private static volatile mcConfig instance;
  8. String location = "mcmmo.properties";
  9. protected static final Logger log = Logger.getLogger("Minecraft");
  10. static ArrayList<String> adminChatList = new ArrayList<String>();
  11. static ArrayList<Block> blockWatchList = new ArrayList<Block>();
  12. static ArrayList<Block> treeFeller = new ArrayList<Block>();
  13. static ArrayList<String> partyChatList = new ArrayList<String>();
  14. static ArrayList<String> godModeList = new ArrayList<String>();
  15. HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
  16. static ArrayList<Entity> bleedTracker = new ArrayList<Entity>();
  17. static ArrayList<Entity> mobSpawnTracker = new ArrayList<Entity>();
  18. /*
  19. * The Bleed Que Stuff
  20. */
  21. public Entity[] bleedQue = new Entity[20];
  22. public int bleedQuePos = 0;
  23. public void addToBleedQue(Entity entity){
  24. //Assign entity to empty position
  25. bleedQue[bleedQuePos] = entity;
  26. //Move position up by 1 increment
  27. bleedQuePos++;
  28. //Check if array is full
  29. if(bleedQuePos >= bleedQue.length){
  30. //Create new temporary array
  31. Entity[] temp = new Entity[bleedQue.length*2];
  32. //Copy data from bleedQue to temporary array
  33. System.arraycopy(bleedQue, 0, temp, 0, bleedQue.length);
  34. //Point bleedQue to new array
  35. bleedQue = temp;
  36. }
  37. }
  38. public Entity[] getBleedQue(){return bleedQue;}
  39. public void clearBleedQue(){
  40. bleedQue = new Entity[bleedQue.length];
  41. setBleedQuePos(0);
  42. }
  43. public void setBleedQuePos(int x){bleedQuePos = x;}
  44. /*
  45. * The Bleed Removal Que Stuff
  46. */
  47. public Entity[] bleedRemovalQue = new Entity[20];
  48. public int bleedRemovalQuePos = 0;
  49. public void addToBleedRemovalQue(Entity entity){
  50. //Assign entity to empty position
  51. bleedRemovalQue[bleedRemovalQuePos] = entity;
  52. //Move position up by 1 increment
  53. bleedRemovalQuePos++;
  54. //Check if array is full
  55. if(bleedRemovalQuePos >= bleedRemovalQue.length){
  56. //Create new temporary array
  57. Entity[] temp = new Entity[bleedRemovalQue.length*2];
  58. //Copy data from bleedRemovalQue to temporary array
  59. System.arraycopy(bleedRemovalQue, 0, temp, 0, bleedRemovalQue.length);
  60. //Point bleedRemovalQue to new array
  61. bleedRemovalQue = temp;
  62. }
  63. }
  64. public Entity[] getBleedRemovalQue(){return bleedRemovalQue;}
  65. public void clearBleedRemovalQue(){
  66. bleedQue = new Entity[bleedRemovalQue.length];
  67. setBleedQuePos(0);
  68. }
  69. public void setBleedRemovalQuePos(int x){bleedRemovalQuePos = x;}
  70. public boolean isBlockWatched(Block block) {return blockWatchList.contains(block);}
  71. public boolean isTreeFellerWatched(Block block) {return treeFeller.contains(block);}
  72. public ArrayList<Block> getTreeFeller() {return treeFeller;}
  73. public void removeBlockWatch(Block block) {blockWatchList.remove(blockWatchList.indexOf(block));}
  74. public void addBlockWatch(Block block) {blockWatchList.add(block);}
  75. public void removeTreeFeller(Block block) {treeFeller.remove(treeFeller.indexOf(block));}
  76. public void addTreeFeller(Block block) {treeFeller.add(block);}
  77. public void addBleedTrack(Entity entity) {bleedTracker.add(entity);}
  78. public void addMobSpawnTrack(Entity entity) {mobSpawnTracker.add(entity);}
  79. public void removeMobSpawnTrack(Entity entity) {mobSpawnTracker.remove(entity);}
  80. public ArrayList<Entity> getBleedTracked() {return bleedTracker;}
  81. public void addArrowTrack(Entity entity, Integer arrowcount) {arrowTracker.put(entity, arrowcount);}
  82. public Integer getArrowCount(Entity entity) {return arrowTracker.get(entity);}
  83. public void removeArrowTracked(Entity entity){
  84. if(arrowTracker.containsKey(entity)){
  85. arrowTracker.remove(entity);
  86. }
  87. }
  88. public void removeBleedTrack(Entity entity){
  89. bleedTracker.remove(entity);
  90. }
  91. public void clearTreeFeller(){
  92. treeFeller.clear();
  93. }
  94. public void setBleedCount(Entity entity, Integer newvalue){
  95. bleedTracker.add(entity);
  96. }
  97. public void addArrowCount(Entity entity, Integer newvalue) {
  98. arrowTracker.put(entity, arrowTracker.get(entity) + newvalue);
  99. }
  100. public boolean isTracked(Entity entity) {
  101. if(arrowTracker.containsKey(entity)){
  102. return true;
  103. } else {
  104. return false;
  105. }
  106. }
  107. public boolean isMobSpawnTracked(Entity entity) {
  108. if(mobSpawnTracker.contains(entity)){
  109. return true;
  110. } else {
  111. return false;
  112. }
  113. }
  114. public boolean isBleedTracked(Entity entity) {
  115. if(bleedTracker.contains(entity)){
  116. return true;
  117. } else {
  118. return false;
  119. }
  120. }
  121. public boolean isAdminToggled(String playerName) {return adminChatList.contains(playerName);}
  122. public boolean isPartyToggled(String playerName) {return partyChatList.contains(playerName);}
  123. public boolean isGodModeToggled(String playerName) {return godModeList.contains(playerName);}
  124. public void removeGodModeToggled(String playerName) {godModeList.remove(godModeList.indexOf(playerName));}
  125. public void removePartyToggled(String playerName) {partyChatList.remove(partyChatList.indexOf(playerName));}
  126. public void removeAdminToggled(String playerName) {adminChatList.remove(adminChatList.indexOf(playerName));}
  127. public void addGodModeToggled(String playerName) {godModeList.add(playerName);}
  128. public void addPartyToggled(String playerName) {partyChatList.add(playerName);}
  129. public void addAdminToggled(String playerName) {adminChatList.add(playerName);}
  130. public static mcConfig getInstance() {
  131. if (instance == null) {
  132. instance = new mcConfig();
  133. }
  134. return instance;
  135. }
  136. public void toggleAdminChat(String playerName){
  137. if(isAdminToggled(playerName)){
  138. removeAdminToggled(playerName);
  139. } else {
  140. addAdminToggled(playerName);
  141. }
  142. }
  143. public void toggleGodMode(String playerName){
  144. if(isGodModeToggled(playerName)){
  145. removeGodModeToggled(playerName);
  146. } else {
  147. addGodModeToggled(playerName);
  148. }
  149. }
  150. public void togglePartyChat(String playerName){
  151. if(isPartyToggled(playerName)){
  152. removePartyToggled(playerName);
  153. } else {
  154. addPartyToggled(playerName);
  155. }
  156. }
  157. }