aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java
blob: 5c95eb28eb6e190272eb48084184c6a3d1c05e3a (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
package dev.mayaqq.ygasi.gui;

import dev.mayaqq.ygasi.registry.PlayerDataRegistry;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.stat.Stats;
import net.minecraft.text.Text;

import java.util.UUID;

import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;

public class MercenaryGui {
    public static void gui(ServerPlayerEntity player) {
        try {
            UUID playerUUID = player.getUuid();
            PlayerDataRegistry.load(playerUUID);
            if (PlayerDataRegistry.PLAYERDATA.branches.get("mercenary") == null || !PlayerDataRegistry.PLAYERDATA.branches.get("mercenary")) {
                player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false);
                BranchGui.gui(player);
            } else {
                SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X6, player, false) {};

                gui.setTitle(Text.of( "§c§lMercenary " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))));

                for (int x = 0; x <= 53; x++) {
                    gui.setSlot(x, new GuiElementBuilder()
                            .setItem(Items.GRAY_STAINED_GLASS_PANE)
                            .setName(Text.of(" "))
                    );
                }
                gui.open();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}