Advertisement
Guest User

Untitled

a guest
Nov 11th, 2013
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. package me.JPG.Tester;
  2.  
  3. import java.util.ArrayList;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.Location;
  6.  
  7. /**
  8. *
  9. * @Author Jake
  10. */
  11. public class Arena {
  12.  
  13. //A list of all the Arena Objects
  14. public static ArrayList<Arena> arenaObjects = new ArrayList<Arena>();
  15.  
  16. //Some fields we want each Arena object to store:
  17. private Location joinLocation, startLocation, endLocation; //Some general arena locations
  18.  
  19. private String name; //Arena name
  20. private ArrayList<String> players = new ArrayList<String>(); //And arraylist of players name
  21.  
  22. private int maxPlayers;
  23.  
  24. private boolean inGame = false; //Boolean to determine if an Arena is ingame or not, automaticly make it false
  25.  
  26.  
  27. //Now for a Constructor:
  28. public Arena (String arenaName, Location joinLocation, Location startLocation, Location endLocation, int maxPlayers) { //So basicly: Arena myArena = new Arena("My Arena", joinLocation, startLocation, endLocation, 17)
  29. //Lets initalize it all:
  30. this.name = arenaName;
  31. this.joinLocation = joinLocation;
  32. this.startLocation = startLocation;
  33. this.endLocation = endLocation;
  34. this.maxPlayers = maxPlayers;
  35.  
  36. //Now lets add this object to the list of objects:
  37. arenaObjects.add(this);
  38.  
  39. }
  40.  
  41. //Now for some Getters and Setters, so with our arena object, we can use special methods:
  42. public Location getJoinLocation() {
  43. return this.joinLocation;
  44. }
  45.  
  46. public void setJoinLocation(Location joinLocation) {
  47. this.joinLocation = joinLocation;
  48. }
  49.  
  50. public Location getStartLocation() {
  51. return this.startLocation;
  52. }
  53.  
  54. public void setStartLocation(Location startLocation) {
  55. this.startLocation = startLocation;
  56. }
  57.  
  58. public Location getEndLocation() {
  59. return this.endLocation;
  60. }
  61.  
  62. public void setEndLocation(Location endLocation) {
  63. this.endLocation = endLocation;
  64. }
  65.  
  66. public String getName() {
  67. return this.name;
  68. }
  69.  
  70. public void setName(String name) {
  71. this.name = name;
  72. }
  73.  
  74. public int getMaxPlayers() {
  75. return this.maxPlayers;
  76. }
  77.  
  78. public void setMaxPlayers(int maxPlayers) {
  79. this.maxPlayers = maxPlayers;
  80. }
  81.  
  82. public ArrayList<String> getPlayers() {
  83. return this.players;
  84. }
  85.  
  86.  
  87.  
  88. //And finally, some booleans:
  89. public boolean isFull() { //Returns weather the arena is full or not
  90. if (players.size() >= maxPlayers) {
  91. return true;
  92. } else {
  93. return false;
  94. }
  95. }
  96.  
  97.  
  98. public boolean isInGame() {
  99. return inGame;
  100. }
  101.  
  102. public void setInGame(boolean inGame) {
  103. this.inGame = inGame;
  104. }
  105.  
  106. //To send each player in the arena a message
  107. public void sendMessage(String message) {
  108. for (String s: players) {
  109. Bukkit.getPlayer(s).sendMessage(message);
  110. }
  111. }
  112.  
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement