Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. package chest;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. import org.bukkit.Location;
  9.  
  10. public class ChestHandler {
  11.  
  12. private Map<Location, Chest> chests;
  13. private ArrayList<ChestItem> items;
  14. private int minItems, maxItems;
  15.  
  16. public ChestHandler(int minItems,int maxItems, ArrayList<ChestItem> items){
  17. this.chests = new HashMap<>();
  18. this.minItems = minItems;
  19. this.maxItems = maxItems;
  20. this.items = items;
  21. }
  22.  
  23. public Chest getChest(Location loc){
  24. if(chests.containsKey(loc)) {
  25. return chests.get(loc);
  26. }
  27. return createNewChest(loc);
  28. }
  29.  
  30. private Chest createNewChest(Location loc){
  31. Chest chest = new Chest(minItems, maxItems, items);
  32. this.chests.put(loc, chest);
  33. return chest;
  34. }
  35.  
  36. public Map<Location, Chest> getChests() {
  37. return chests;
  38. }
  39.  
  40. public List<ChestItem> getItems() {
  41. return items;
  42. }
  43.  
  44. public int getMinItems() {
  45. return minItems;
  46. }
  47.  
  48. public int getMaxItems() {
  49. return maxItems;
  50. }
  51.  
  52.  
  53.  
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement