Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zplugin.znexusfactions.api;
- import com.avaje.ebean.validation.NotEmpty;
- import com.avaje.ebean.validation.NotNull;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.OfflinePlayer;
- import javax.persistence.Entity;
- import javax.persistence.Id;
- import javax.persistence.Table;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.UUID;
- @Entity()
- @Table(name = "FactionsDB")
- public class FactionData {
- @Id
- private int id;
- @NotEmpty
- private String name, tag;
- @NotNull
- private List<UUID> players = new ArrayList<>();
- @NotEmpty
- private String world;
- @NotNull
- private int nexusX, nexusY, nexusZ;
- @NotNull
- private int xOne, yOne, zOne;
- @NotNull
- private int xTwo, yTwo, zTwo;
- public int getId() {
- return id;
- }
- public String getName() {
- return name;
- }
- public String getTag() {
- return tag;
- }
- public List<UUID> getPlayers() {
- return players;
- }
- public String getWorld() {
- return world;
- }
- public int getNexusX() {
- return nexusX;
- }
- public int getNexusY() {
- return nexusY;
- }
- public int getNexusZ() {
- return nexusZ;
- }
- public int getxOne() {
- return xOne;
- }
- public int getyOne() {
- return yOne;
- }
- public int getzOne() {
- return zOne;
- }
- public int getxTwo() {
- return xTwo;
- }
- public int getyTwo() {
- return yTwo;
- }
- public int getzTwo() {
- return zTwo;
- }
- public void setId(int id) {
- this.id = id;
- }
- public void setName(String name) {
- this.name = name;
- }
- public void setTag(String tag) {
- this.tag = tag;
- }
- public void setPlayers(List<UUID> players) {
- this.players = players;
- }
- public void setWorld(String world) {
- this.world = world;
- }
- public void setNexusX(int nexusX) {
- this.nexusX = nexusX;
- }
- public void setNexusY(int nexusY) {
- this.nexusY = nexusY;
- }
- public void setNexusZ(int nexusZ) {
- this.nexusZ = nexusZ;
- }
- public void setxOne(int xOne) {
- this.xOne = xOne;
- }
- public void setyOne(int yOne) {
- this.yOne = yOne;
- }
- public void setzOne(int zOne) {
- this.zOne = zOne;
- }
- public void setxTwo(int xTwo) {
- this.xTwo = xTwo;
- }
- public void setyTwo(int yTwo) {
- this.yTwo = yTwo;
- }
- public void setzTwo(int zTwo) {
- this.zTwo = zTwo;
- }
- public void setFaction(Faction faction) {
- this.name = faction.getName();
- this.tag = faction.getTag();
- List<UUID> players = new ArrayList<>();
- for (OfflinePlayer player : faction.getPlayers()) {
- players.add(player.getUniqueId());
- }
- this.players = players;
- this.world = faction.getNexus().getLocation().getWorld().getName();
- this.nexusX = faction.getNexus().getLocation().getBlockX();
- this.nexusY = faction.getNexus().getLocation().getBlockY();
- this.nexusZ = faction.getNexus().getLocation().getBlockZ();
- this.xOne = faction.getBase().getArea().get(0).getBlockX();
- this.yOne = faction.getBase().getArea().get(0).getBlockY();
- this.zOne = faction.getBase().getArea().get(0).getBlockZ();
- this.xTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockX();
- this.yTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockY();
- this.zTwo = faction.getBase().getArea().get(faction.getBase().getArea().size()).getBlockZ();
- }
- public List<OfflinePlayer> getBukkitPlayers() {
- List<OfflinePlayer> list = new ArrayList<>();
- for (UUID uniqueID : players) {
- list.add(Bukkit.getOfflinePlayer(uniqueID));
- }
- return list;
- }
- public Faction getFaction() {
- Nexus nexus = new Nexus(new Location(Bukkit.getWorld(world), nexusX, nexusY, nexusZ), false);
- Vault vault = new Vault(nexus);
- Base base = new Base(vault, players.size());
- Faction faction = new Faction(name, tag, getBukkitPlayers(), base, true);
- return faction;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement