aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/skyblock/RaffleTaskHighlight.java
blob: 63c44adbb5e527772fd81b320a138e1b2c36a35b (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
package de.hysky.skyblocker.skyblock;

import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.container.SimpleContainerSolver;
import de.hysky.skyblocker.utils.render.gui.ColorHighlight;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import it.unimi.dsi.fastutil.objects.ObjectSet;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;

import java.util.List;

public class RaffleTaskHighlight extends SimpleContainerSolver {
	public RaffleTaskHighlight() {
		super("Daily Tasks");
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

	@Override
	public List<ColorHighlight> getColors(Int2ObjectMap<ItemStack> slots) {
		ObjectArrayList<ColorHighlight> highlights = new ObjectArrayList<>(21); // There are 21 paper slots, and they are either complete or incomplete, so we're guaranteed to need 21 highlights

		ObjectSet<Entry<ItemStack>> set = slots.int2ObjectEntrySet();
		for (Entry<ItemStack> entry : set) {
			ItemStack itemStack = entry.getValue();
			if (!itemStack.isOf(Items.PAPER) && !itemStack.isOf(Items.MAP) && !itemStack.isOf(Items.FILLED_MAP)) continue;
			List<Text> lore = ItemUtils.getLore(itemStack);
			if (lore.isEmpty()) continue;
			switch (lore.getLast().getString()) {
				case "COMPLETE" -> highlights.add(ColorHighlight.green(entry.getIntKey()));
				case "INCOMPLETE" -> highlights.add(ColorHighlight.red(entry.getIntKey()));
			}
		}

		return highlights;
	}
}