Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package br.com.outlook.ausare.factionsx.faction;
- import java.util.Map;
- import java.util.Set;
- import br.com.outlook.ausare.factionsx.faction.invites.Invite;
- public class Faction {
- private Set<FPlayer> players;
- private String tag;
- private String desc;
- private double power;
- private Set<Invite> convites;
- private Map<String, Relation> relation;
- private String id;
- public Faction(String id) {
- this.id = id;
- }
- public void setPlayer(Set<FPlayer> players) {
- this.players = players;
- }
- public Set<FPlayer> getPlayers() {
- return this.players;
- }
- public void setTag(String tag) {
- this.tag = tag;
- }
- public String getTag() {
- return this.tag;
- }
- public void setDesc(String desc) {
- this.desc = desc;
- }
- public String getDesc() {
- return desc;
- }
- public void setPower(double power) {
- this.power = power;
- }
- public double getPower() {
- return power;
- }
- public void setInvites(Set<Invite> convites) {
- this.convites = convites;
- }
- public Set<Invite> getInvites() {
- return convites;
- }
- public void setRelation(Map<String, Relation> relation) {
- this.relation = relation;
- }
- public Map<String, Relation> getRelation() {
- return relation;
- }
- public String getID() {
- return id;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.faction;
- import org.bukkit.Bukkit;
- import org.bukkit.entity.Player;
- import br.com.outlook.ausare.factionsx.faction.invites.Invite;
- import br.com.outlook.ausare.factionsx.faction.invites.InviteUtils;
- public class FPlayer {
- private String faction;
- private double power;
- private Rank factionRank;
- private Player player;
- public FPlayer(String player) {
- for (final Player players : Bukkit.getServer().getOnlinePlayers()) {
- if (players.getUniqueId().toString().equals(player)) {
- setPlayer(players);
- }
- }
- }
- public FPlayer(Player p) {
- setPlayer(p);
- }
- public Invite getInvite() {
- return InviteUtils.invites.get(player);
- }
- public String getFaction() {
- return faction;
- }
- public void setFaction(String faction) {
- this.faction = faction;
- }
- public double getPower() {
- return power;
- }
- public void setPower(double power) {
- this.power = power;
- }
- public Rank getFactionRank() {
- return factionRank;
- }
- public void setFactionRank(Rank factionRank) {
- this.factionRank = factionRank;
- }
- public Player getPlayer() {
- return player;
- }
- public void setPlayer(Player player) {
- this.player = player;
- }
- public boolean isOnline() {
- return getPlayer().isOnline();
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.faction;
- public enum Rank {
- LIDER(4, "Líder"), MODERADOR(3, "Moderador"), MEMBRO(2, "Membro"), NONE(1, "Nenhum");
- private int rankN;
- private String rankS;
- private Rank(int i, String s) {
- this.rankN = i;
- this.rankS = s;
- }
- public String getString() {
- return rankS;
- }
- public int getInt() {
- return rankN;
- }
- public int getNext() {
- return rankN != 4 ? rankN + 1 : rankN;
- }
- public int getPrevious() {
- return rankN != 1 ? rankN - 1 : rankN;
- }
- public Rank valueOf(int i) {
- switch (i) {
- case 4:
- return Rank.LIDER;
- case 3:
- return Rank.MODERADOR;
- case 2:
- return Rank.MEMBRO;
- case 1:
- return Rank.NONE;
- default:
- break;
- }
- return Rank.NONE;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.faction;
- public enum Relation {
- NEUTRO, ALIADO, INIMIGO;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.faction.invites;
- import org.bukkit.entity.Player;
- import br.com.outlook.ausare.factionsx.Factions;
- import br.com.outlook.ausare.factionsx.faction.FPlayer;
- import br.com.outlook.ausare.factionsx.faction.Faction;
- import br.com.outlook.ausare.factionsx.faction.FactionUtils;
- import br.com.outlook.ausare.factionsx.faction.Rank;
- public class Invite {
- private String facId;
- private Player player;
- public Invite(String facId, Player player) {
- this.setFacId(facId);
- this.setPlayer(player);
- }
- public void aceitar(FPlayer fplayer) {
- if (fplayer.getFactionRank().getInt() >= Rank.MODERADOR.getInt()) {
- if (FactionUtils.getPlayerFaction(getPlayer().getUniqueId()) == null) {
- Faction fac = FactionUtils.getFactionByID(facId);
- if (fac.getPlayers().size() >= Factions.getInstance().getMainConfig().FACTION_MAXSIZE) {
- fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().INVITE_CAPACIDADE_MAXIMA);
- return;
- }
- FPlayer fp = FactionUtils.player.get(getPlayer().getUniqueId());
- if (fp == null) fp = new FPlayer(getPlayer());
- fp.setFaction(getFacId());
- fp.setFactionRank(Rank.MEMBRO);
- } else {
- fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().INVITE_ERRO);
- }
- } else {
- fplayer.getPlayer().sendMessage(Factions.getInstance().getMensagensConfiguration().PRECISA_SER
- .replace("%minCargo%", Rank.MODERADOR.getString()));
- }
- }
- public void negar() {
- }
- public String getFacId() {
- return facId;
- }
- public void setFacId(String facId) {
- this.facId = facId;
- }
- public Player getPlayer() {
- return player;
- }
- public void setPlayer(Player player) {
- this.player = player;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.storage;
- public enum Data {
- SQL, FLAT;
- public static Data currentData;
- public static void setupData() {
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- package br.com.outlook.ausare.factionsx.configuration;
- import java.util.Arrays;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.configuration.file.YamlConfiguration;
- import br.com.outlook.ausare.factionsx.Factions;
- import br.com.outlook.ausare.factionsx.storage.Data;
- public abstract class MainConfiguration extends FConfiguration {
- public Data STORAGE;
- public boolean USE_MYSQL;
- public String MYSQL_USER;
- public String MYSQL_PASSWORD;
- public String MYSQL_DATABASE;
- public String MYSQL_HOST;
- public boolean USE_FLATFILE;
- public List<String> COMMAND_ALIASES;
- public int FACTION_MAXSIZE;
- public MainConfiguration(Factions factions, YamlConfiguration file) {
- super(factions, file);
- USE_MYSQL = getBoolean("Data.UseMySQL", false);
- if (USE_MYSQL) {
- MYSQL_USER = getString("Data.MySQL.User");
- MYSQL_PASSWORD = getString("Data.MySQL.Password");
- MYSQL_DATABASE = getString("Data.MySQL.Database");
- MYSQL_HOST = getString("Data.MySQL.Host");
- }
- USE_FLATFILE = getBoolean("Data.UseFlatFile", true);
- if ((USE_MYSQL == true && USE_FLATFILE == true) || (USE_MYSQL == false && USE_FLATFILE == false))
- Bukkit.shutdown();
- if (USE_FLATFILE) STORAGE = Data.FLAT;
- if (USE_MYSQL) STORAGE = Data.SQL;
- COMMAND_ALIASES = getStringList("ComandoFaction.Aliases", Arrays.asList("faction", "cla"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement