Advertisement
agentsix1

errr

Jun 27th, 2016
34,201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.19 KB | None | 0 0
  1.     String theRarity = "";
  2.     String theRarityName = "";
  3.     public String getRarityName() {
  4.         Random rn = new Random();
  5.         int itemNumb = 0;
  6.         boolean rarity = false;
  7.         for (int i : getConfig().getIntegerList("Rarity.Settings.Possibility")) {
  8.             int n1 = rn.nextInt(i - 0) + 0;
  9.             int n2 = rn.nextInt(i - 0) + 0;
  10.             if (n1 == n2) {
  11.                 cmdDebug("num 1 " + n1);
  12.                 cmdDebug("num 2 " + n2);
  13.                 cmdDebug("Poss " + i);
  14.                 cmdDebug("rounds " + itemNumb);
  15.                 rarity = true;
  16.                 break;
  17.             }
  18.             itemNumb += 1;
  19.         }
  20.         if (rarity) {
  21.             //List<Integer> Rarities = getConfig().getIntegerList("Rarity.Settings.Possibility");
  22.             List<String> raritiesNames = getConfig().getStringList("Rarity.Settings.Names");
  23.             theRarityName = raritiesNames.get(itemNumb);
  24.             return raritiesNames.get(itemNumb);
  25.         } else {
  26.             theRarityName = getConfig().getString("Rarity.Settings.Default Name");
  27.             return getConfig().getString("Rarity.Settings.Default Name");
  28.            
  29.         }
  30.     }
  31.  
  32.     public boolean detectPossibleITEMS(String rarity) {
  33.         if (Collections.frequency(getConfig().getStringList("Rarity.Items.Item Rarity"), rarity) > 0) {
  34.             return true;
  35.         } else {
  36.             return false;
  37.         }
  38.        
  39.     }
  40.    
  41.     public boolean detectPossibleMONEY(String rarity) {
  42.         if (Collections.frequency(getConfig().getStringList("Rarity.Money.Money Rarity"), rarity) > 0) {
  43.             return true;
  44.         } else {
  45.             return false;
  46.         }
  47.        
  48.     }
  49.    
  50.     public Integer getPrizeItemID(String rarity) {
  51.         Integer id = 0;
  52.         List<Integer> tempItemList = new ArrayList<Integer>();
  53.         for (String a : getConfig().getStringList("Rarity.Items.Item Rarity")) {
  54.             if (a.equals(rarity)) {
  55.                 tempItemList.add(id);
  56.                 cmdDebug("added line!");
  57.             }
  58.             id += 1;
  59.         }
  60.         Random rn = new Random();
  61.         int num = tempItemList.size();
  62.         if (num == 0) {
  63.             return null;
  64.         }
  65.         cmdDebug("size = " + num);
  66.         int output = rn.nextInt(num - 0) + 0;
  67.         return tempItemList.get(output);
  68.     }
  69.    
  70.     public Integer getPrizeMoneyID(String rarity) {
  71.         Integer id = 0;
  72.         List<Integer> tempMoneyList = new ArrayList<Integer>();
  73.         cmdDebug("array created");
  74.         for (String a : getConfig().getStringList("Rarity.Money.Money Rarity")) {
  75.             cmdDebug("Inside For loop - " + id);
  76.             if (a.equals(rarity)) {
  77.                 tempMoneyList.add(id);
  78.                 cmdDebug("added line!");
  79.             }
  80.             id += 1;
  81.         }
  82.         cmdDebug("end of for loop");
  83.         Random rn = new Random();
  84.         int num = tempMoneyList.size();
  85.         cmdDebug("grabbed array size " + num);
  86.         if (num == 0) {
  87.             cmdDebug("Returning null");
  88.             return null;
  89.         }
  90.        
  91.         cmdDebug("size = " + num);
  92.         int output = rn.nextInt(num - 0) + 0;
  93.         cmdDebug("returing output " + output);
  94.         return tempMoneyList.get(output);
  95.     }
  96.    
  97.     public String giveMoneyItem() {
  98.         Random rn = new Random();
  99.         int output = rn.nextInt(2 - 0) + 0;
  100.         if (output >= 1) {
  101.             return "Money";
  102.         } else {
  103.             return "Item";
  104.         }
  105.     }
  106.    
  107.     public String givePlayerPrize(Player p, String type) {
  108.         theRarity = getRarityName();
  109.         cmdDebug("set rarity" + theRarity);
  110.         if (type == "Money") {
  111.             cmdDebug("Chose Money");
  112.             int id = getPrizeMoneyID(theRarity);
  113.             cmdDebug("Money Id set " + id);
  114.             if (detectPossibleMONEY(theRarity)) {
  115.                 cmdDebug("Detected Possible Money");
  116.                 double amount =  new Integer(getConfig().getIntegerList("Rarity.Money.Prizes").get(getPrizeMoneyID(theRarity)));
  117.                 Methods.giveMoney(p, amount, theRarity, getConfig().getString("Messages.Prize Money"), prizes);
  118.                 //Database.addVote_Online(p, rarityMessage(theRarity, p, "$" + amount, "money"));
  119.                 cmdDebug("Vote Complete!");
  120.                 return theRarity + " | " + "$" + amount;
  121.             } else {
  122.                 System.out.println("It appears there was no prize set for your default prizes. Please fix this as soon as possible. Rewarding player with offline vote.");
  123.                 Methods.pSend("A server side error has caused you to not receive a prize. Please contact a admin.", p);
  124.                 //Database.addVote_Offline(p.getName());
  125.                 return null;
  126.             }
  127.         } else if (detectPossibleITEMS(theRarity)) {
  128.             cmdDebug("Detected Possible Item Rarity");
  129.             int id = getPrizeItemID(theRarity);
  130.             cmdDebug("Item Id Set " + id);
  131.             ItemStack addplz = Methods.getItem(p, getConfig().getStringList("Rarity.Items.Item").get(id), id);
  132.             p.getInventory().addItem(addplz);
  133.             rarityMessage(theRarity, p, getConfig().getStringList("Rarity.Items.Item").get(id) + " Amount: " + getConfig().getStringList("Rarity.Items.Amount").get(id), "item", addplz.getItemMeta().getDisplayName().replace("_", " "));
  134.             //Database.addVote_Online(p, rarityMessage(theRarity, p, getConfig().getStringList("Rarity.Items.Item").get(id) + "Amount: " + getConfig().getStringList("Rarity.Items.Amount").get(id), "item"));
  135.             cmdDebug("Item Given Process Complete");
  136.             return theRarity + " | " + getConfig().getStringList("Rarity.Items.Item").get(id) + " Amount: " + getConfig().getStringList("Rarity.Items.Amount").get(id);
  137.         } else {
  138.             System.out.println("It appears there was no prize set for your default prizes. Please fix this as soon as possible. Rewarding player with offline vote. Also you may have both Items and Money disable for votes.");
  139.             Methods.pSend("A server side error has caused you to not receive a prize. Please contact a admin.", p);
  140.             //Database.addVote_Offline(p.getName());
  141.             return null;
  142.         }
  143.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement