User:RolandOfGilead/Java/Drop Rate Tool/DropRate.java

import java.awt.Color; public class DropRate { String name; IntWrapper gold= new IntWrapper(0); IntWrapper goldTotal= new IntWrapper(0); IntWrapper 	equipG= new IntWrapper(0); IntWrapper equipP= new IntWrapper(0); IntWrapper equipB= new IntWrapper(0); IntWrapper equipW= new IntWrapper(0); IntWrapper salvageG= new IntWrapper(0); IntWrapper salvageP= new IntWrapper(0); IntWrapper salvageB= new IntWrapper(0); IntWrapper salvageW= new IntWrapper(0); IntWrapper craftingR= new IntWrapper(0); IntWrapper craftingC= new IntWrapper(0); IntWrapper key= new IntWrapper(0); IntWrapper collectible= new IntWrapper(0); IntWrapper dye= new IntWrapper(0); IntWrapper other= new IntWrapper(0); IntWrapper nothing= new IntWrapper(0); IntWrapper golds[] = {gold}; IntWrapper equip[] = {equipG, equipP, equipB, equipW}; IntWrapper salvage[] = {salvageG, salvageP, salvageB, salvageW}; IntWrapper crafting[] = {craftingR, craftingC}; IntWrapper keys[] = {key}; IntWrapper collectibles[] = {collectible}; IntWrapper dyes[] = {dye}; IntWrapper others[] = {other}; IntWrapper nothings[] = {nothing}; IntWrapper total [][] = {golds, equip, salvage, crafting, keys, collectibles, dyes, o thers, nothings}; String goldString= "Gold"; String equipString= "Equip Items"; String salvageString= "Salvage Items"; String craftingString= "Crafting Materials"; String keyString= "Keys"; String collectibleString= "Collectibles"; String dyeString= "Vials of Dye"; String otherString= "Other"; String nothingString= "Nothing"; String totalString[] = {goldString, equipString, salvageString, craftingString, keyString, collectibleString, dyeString, otherString, nothingString}; String rarities4[] = {"G", "P", "B", "W"}; String rarities2[] = {"R", "C"}; Color color4[] = {new Color(200, 200, 0), Color.BLUE, new Color(128, 0, 255), Color.DARK_GRAY}; Color color 2[] = {color4[0], color4[3]}; public DropRate(String n) { name = n; 	} public void reset { for(int i=0; i!=total.length; ++i) for(int j=0; j!=total[i].length; ++j) { total[i][j].in = 0; } 	} 	public String getTable(int accuracy) { int sum = 0; StringBuffer header = new StringBuffer("{" + "{DropDataHeader|" + name + "}}\n"); StringBuffer body = new StringBuffer("{" + "{DropDataBody|"); StringBuffer perc = new StringBuffer("{" + "{DropDataPerc"); for(int i=0; i!=total.length; ++i) { if(total[i].length>1) { int temp=0; for(int j=0; j!=total[i].length; ++j) temp += total[i][j].in; body.append(temp + "|"); } 			for(int j=0; j!=total[i].length; ++j) { body.append(total[i][j].in + "|"); sum += total[i][j].in; } 		} 		body.append(sum + "|" + "}}\n"); Float f; 		for(int i=0; i!=total.length; ++i) { f = new Float(0); for(int j=0; j!=total[i].length; ++j) { f += total[i][j].in; } 			f*=100; f /= sum; String fl = f.toString; if(fl.equalsIgnoreCase("NaN")) fl = "0.0"; int index = Math.max(0, fl.indexOf('.')); fl = fl.substring(0, index+ Math.min(accuracy + (accuracy>0?1:0), fl.substring(index).length) ); f = new Float( fl); perc.append("|" + f); } 		perc.append("}}"); StringBuffer ret = new StringBuffer; ret.append(header).append(body).append(perc); return ret.toString; } }