Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.33 KB | None | 0 0
  1. package me.Ghappy.EstateRanker;
  2.  
  3. import com.sk89q.worldedit.Vector;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.entity.Player;
  8.  
  9. public class ERPlayer {
  10.     public static EstateRanker plugin;
  11.     private Player player;
  12.     public enum Estate {Builder, Trader, Miner, Officer};
  13.     public ERPlayer(Player p, EstateRanker e){
  14.         player = p;
  15.         plugin = e;
  16.     }
  17.     private String getGroup(){
  18.         String[] groups;
  19.         String thisEstate = null;
  20.         groups = plugin.Permissions.getUser(player.getName()).getGroupsNames();
  21.         for(int i = 0; i < groups.length; i++){
  22.             if(plugin.lEst.contains(groups[i].toLowerCase())){
  23.                 if(thisEstate != null){
  24.                     if(plugin.trader.contains(thisEstate)){
  25.                         if(plugin.trader.indexOf(groups[i]) > plugin.trader.indexOf(thisEstate)){
  26.                             thisEstate = groups[i];
  27.                         }
  28.                     } else if(plugin.miner.contains(thisEstate)){
  29.                         if(plugin.miner.indexOf(groups[i]) > plugin.miner.indexOf(thisEstate)){
  30.                             thisEstate = groups[i];
  31.                         }
  32.                     } else if(plugin.builder.contains(thisEstate)){
  33.                         if(plugin.builder.indexOf(groups[i]) > plugin.builder.indexOf(thisEstate)){
  34.                             thisEstate = groups[i];
  35.                         }
  36.                     } else if(plugin.officer.contains(thisEstate)){
  37.                         if(plugin.officer.indexOf(groups[i]) > plugin.officer.indexOf(thisEstate)){
  38.                             thisEstate = groups[i];
  39.                         }
  40.                     }
  41.                 } else {
  42.                     thisEstate = groups[i];
  43.                 }
  44.             }
  45.         }
  46.         return thisEstate.toLowerCase();
  47.     }
  48.     public String getEstate(){
  49.         return getGroup();
  50.     }
  51.     public ChatColor EstateColor(){
  52.         String thisEstate = getGroup();
  53.         if(plugin.miner.contains(thisEstate)){
  54.             return ChatColor.GREEN;
  55.         } else if(plugin.officer.contains(thisEstate)){
  56.             return ChatColor.BLUE;
  57.         } else if(plugin.trader.contains(thisEstate)){
  58.             return ChatColor.GOLD;
  59.         } else if(plugin.builder.contains(thisEstate)){
  60.             return ChatColor.DARK_GRAY;
  61.         }
  62.         return ChatColor.WHITE;
  63.     }
  64.     public ChatColor EstateColor(Estate thisEstate){
  65.         if(thisEstate == Estate.Miner){
  66.             return ChatColor.GREEN;
  67.         } else if(thisEstate == Estate.Officer){
  68.             return ChatColor.BLUE;
  69.         } else if(thisEstate == Estate.Trader){
  70.             return ChatColor.GOLD;
  71.         } else if(thisEstate == Estate.Builder){
  72.             return ChatColor.DARK_GRAY;
  73.         }
  74.         return ChatColor.WHITE;
  75.     }
  76.     public String getNextEstate(){
  77.         String thisEstate = getGroup();
  78.         String nextEstate = null;
  79.  
  80.         if(thisEstate != null){
  81.             if(thisEstate.equalsIgnoreCase("default")){
  82.                 return nextEstate;
  83.             }
  84.             if(plugin.trader.contains(thisEstate)){
  85.                 if(plugin.trader.indexOf(thisEstate) == 3) return null;
  86.                 nextEstate = plugin.trader.get(plugin.trader.indexOf(thisEstate) + 1);
  87.             } else if(plugin.builder.contains(thisEstate)){
  88.                 if(plugin.builder.indexOf(thisEstate) == 3) return null;
  89.                 nextEstate = plugin.builder.get(plugin.builder.indexOf(thisEstate) + 1);
  90.             } else if(plugin.miner.contains(thisEstate)){
  91.                 if(plugin.miner.indexOf(thisEstate) == 3) return null;
  92.                 nextEstate = plugin.miner.get(plugin.miner.indexOf(thisEstate) + 1);
  93.             } else if(plugin.officer.contains(thisEstate)){
  94.                 if(plugin.officer.indexOf(thisEstate) == 3) return null;
  95.                 nextEstate = plugin.officer.get(plugin.officer.indexOf(thisEstate) + 1);
  96.             }
  97.         }
  98.         return nextEstate;
  99.     }
  100.     public int rankUpPrice(){
  101.         int Price = -1;
  102.         String thisEstate = getGroup();
  103.         if(thisEstate != null){
  104.             if(thisEstate.equalsIgnoreCase("default")){
  105.                 Price = 4000;
  106.             } else if(plugin.lvl1.contains(thisEstate)){
  107.                 Price = 50000;
  108.             } else if(plugin.lvl2.contains(thisEstate)){
  109.                 Price = 200000;
  110.             } else if(plugin.lvl3.contains(thisEstate)){
  111.                 Price = 500000;
  112.             } else {
  113.                 Price = -1;
  114.             }
  115.             return Price;
  116.         } else {
  117.             return -1;
  118.         }
  119.     }
  120.     public int changePrice(){
  121.         int Price = -1;
  122.         String thisEstate = getGroup();
  123.         if(thisEstate != null){
  124.            if(thisEstate.equalsIgnoreCase("default")){
  125.                 Price = -1;
  126.             } else if(plugin.lvl1.contains(thisEstate)){
  127.                 Price = 3000;
  128.             } else if(plugin.lvl2.contains(thisEstate)){
  129.                 Price = 10000;
  130.             } else if(plugin.lvl3.contains(thisEstate)){
  131.                 Price = 25000;
  132.             } else if(plugin.lvl4.contains(thisEstate)){
  133.                 Price = 50000;
  134.             } else return -1;
  135.         } else return -1;
  136.         return Price;
  137.     }
  138.     public boolean canLevel(){
  139.         String thisEstate = getGroup();
  140.         if(thisEstate != null){
  141.             if(thisEstate.equalsIgnoreCase("default")){
  142.                 return false;
  143.             } else if(plugin.lvl1.contains(thisEstate)){
  144.                 return true;
  145.             } else if(plugin.lvl2.contains(thisEstate)){
  146.                 return true;
  147.             } else if(plugin.lvl3.contains(thisEstate)){
  148.                 return true;
  149.             } else return false;
  150.         } else return false;
  151.     }
  152.     public boolean isAtGod(){
  153.         String thisEstate = getGroup();
  154.         String cEstate;
  155.         if(plugin.lEst.contains(thisEstate)){
  156.             cEstate = plugin.cEst.get(plugin.lEst.indexOf(thisEstate));
  157.         } else {
  158.             return false;
  159.         }
  160.         List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
  161.         if(strIDs.contains("officerestate")){
  162.                 if(!plugin.officer.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
  163.                     player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
  164.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  165.                     player.sendMessage("You are in the " + cEstate + " estate, this is the Officer rankUp area");
  166.                     player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
  167.                     player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
  168.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  169.                     return false;
  170.                 } else {
  171.                     return true;
  172.                 }
  173.             } else if (strIDs.contains("minerestate")) {
  174.                 if(!plugin.miner.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
  175.                     player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
  176.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  177.                     player.sendMessage("Your are in the " + cEstate + " estate, this is the Miners rankUp area");
  178.                     player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
  179.                     player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
  180.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  181.                     return false;
  182.                 } else {
  183.                     return true;
  184.                 }
  185.             } else if(strIDs.contains("builderestate")){
  186.                 if(!plugin.builder.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
  187.                     player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
  188.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  189.                     player.sendMessage("You are in the " + cEstate + " estate, this is the Builder rankUp area");
  190.                     player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
  191.                     player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
  192.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  193.                     return false;
  194.                 } else {
  195.                     return true;
  196.                 }
  197.             } else if(strIDs.contains("traderestate")){
  198.                 if(!plugin.trader.contains(thisEstate) && !thisEstate.equalsIgnoreCase("default")){
  199.                     player.sendMessage(ChatColor.DARK_AQUA + "~ Creation Nation RankUp ~");
  200.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  201.                     player.sendMessage("You are in the " + cEstate + " estate, this is the Trader rankUp area");
  202.                     player.sendMessage("You must use the " + cEstate + " RankUp area to rank up");
  203.                     player.sendMessage("Or you can use " + ChatColor.GREEN + "'/RankChange Info'" + ChatColor.WHITE + " For info on changing Estates");
  204.                     player.sendMessage(ChatColor.GOLD + "--------------------------------------------");
  205.                     return false;
  206.                 } else {
  207.                     return true;
  208.                 }
  209.             } else {
  210.                 player.sendMessage(ChatColor.DARK_RED + "You need to be in the presence of an estate god to do this!");
  211.                 return false;
  212.             }
  213.     }
  214.     public boolean isAtSpecificGod(String Estate){
  215.         List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
  216.         List<String> tmp = Arrays.asList("officer", "miner", "builder", "trader");
  217.         return strIDs.contains(plugin.zIDs.get(tmp.indexOf(Estate.toLowerCase())));
  218.     }
  219.     public boolean isAtGodExcept(){
  220.         String Est = getGroup();
  221.         if(Est == null) return false;
  222.         List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
  223.         List<String> tmp = Arrays.asList("officer", "miner", "builder", "trader");
  224.         List<String> tmpZ = Arrays.asList("officerestate" , "minerestate" , "builderestate" , "traderestate");
  225.         if(!tmp.contains(Est)){
  226.             return false;
  227.         }
  228.         tmpZ.remove(tmp.indexOf(Est));
  229.         for(int i = 0; i < 4; i++){
  230.             if(strIDs.contains(tmpZ.get(i))) return true;
  231.         }
  232.         return false;
  233.     }
  234.     public Estate getApplicableGod(){
  235.         List<String> strIDs = plugin.worldguard.getGlobalRegionManager().get(player.getWorld()).getApplicableRegionsIDs(new Vector(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()));
  236.         List<Estate> tmp = Arrays.asList(Estate.Officer, Estate.Miner, Estate.Builder, Estate.Trader);
  237.         List<String> tmpZ = Arrays.asList("officerestate" , "minerestate" , "builderestate" , "traderestate");
  238.         for(int i = 0; i < strIDs.size(); i++){
  239.             for(int d = 0; d < tmpZ.size(); d++){
  240.                 if(strIDs.get(i).equals(tmpZ.get(d))){
  241.                     return tmp.get(tmpZ.indexOf(d));
  242.                 }
  243.             }
  244.         }
  245.         return null;
  246.     }
  247.     public double getCurrentCN(){
  248.         return plugin.iCon.getAccount(player.getName()).getHoldings().balance();
  249.     }
  250.     public boolean hasUsedChange(Estate estate){
  251.  
  252.         return true;
  253.     }
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement