mirror of
https://github.com/GTNewHorizons/Baubles-Expanded.git
synced 2026-11-24 22:04:40 +00:00
91 lines
1.9 KiB
Java
91 lines
1.9 KiB
Java
package baubles.api.expanded;
|
|
|
|
import baubles.api.BaubleType;
|
|
|
|
public class BaubleExpandedSlots {
|
|
|
|
public static final int slotLimit = 20;
|
|
|
|
private static String[] slots = new String[slotLimit];
|
|
private static int newSlotsRemaining = slotLimit;
|
|
|
|
public static final String ringType = "ring";
|
|
public static final String amuletType = "amulet";
|
|
public static final String beltType = "belt";
|
|
|
|
static {
|
|
tryAddSlot(amuletType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(beltType);
|
|
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
tryAddSlot(ringType);
|
|
}
|
|
|
|
public static boolean tryAddSlot(String type) {
|
|
//TODO: block after GUI init
|
|
if(newSlotsRemaining >= 1) {
|
|
slots[slotLimit - newSlotsRemaining] = type;
|
|
newSlotsRemaining--;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static boolean tryRemoveSlot(String type) {
|
|
//TODO: block after GUI init
|
|
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
|
|
if(slots[slotToCheck].equals(type)) {
|
|
for(int slotToMove = slotToCheck + 1; slotToMove < slotLimit; slotToMove++) {
|
|
slots[slotToMove - 1] = slots[slotToMove];
|
|
}
|
|
slots[slotLimit - 1] = null;
|
|
newSlotsRemaining++;
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public static int totalCurrentSlotsOfType(String type) {
|
|
int total = 0;
|
|
for(int slotToCheck = 0; slotToCheck < slotLimit; slotToCheck++) {
|
|
if(slots[slotToCheck].equals(type)) {
|
|
total++;
|
|
}
|
|
}
|
|
return total;
|
|
}
|
|
|
|
public static int getTotalSlots() {
|
|
return slotLimit - newSlotsRemaining;
|
|
}
|
|
|
|
public static String getSlotType(int slot) {
|
|
if (slot > 0 & slot < slotLimit) {
|
|
return slots[slot];
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static String getTypeStringFromBaubleType(BaubleType type) {
|
|
switch(type) {
|
|
case RING:
|
|
return ringType;
|
|
case AMULET:
|
|
return amuletType;
|
|
case BELT:
|
|
return beltType;
|
|
}
|
|
return "unknown";
|
|
}
|
|
|
|
}
|