Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Ghappy.EstateRanker;
- import com.sk89q.worldedit.Vector;
- import java.util.Arrays;
- import java.util.List;
- import org.bukkit.ChatColor;
- import org.bukkit.entity.Player;
- public class ERPlayer {
- public static EstateRanker plugin;
- private Player player;
- public enum Estate {Builder, Trader, Miner, Officer};
- public ERPlayer(Player p, EstateRanker e){
- player = p;
- plugin = e;
- }
- private String getGroup(){
- String[] groups;
- String thisEstate = null;
- groups = plugin.Permissions.getUser(player.getName()).getGroupsNames();
- for(int i = 0; i < groups.length; i++){
- if(plugin.lEst.contains(groups[i].toLowerCase())){
- if(thisEstate != null){
- if(plugin.trader.contains(thisEstate)){
- if(plugin.trader.indexOf(groups[i]) > plugin.trader.indexOf(thisEstate)){
- thisEstate = groups[i];
- }
- } else if(plugin.miner.contains(thisEstate)){
- if(plugin.miner.indexOf(groups[i]) > plugin.miner.indexOf(thisEstate)){
- thisEstate = groups[i];
- }
- } else if(plugin.builder.contains(thisEstate)){
- if(plugin.builder.indexOf(groups[i]) > plugin.builder.indexOf(thisEstate)){
- thisEstate = groups[i];
- }
- } else if(plugin.officer.contains(thisEstate)){
- if(plugin.officer.indexOf(groups[i]) > plugin.officer.indexOf(thisEstate)){
- thisEstate = groups[i];
- }
- }
- } else {
- thisEstate = groups[i];
- }
- }
- }
- return thisEstate.toLowerCase();
- }
- public String getEstate(){
- return getGroup();
- }
- public ChatColor EstateColor(){
- String thisEstate = getGroup();
- if(plugin.miner.contains(thisEstate)){
- return ChatColor.GREEN;
- } else if(plugin.officer.contains(thisEstate)){
- return ChatColor.BLUE;
- } else if(plugin.trader.contains(thisEstate)){
- return ChatColor.GOLD;
- } else if(plugin.builder.contains(thisEstate)){
- return ChatColor.DARK_GRAY;
- }
- return ChatColor.WHITE;
- }
- public ChatColor EstateColor(Estate thisEstate){
- if(thisEstate == Estate.Miner){
- return ChatColor.GREEN;
- } else if(thisEstate == Estate.Officer){
- return ChatColor.BLUE;
- } else if(thisEstate == Estate.Trader){
- return ChatColor.GOLD;
- } else if(thisEstate == Estate.Builder){
- return ChatColor.DARK_GRAY;
- }
- return ChatColor.WHITE;
- }
- public String getNextEstate(){
- String thisEstate = getGroup();
- String nextEstate = null;
- if(thisEstate != null){
- if(thisEstate.equalsIgnoreCase("default")){
- return nextEstate;
- }
- if(plugin.trader.contains(thisEstate)){
- if(plugin.trader.indexOf(thisEstate) == 3) return null;
- nextEstate = plugin.trader.get(plugin.trader.indexOf(thisEstate) + 1);
- } else if(plugin.builder.contains(thisEstate)){
- if(plugin.builder.indexOf(thisEstate) == 3) return null;
- nextEstate = plugin.builder.get(plugin.builder.indexOf(thisEstate) + 1);
- } else if(plugin.miner.contains(thisEstate)){
- if(plugin.miner.indexOf(thisEstate) == 3) return null;
- nextEstate = plugin.miner.get(plugin.miner.indexOf(thisEstate) + 1);
- } else if(plugin.officer.contains(thisEstate)){
- if(plugin.officer.indexOf(thisEstate) == 3) return null;
- nextEstate = plugin.officer.get(plugin.officer.indexOf(thisEstate) + 1);
- }
- }
- return nextEstate;
- }
- public int rankUpPrice(){
- int Price = -1;
- String thisEstate = getGroup();
- if(thisEstate != null){
- if(thisEstate.equalsIgnoreCase("default")){
- Price = 4000;
- } else if(plugin.lvl1.contains(thisEstate)){
- Price = 50000;
- } else if(plugin.lvl2.contains(thisEstate)){
- Price = 200000;
- } else if(plugin.lvl3.contains(thisEstate)){
- Price = 500000;
- } else {
- Price = -1;
- }
- return Price;
- } else {
- return -1;
- }
- }
- public int changePrice(){
- int Price = -1;
- String thisEstate = getGroup();
- if(thisEstate != null){
- if(thisEstate.equalsIgnoreCase("default")){
- Price = -1;
- } else if(plugin.lvl1.contains(thisEstate)){
- Price = 3000;
- } else if(plugin.lvl2.contains(thisEstate)){
- Price = 10000;
- } else if(plugin.lvl3.contains(thisEstate)){
- Price = 25000;
- } else if(plugin.lvl4.contains(thisEstate)){
- Price = 50000;
- } else return -1;
- } else return -1;
- return Price;
- }
- public boolean canLevel(){
- String thisEstate = getGroup();
- if(thisEstate != null){
- if(thisEstate.equalsIgnoreCase("default")){
- return false;
- } else if(plugin.lvl1.contains(thisEstate)){
- return true;
- } else if(plugin.lvl2.contains(thisEstate)){
- return true;
- } else if(plugin.lvl3.contains(thisEstate)){
- return true;
- } else return false;
- } else return false;
- }
- public boolean isAtGod(){
- String thisEstate = getGroup();
- String cEstate;
- if(plugin.lEst.contains(thisEstate)){
- cEstate = plugin.cEst.get(plugin.lEst.indexOf(thisEstate));
- } else {
- return false;
- }
- List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
- if(strIDs.contains("officerestate")){
- if(!plugin.officer.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
- player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- player.sendMessage("You are in the " + cEstate + " estate, this is the Officer rankUp area");
- player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
- player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- return false;
- } else {
- return true;
- }
- } else if (strIDs.contains("minerestate")) {
- if(!plugin.miner.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
- player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- player.sendMessage("Your are in the " + cEstate + " estate, this is the Miners rankUp area");
- player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
- player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- return false;
- } else {
- return true;
- }
- } else if(strIDs.contains("builderestate")){
- if(!plugin.builder.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
- player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- player.sendMessage("You are in the " + cEstate + " estate, this is the Builder rankUp area");
- player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
- player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- return false;
- } else {
- return true;
- }
- } else if(strIDs.contains("traderestate")){
- if(!plugin.trader.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
- player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- player.sendMessage("You are in the " + cEstate + " estate, this is the Trader rankUp area");
- player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
- player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
- player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
- return false;
- } else {
- return true;
- }
- } else {
- player.sendMessage(ChatColor.DARK_RED + "You need to be in the presence of an estate god to do this!");
- return false;
- }
- }
- public boolean isAtSpecificGod(String Estate){
- List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
- List<String> tmp = Arrays.asList("officer", "miner", "builder", "trader");
- return strIDs.contains(plugin.zIDs.get(tmp.indexOf(Estate.toLowerCase())));
- }
- public boolean isAtGodExcept(){
- String Est = getGroup();
- if(Est == null) return false;
- List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
- List<String> tmp = Arrays.asList("officer", "miner", "builder", "trader");
- List<String> tmpZ = Arrays.asList("officerestate" , "minerestate" , "builderestate" , "traderestate");
- if(!tmp.contains(Est)){
- return false;
- }
- tmpZ.remove(tmp.indexOf(Est));
- for(int i = 0; i < 4; i++){
- if(strIDs.contains(tmpZ.get(i))) return true;
- }
- return false;
- }
- public Estate getApplicableGod(){
- List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
- List<Estate> tmp = Arrays.asList(Estate.Officer, Estate.Miner, Estate.Builder, Estate.Trader);
- List<String> tmpZ = Arrays.asList("officerestate" , "minerestate" , "builderestate" , "traderestate");
- for(int i = 0; i < strIDs.size(); i++){
- for(int d = 0; d < tmpZ.size(); d++){
- if(strIDs.get(i).equals(tmpZ.get(d))){
- return tmp.get(tmpZ.indexOf(d));
- }
- }
- }
- return null;
- }
- public double getCurrentCN(){
- return plugin.iCon.getAccount(player.getName()).getHoldings().balance();
- }
- public boolean hasUsedChange(Estate estate){
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement