Advertisement
Guest User

Untitled

a guest
Oct 8th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.51 KB | None | 0 0
  1. package br.com.outlook.ausare.factionsx.faction;
  2.  
  3. import java.util.Map;
  4. import java.util.Set;
  5.  
  6. import br.com.outlook.ausare.factionsx.faction.invites.Invite;
  7.  
  8. public class Faction {
  9.  
  10. private Set<FPlayer> players;
  11. private String tag;
  12. private String desc;
  13. private double power;
  14. private Set<Invite> convites;
  15. private Map<String, Relation> relation;
  16. private String id;
  17.  
  18. public Faction(String id) {
  19. this.id = id;
  20. }
  21.  
  22. public void setPlayer(Set<FPlayer> players) {
  23. this.players = players;
  24. }
  25.  
  26. public Set<FPlayer> getPlayers() {
  27. return this.players;
  28. }
  29.  
  30. public void setTag(String tag) {
  31. this.tag = tag;
  32. }
  33.  
  34. public String getTag() {
  35. return this.tag;
  36. }
  37.  
  38. public void setDesc(String desc) {
  39. this.desc = desc;
  40. }
  41.  
  42. public String getDesc() {
  43. return desc;
  44. }
  45.  
  46. public void setPower(double power) {
  47. this.power = power;
  48. }
  49.  
  50. public double getPower() {
  51. return power;
  52. }
  53.  
  54. public void setInvites(Set<Invite> convites) {
  55. this.convites = convites;
  56. }
  57.  
  58. public Set<Invite> getInvites() {
  59. return convites;
  60. }
  61.  
  62. public void setRelation(Map<String, Relation> relation) {
  63. this.relation = relation;
  64. }
  65.  
  66. public Map<String, Relation> getRelation() {
  67. return relation;
  68. }
  69.  
  70. public String getID() {
  71. return id;
  72. }
  73.  
  74. }
  75.  
  76. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  77.  
  78.  
  79.  
  80. package br.com.outlook.ausare.factionsx.faction;
  81.  
  82. import org.bukkit.Bukkit;
  83. import org.bukkit.entity.Player;
  84.  
  85. import br.com.outlook.ausare.factionsx.faction.invites.Invite;
  86. import br.com.outlook.ausare.factionsx.faction.invites.InviteUtils;
  87.  
  88. public class FPlayer {
  89.  
  90. private String faction;
  91. private double power;
  92. private Rank factionRank;
  93. private Player player;
  94.  
  95. public FPlayer(String player) {
  96. for (final Player players : Bukkit.getServer().getOnlinePlayers()) {
  97. if (players.getUniqueId().toString().equals(player)) {
  98. setPlayer(players);
  99. }
  100. }
  101. }
  102.  
  103. public FPlayer(Player p) {
  104. setPlayer(p);
  105. }
  106.  
  107. public Invite getInvite() {
  108. return InviteUtils.invites.get(player);
  109. }
  110.  
  111. public String getFaction() {
  112. return faction;
  113. }
  114.  
  115. public void setFaction(String faction) {
  116. this.faction = faction;
  117. }
  118.  
  119. public double getPower() {
  120. return power;
  121. }
  122.  
  123. public void setPower(double power) {
  124. this.power = power;
  125. }
  126.  
  127. public Rank getFactionRank() {
  128. return factionRank;
  129. }
  130.  
  131. public void setFactionRank(Rank factionRank) {
  132. this.factionRank = factionRank;
  133. }
  134.  
  135. public Player getPlayer() {
  136. return player;
  137. }
  138.  
  139. public void setPlayer(Player player) {
  140. this.player = player;
  141. }
  142.  
  143. public boolean isOnline() {
  144. return getPlayer().isOnline();
  145. }
  146.  
  147. }
  148.  
  149.  
  150. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  151.  
  152. package br.com.outlook.ausare.factionsx.faction;
  153.  
  154.  
  155. public enum Rank {
  156.  
  157. LIDER(4, "Líder"), MODERADOR(3, "Moderador"), MEMBRO(2, "Membro"), NONE(1, "Nenhum");
  158.  
  159. private int rankN;
  160. private String rankS;
  161.  
  162. private Rank(int i, String s) {
  163. this.rankN = i;
  164. this.rankS = s;
  165. }
  166.  
  167. public String getString() {
  168. return rankS;
  169. }
  170.  
  171. public int getInt() {
  172. return rankN;
  173. }
  174.  
  175. public int getNext() {
  176. return rankN != 4 ? rankN + 1 : rankN;
  177. }
  178.  
  179. public int getPrevious() {
  180. return rankN != 1 ? rankN - 1 : rankN;
  181. }
  182.  
  183. public Rank valueOf(int i) {
  184. switch (i) {
  185. case 4:
  186. return Rank.LIDER;
  187. case 3:
  188. return Rank.MODERADOR;
  189. case 2:
  190. return Rank.MEMBRO;
  191. case 1:
  192. return Rank.NONE;
  193. default:
  194. break;
  195. }
  196. return Rank.NONE;
  197. }
  198. }
  199.  
  200. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  201.  
  202. package br.com.outlook.ausare.factionsx.faction;
  203.  
  204. public enum Relation {
  205.  
  206. NEUTRO, ALIADO, INIMIGO;
  207.  
  208. }
  209.  
  210.  
  211. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  212.  
  213. package br.com.outlook.ausare.factionsx.faction.invites;
  214.  
  215. import org.bukkit.entity.Player;
  216.  
  217. import br.com.outlook.ausare.factionsx.Factions;
  218. import br.com.outlook.ausare.factionsx.faction.FPlayer;
  219. import br.com.outlook.ausare.factionsx.faction.Faction;
  220. import br.com.outlook.ausare.factionsx.faction.FactionUtils;
  221. import br.com.outlook.ausare.factionsx.faction.Rank;
  222.  
  223. public class Invite {
  224.  
  225. private String facId;
  226. private Player player;
  227.  
  228. public Invite(String facId, Player player) {
  229. this.setFacId(facId);
  230. this.setPlayer(player);
  231. }
  232.  
  233. public void aceitar(FPlayer fplayer) {
  234. if (fplayer.getFactionRank().getInt() >= Rank.MODERADOR.getInt()) {
  235. if (FactionUtils.getPlayerFaction(getPlayer().getUniqueId()) == null) {
  236. Faction fac = FactionUtils.getFactionByID(facId);
  237. if (fac.getPlayers().size() >= Factions.getInstance().getMainConfig().FACTION_MAXSIZE) {
  238. fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().INVITE_CAPACIDADE_MAXIMA);
  239. return;
  240. }
  241. FPlayer fp = FactionUtils.player.get(getPlayer().getUniqueId());
  242. if (fp == null) fp = new FPlayer(getPlayer());
  243. fp.setFaction(getFacId());
  244. fp.setFactionRank(Rank.MEMBRO);
  245. } else {
  246. fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().INVITE_ERRO);
  247. }
  248. } else {
  249. fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().PRECISA_SER
  250. .replace("%minCargo%", Rank.MODERADOR.getString()));
  251. }
  252. }
  253.  
  254. public void negar() {
  255.  
  256. }
  257.  
  258. public String getFacId() {
  259. return facId;
  260. }
  261.  
  262. public void setFacId(String facId) {
  263. this.facId = facId;
  264. }
  265.  
  266. public Player getPlayer() {
  267. return player;
  268. }
  269.  
  270. public void setPlayer(Player player) {
  271. this.player = player;
  272. }
  273.  
  274.  
  275.  
  276. }
  277.  
  278.  
  279. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  280.  
  281. package br.com.outlook.ausare.factionsx.storage;
  282.  
  283. public enum Data {
  284.  
  285. SQL, FLAT;
  286. public static Data currentData;
  287.  
  288. public static void setupData() {
  289.  
  290. }
  291.  
  292. }
  293.  
  294.  
  295.  
  296. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  297.  
  298. package br.com.outlook.ausare.factionsx.configuration;
  299.  
  300. import java.util.Arrays;
  301. import java.util.List;
  302.  
  303. import org.bukkit.Bukkit;
  304. import org.bukkit.configuration.file.YamlConfiguration;
  305.  
  306. import br.com.outlook.ausare.factionsx.Factions;
  307. import br.com.outlook.ausare.factionsx.storage.Data;
  308.  
  309. public abstract class MainConfiguration extends FConfiguration {
  310.  
  311. public Data STORAGE;
  312.  
  313. public boolean USE_MYSQL;
  314. public String MYSQL_USER;
  315. public String MYSQL_PASSWORD;
  316. public String MYSQL_DATABASE;
  317. public String MYSQL_HOST;
  318.  
  319. public boolean USE_FLATFILE;
  320.  
  321. public List<String> COMMAND_ALIASES;
  322.  
  323. public int FACTION_MAXSIZE;
  324.  
  325. public MainConfiguration(Factions factions, YamlConfiguration file) {
  326. super(factions, file);
  327. USE_MYSQL = getBoolean("Data.UseMySQL", false);
  328. if (USE_MYSQL) {
  329. MYSQL_USER = getString("Data.MySQL.User");
  330. MYSQL_PASSWORD = getString("Data.MySQL.Password");
  331. MYSQL_DATABASE = getString("Data.MySQL.Database");
  332. MYSQL_HOST = getString("Data.MySQL.Host");
  333. }
  334. USE_FLATFILE = getBoolean("Data.UseFlatFile", true);
  335. if ((USE_MYSQL == true && USE_FLATFILE == true) || (USE_MYSQL == false && USE_FLATFILE == false))
  336. Bukkit.shutdown();
  337. if (USE_FLATFILE) STORAGE = Data.FLAT;
  338. if (USE_MYSQL) STORAGE = Data.SQL;
  339. COMMAND_ALIASES = getStringList("ComandoFaction.Aliases", Arrays.asList("faction", "cla"));
  340. }
  341.  
  342.  
  343.  
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement