Advertisement
ZP4RKER

Complicated or Not?

Sep 29th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.37 KB | None | 0 0
  1. package zplugin.znexusfactions.api;
  2.  
  3. import com.avaje.ebean.validation.NotEmpty;
  4. import com.avaje.ebean.validation.NotNull;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.OfflinePlayer;
  8.  
  9. import javax.persistence.Entity;
  10. import javax.persistence.Id;
  11. import javax.persistence.Table;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. import java.util.UUID;
  15.  
  16. @Entity()
  17. @Table(name = "FactionsDB")
  18. public class FactionData {
  19.  
  20. @Id
  21. private int id;
  22.  
  23. @NotEmpty
  24. private String name, tag;
  25.  
  26. @NotNull
  27. private List<UUID> players = new ArrayList<>();
  28.  
  29. @NotEmpty
  30. private String world;
  31.  
  32. @NotNull
  33. private int nexusX, nexusY, nexusZ;
  34.  
  35. @NotNull
  36. private int xOne, yOne, zOne;
  37.  
  38. @NotNull
  39. private int xTwo, yTwo, zTwo;
  40.  
  41. public int getId() {
  42. return id;
  43. }
  44.  
  45. public String getName() {
  46. return name;
  47. }
  48.  
  49. public String getTag() {
  50. return tag;
  51. }
  52.  
  53. public List<UUID> getPlayers() {
  54. return players;
  55. }
  56.  
  57. public String getWorld() {
  58. return world;
  59. }
  60.  
  61. public int getNexusX() {
  62. return nexusX;
  63. }
  64.  
  65. public int getNexusY() {
  66. return nexusY;
  67. }
  68.  
  69. public int getNexusZ() {
  70. return nexusZ;
  71. }
  72.  
  73. public int getxOne() {
  74. return xOne;
  75. }
  76.  
  77. public int getyOne() {
  78. return yOne;
  79. }
  80.  
  81. public int getzOne() {
  82. return zOne;
  83. }
  84.  
  85. public int getxTwo() {
  86. return xTwo;
  87. }
  88.  
  89. public int getyTwo() {
  90. return yTwo;
  91. }
  92.  
  93. public int getzTwo() {
  94. return zTwo;
  95. }
  96.  
  97. public void setId(int id) {
  98. this.id = id;
  99. }
  100.  
  101. public void setName(String name) {
  102. this.name = name;
  103. }
  104.  
  105. public void setTag(String tag) {
  106. this.tag = tag;
  107. }
  108.  
  109. public void setPlayers(List<UUID> players) {
  110. this.players = players;
  111. }
  112.  
  113. public void setWorld(String world) {
  114. this.world = world;
  115. }
  116.  
  117. public void setNexusX(int nexusX) {
  118. this.nexusX = nexusX;
  119. }
  120.  
  121. public void setNexusY(int nexusY) {
  122. this.nexusY = nexusY;
  123. }
  124.  
  125. public void setNexusZ(int nexusZ) {
  126. this.nexusZ = nexusZ;
  127. }
  128.  
  129. public void setxOne(int xOne) {
  130. this.xOne = xOne;
  131. }
  132.  
  133. public void setyOne(int yOne) {
  134. this.yOne = yOne;
  135. }
  136.  
  137. public void setzOne(int zOne) {
  138. this.zOne = zOne;
  139. }
  140.  
  141. public void setxTwo(int xTwo) {
  142. this.xTwo = xTwo;
  143. }
  144.  
  145. public void setyTwo(int yTwo) {
  146. this.yTwo = yTwo;
  147. }
  148.  
  149. public void setzTwo(int zTwo) {
  150. this.zTwo = zTwo;
  151. }
  152.  
  153. public void setFaction(Faction faction) {
  154. this.name = faction.getName();
  155. this.tag = faction.getTag();
  156. List<UUID> players = new ArrayList<>();
  157. for (OfflinePlayer player : faction.getPlayers()) {
  158. players.add(player.getUniqueId());
  159. }
  160. this.players = players;
  161. this.world = faction.getNexus().getLocation().getWorld().getName();
  162. this.nexusX = faction.getNexus().getLocation().getBlockX();
  163. this.nexusY = faction.getNexus().getLocation().getBlockY();
  164. this.nexusZ = faction.getNexus().getLocation().getBlockZ();
  165. this.xOne = faction.getBase().getArea().get(0).getBlockX();
  166. this.yOne = faction.getBase().getArea().get(0).getBlockY();
  167. this.zOne = faction.getBase().getArea().get(0).getBlockZ();
  168. this.xTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockX();
  169. this.yTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockY();
  170. this.zTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockZ();
  171. }
  172.  
  173. public List<OfflinePlayer> getBukkitPlayers() {
  174. List<OfflinePlayer> list = new ArrayList<>();
  175. for (UUID uniqueID : players) {
  176. list.add(Bukkit.getOfflinePlayer(uniqueID));
  177. }
  178. return list;
  179. }
  180.  
  181. public Faction getFaction() {
  182. Nexus nexus = new Nexus(new Location(Bukkit.getWorld(world), nexusX, nexusY, nexusZ), false);
  183. Vault vault = new Vault(nexus);
  184. Base base = new Base(vault, players.size());
  185. Faction faction = new Faction(name, tag, getBukkitPlayers(), base, true);
  186. return faction;
  187. }
  188.  
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement