aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/gui')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java88
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java4
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java36
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java12
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java4
5 files changed, 113 insertions, 31 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
index ca02eec..a9ccb71 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
@@ -1,7 +1,6 @@
package dev.mayaqq.ygasi.gui;
-import dev.mayaqq.ygasi.util.GetAdvancementProgress;
-import dev.mayaqq.ygasi.util.GrantAdvancementCriterion;
+import dev.mayaqq.ygasi.util.YgasiUtils;
import eu.pb4.sgui.api.elements.*;
import net.minecraft.item.ItemStack;
@@ -50,9 +49,9 @@ public class BranchGui {
}
//branch items
- if (!GetAdvancementProgress.get(player, "mercenary")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "mercenary")) {
gui.setSlot(11, new GuiElementBuilder()
- .setItem(Items.IRON_SWORD)
+ .setItem(Items.DIAMOND_SWORD)
.setCustomModelData(1)
.hideFlag(ItemStack.TooltipSection.MODIFIERS)
.addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY)))
@@ -62,7 +61,7 @@ public class BranchGui {
);
} else {
gui.setSlot(11, new GuiElementBuilder()
- .setItem(Items.IRON_SWORD)
+ .setItem(Items.DIAMOND_SWORD)
.hideFlag(ItemStack.TooltipSection.MODIFIERS)
.glow()
.setName(Text.literal("Mercenary")
@@ -71,7 +70,7 @@ public class BranchGui {
);
}
- if (!GetAdvancementProgress.get(player, "wizardry")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "wizardry")) {
gui.setSlot(13, new GuiElementBuilder()
.setItem(Items.BLAZE_ROD)
.addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY)))
@@ -89,7 +88,7 @@ public class BranchGui {
);
}
- if (!GetAdvancementProgress.get(player, "druidry")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "druidry")) {
gui.setSlot(15, new GuiElementBuilder()
.setItem(Items.OAK_SAPLING)
.addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY)))
@@ -106,7 +105,33 @@ public class BranchGui {
.setCallback((index, clickType, actionType) -> DruidryGui.gui(player))
);
}
- GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu");
+
+ if (!YgasiUtils.getAdvancementProgress(player, "extra")) {
+ gui.setSlot(26, new GuiElementBuilder()
+ .setItem(Items.BOOK)
+ .addLoreLine(Text.literal("Cost: " + ConfigRegistry.CONFIG.branchCost / 2).setStyle(Style.EMPTY.withFormatting(Formatting.DARK_GRAY)))
+ .setName(Text.literal("Extra")
+ .setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.BLUE)))
+ .setCallback((index, clickType, actionType) -> save(player, "extra", "§9Extra Skills"))
+ );
+ } else {
+ gui.setSlot(26, new GuiElementBuilder()
+ .setItem(Items.BOOK)
+ .glow()
+ .setName(Text.literal("Extra Skills")
+ .setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.BLUE)))
+ .setCallback((index, clickType, actionType) -> ExtraGui.gui(player))
+ );
+ }
+
+ //info item
+ gui.setSlot(18, new GuiElementBuilder()
+ .setItem(Items.PAPER)
+ .setName(Text.literal("Info").formatted(Formatting.GOLD).formatted(Formatting.BOLD))
+ .setCallback((index, clickType, actionType) -> infoMessage(player))
+ );
+
+ YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu");
gui.open();
} catch (Exception e) {
@@ -114,24 +139,39 @@ public class BranchGui {
}
}
public static void save(ServerPlayerEntity player, String branch, String branchName) {
- if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost) {
- player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost);
- player.sendMessage(Text.of("You have selected the §a" + branchName + " §fbranch!"), false);
- player.closeHandledScreen();
- if (branch.equals("mercenary")) {
- GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/mercenary"), "unlocked_mercenary");
- MercenaryGui.gui(player);
- } else if (branch.equals("wizardry")) {
- GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/wizardry"), "unlocked_wizardry");
- WizardryGui.gui(player);
- } else if (branch.equals("druidry")) {
- GrantAdvancementCriterion.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/druidry"), "unlocked_druidry");
- DruidryGui.gui(player);
+ if (branch.equals("extra")) {
+ if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost / 2) {
+ player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost / 2);
+ YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/extra"), "unlocked_extra");
+ player.sendMessage(Text.of("§aYou have unlocked the " + branchName + " branch!"), false);
+ ExtraGui.gui(player);
+ } else {
+ player.sendMessage(Text.of("§cYou do not have enough skill points to unlock this branch!"), false);
}
-
} else {
- player.sendMessage(Text.translatable("gui.ygasi.no.skill").setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.RED)), false);
- player.closeHandledScreen();
+ if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost) {
+ player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost);
+ player.sendMessage(Text.of("You have selected the §a" + branchName + " §fbranch!"), false);
+ player.closeHandledScreen();
+ if (branch.equals("mercenary")) {
+ YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/mercenary"), "unlocked_mercenary");
+ MercenaryGui.gui(player);
+ } else if (branch.equals("wizardry")) {
+ YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/wizardry"), "unlocked_wizardry");
+ WizardryGui.gui(player);
+ } else if (branch.equals("druidry")) {
+ YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/druidry"), "unlocked_druidry");
+ DruidryGui.gui(player);
+ }
+
+ } else {
+ player.sendMessage(Text.translatable("gui.ygasi.no.skill").setStyle(Style.EMPTY.withBold(true).withFormatting(Formatting.RED)), false);
+ player.closeHandledScreen();
+ }
}
}
+ public static void infoMessage(ServerPlayerEntity player) {
+ player.closeHandledScreen();
+ player.sendMessage(Text.translatable("gui.ygasi.info.main"), false);
+ }
} \ No newline at end of file
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java
index d2be67e..dc5e5e7 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java
@@ -1,6 +1,6 @@
package dev.mayaqq.ygasi.gui;
-import dev.mayaqq.ygasi.util.GetAdvancementProgress;
+import dev.mayaqq.ygasi.util.YgasiUtils;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
@@ -13,7 +13,7 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
public class DruidryGui {
public static void gui(ServerPlayerEntity player) {
try {
- if (!GetAdvancementProgress.get(player, "druidry")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "druidry")) {
player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false);
BranchGui.gui(player);
} else {
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java
new file mode 100644
index 0000000..98ca697
--- /dev/null
+++ b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java
@@ -0,0 +1,36 @@
+package dev.mayaqq.ygasi.gui;
+
+import dev.mayaqq.ygasi.util.YgasiUtils;
+import eu.pb4.sgui.api.elements.GuiElementBuilder;
+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 static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
+
+public class ExtraGui {
+ public static void gui(ServerPlayerEntity player) {
+ try {
+ if (!YgasiUtils.getAdvancementProgress(player, "extra")) {
+ player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false);
+ BranchGui.gui(player);
+ } else {
+ SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X3, player, false) {};
+
+ gui.setTitle(Text.of( "§9§lExtra " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))));
+
+ for (int x = 0; x <= 26; x++) {
+ gui.setSlot(x, new GuiElementBuilder()
+ .setItem(Items.GRAY_STAINED_GLASS_PANE)
+ .setName(Text.of(" "))
+ );
+ }
+ gui.open();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java
index ea75c43..79cc08d 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java
@@ -1,6 +1,6 @@
package dev.mayaqq.ygasi.gui;
-import dev.mayaqq.ygasi.util.GetAdvancementProgress;
+import dev.mayaqq.ygasi.util.YgasiUtils;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
@@ -13,14 +13,14 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
public class MercenaryGui {
public static void gui(ServerPlayerEntity player) {
try {
- if (!GetAdvancementProgress.get(player, "mercenary")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "mercenary")) {
player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false);
BranchGui.gui(player);
} else {
SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X6, player, false) {};
gui.setTitle(Text.of( "§c§lMercenary " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))));
-
+ //background items
for (int x = 0; x <= 53; x++) {
gui.setSlot(x, new GuiElementBuilder()
.setItem(Items.GRAY_STAINED_GLASS_PANE)
@@ -28,6 +28,12 @@ public class MercenaryGui {
);
}
+ //skill items
+ gui.setSlot(49, new GuiElementBuilder()
+ .setItem(Items.DIAMOND_BLOCK)
+ .setName(Text.of("§c§lMercenary Unlocked!"))
+ .addLoreLine(Text.of("§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))))
+ );
gui.open();
}
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java
index f5ae47f..d049e5a 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java
@@ -1,6 +1,6 @@
package dev.mayaqq.ygasi.gui;
-import dev.mayaqq.ygasi.util.GetAdvancementProgress;
+import dev.mayaqq.ygasi.util.YgasiUtils;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
@@ -13,7 +13,7 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS;
public class WizardryGui {
public static void gui(ServerPlayerEntity player) {
try {
- if (!GetAdvancementProgress.get(player, "wizardry")) {
+ if (!YgasiUtils.getAdvancementProgress(player, "wizardry")) {
player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false);
BranchGui.gui(player);
} else {