blob: 616032d5ef2012093453bd562d05059b1ca442e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
package de.cowtipper.cowlection.chesttracker.data;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
public class ItemData {
private final String key;
private final ItemStack itemStack;
private final String name;
private int amount;
private double bazaarInstantSellPrice = 0;
private double bazaarSellOfferPrice = 0;
private int lowestBin = 0;
private double npcPrice = 0;
private PriceType priceType;
private boolean isHidden = false;
public ItemData(String key, ItemStack itemStack) {
this.key = key;
this.itemStack = itemStack;
this.itemStack.stackSize = 1;
this.name = itemStack.getDisplayName();
this.amount = 0;
this.priceType = PriceType.NONE;
}
public String getKey() {
return key;
}
public ItemStack getItemStack() {
return itemStack;
}
public String getName() {
return name;
}
public int getAmount() {
return amount;
}
public double getPrice(boolean useInstantSellPrices) {
switch (priceType) {
case BAZAAR:
return useInstantSellPrices ? bazaarInstantSellPrice : bazaarSellOfferPrice;
case LOWEST_BIN:
return lowestBin;
case NPC_SELL:
return npcPrice;
default:
return 0;
}
}
public double getPriceSum(boolean useInstantSellPrices) {
switch (priceType) {
case BAZAAR:
return useInstantSellPrices ? getBazaarInstantSellValue() : getBazaarSellOfferValue();
case LOWEST_BIN:
return getLowestBinValue();
case NPC_SELL:
return getNpcSellValue();
default:
return 0;
}
}
public void setBazaarInstantSellPrice(double bazaarInstantSellPrice) {
this.bazaarInstantSellPrice = bazaarInstantSellPrice;
this.priceType = PriceType.BAZAAR;
}
public void setBazaarSellOfferPrice(double bazaarSellOfferPrice) {
this.bazaarSellOfferPrice = bazaarSellOfferPrice;
this.priceType = PriceType.BAZAAR;
}
public void setLowestBin(int lowestBin) {
this.lowestBin = lowestBin;
this.priceType = PriceType.LOWEST_BIN;
}
public void setNpcPrice(double npcPrice) {
this.npcPrice = npcPrice;
this.priceType = PriceType.NPC_SELL;
}
public ItemData addAmount(int stackSize) {
this.amount += stackSize;
return this;
}
public double getBazaarInstantSellValue() {
return amount * bazaarInstantSellPrice;
}
public double getBazaarSellOfferValue() {
return amount * bazaarSellOfferPrice;
}
public long getLowestBinValue() {
return (long) amount * lowestBin;
}
public long getNpcSellValue() {
return (long) Math.floor((long) amount * npcPrice);
}
public PriceType getPriceType() {
return priceType;
}
public boolean isHidden() {
return isHidden;
}
public void setHidden(boolean hidden) {
isHidden = hidden;
}
public String toCopyableFormat() {
return "\n" + EnumChatFormatting.getTextWithoutFormattingCodes(name) + "\t" + name + "\t" + amount + "\t"
+ toCopyableFormat(bazaarInstantSellPrice) + "\t" + toCopyableFormat(getBazaarInstantSellValue()) + "\t"
+ toCopyableFormat(bazaarSellOfferPrice) + "\t" + toCopyableFormat(getBazaarSellOfferValue()) + "\t"
+ toCopyableFormat(lowestBin) + "\t" + toCopyableFormat(getLowestBinValue()) + "\t"
+ toCopyableFormat(npcPrice) + "\t" + toCopyableFormat(getNpcSellValue());
}
private String toCopyableFormat(double value) {
return value > 0 ? Long.toString(Math.round(value)) : "";
}
public enum PriceType {
LOWEST_BIN("BIN"), BAZAAR("BZ"), NPC_SELL("NPC"), NONE("-");
private final String indicator;
PriceType(String indicator) {
this.indicator = indicator;
}
public String getIndicator() {
return indicator;
}
}
}
|