diff options
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/gui')
7 files changed, 33 insertions, 20 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java index 71be174..d4cb050 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java @@ -18,12 +18,11 @@ import net.minecraft.util.Identifier; public class BranchGui { public static void gui(ServerPlayerEntity player) { - int skillPoints = player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)); - try { SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X3, player, false) {}; - gui.setTitle(Text.translatable("gui.ygasi.branch.title", skillPoints)); + //the title of the gui + gui.setTitle(Text.translatable("gui.ygasi.branch.title", player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))).formatted(Formatting.DARK_AQUA)); //background items for (int x = 0; x <= 26; x++) { @@ -48,6 +47,7 @@ public class BranchGui { } //branch items + //mercenary gui button if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) { gui.setSlot(11, new GuiElementBuilder() .setItem(Items.DIAMOND_SWORD) @@ -67,6 +67,7 @@ public class BranchGui { ); } + //wizardry gui button if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry")) { gui.setSlot(13, new GuiElementBuilder() .setItem(Items.BLAZE_ROD) @@ -83,6 +84,7 @@ public class BranchGui { ); } + //druidry gui button if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry")) { gui.setSlot(15, new GuiElementBuilder() .setItem(Items.OAK_SAPLING) @@ -99,6 +101,7 @@ public class BranchGui { ); } + //extra gui button if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/extra")) { gui.setSlot(26, new GuiElementBuilder() .setItem(Items.BOOK) @@ -115,7 +118,7 @@ public class BranchGui { ); } - //info item + //info item button gui.setSlot(18, new GuiElementBuilder() .setItem(Items.PAPER) .setName(Text.translatable("gui.ygasi.branch.info.title")) @@ -124,7 +127,7 @@ public class BranchGui { player.sendMessage(Text.translatable("gui.ygasi.branch.info.main"), false); }) ); - //reset item + //reset item button gui.setSlot(8, new GuiElementBuilder() .setItem(Items.BARRIER) .setName(Text.translatable("gui.ygasi.branch.reset.title")) @@ -133,6 +136,7 @@ public class BranchGui { .setCallback((index, clickType, actionType) -> ResetGui.gui(player)) ); + //grant the player the root advancement of ygasi YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu"); gui.open(); @@ -140,7 +144,9 @@ public class BranchGui { e.printStackTrace(); } } + //this happens when you try to unlock a branch public static void save(ServerPlayerEntity player, String branch, String branchName) { + //special category for extra branch because it's half the price 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); @@ -150,11 +156,14 @@ public class BranchGui { } else { player.sendMessage(Text.translatable("gui.ygasi.branch.no.skill"), false); } + //the rest of the branches } else { + //same code as in extra 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.translatable("gui.ygasi.branch.unlock", Text.translatable(branchName)), false); player.closeHandledScreen(); + //grant the player the advancement of the branch they unlocked switch (branch) { case "mercenary" -> { YgasiUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/mercenary"), "unlocked_mercenary"); @@ -169,7 +178,7 @@ public class BranchGui { DruidryGui.gui(player); } } - + //if the player doesn't have enough skill points } else { player.sendMessage(Text.translatable("gui.ygasi.branch.no.skill"), false); player.closeHandledScreen(); diff --git a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java index 748f9b3..64e3db3 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java @@ -12,14 +12,15 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class DruidryGui { public static void gui(ServerPlayerEntity player) { + String title = Text.translatable("gui.ygasi.branch.druidry.title").getString() + " " + Text.translatable("gui.ygasi.branch.title", player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))).getString(); try { if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry")) { - player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); + player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), false); BranchGui.gui(player); } else { SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X6, player, false) {}; - gui.setTitle(Text.of( "§a§lDruidry " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))); + gui.setTitle(Text.of(title)); for (int x = 0; x <= 53; x++) { gui.setSlot(x, new GuiElementBuilder() diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java index 04cfc98..268535b 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java @@ -12,14 +12,15 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class ExtraGui { public static void gui(ServerPlayerEntity player) { + String title = Text.translatable("gui.ygasi.branch.extra.title").getString() + " " + Text.translatable("gui.ygasi.branch.title", player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))).getString(); try { if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/extra")) { - player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); + player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), 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)))); + gui.setTitle(Text.of( title)); for (int x = 0; x <= 26; x++) { gui.setSlot(x, new GuiElementBuilder() diff --git a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java index 666c802..43d06ed 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java @@ -1,6 +1,5 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.registry.ConfigRegistry; import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; import net.minecraft.item.Items; @@ -8,19 +7,21 @@ import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.stat.Stats; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class MercenaryGui { public static void gui(ServerPlayerEntity player) { + String title = Text.translatable("gui.ygasi.branch.mercenary.title").getString() + " " + Text.translatable("gui.ygasi.branch.title", player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))).formatted(Formatting.DARK_AQUA).getString(); try { if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) { - player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); + player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), 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)))); + gui.setTitle(Text.of(title)); //background items for (int x = 0; x <= 53; x++) { gui.setSlot(x, new GuiElementBuilder() diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java index 95c8206..a976929 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java @@ -2,7 +2,6 @@ package dev.mayaqq.ygasi.gui; import dev.mayaqq.ygasi.util.YgasiUtils; import eu.pb4.sgui.api.elements.GuiElementBuilder; -import net.minecraft.advancement.Advancement; import net.minecraft.item.Items; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.server.network.ServerPlayerEntity; @@ -29,14 +28,14 @@ public class ResetGui { gui.setSlot(12, new GuiElementBuilder() .setItem(Items.GREEN_CONCRETE) - .setName(Text.translatable("gui.ygasi.reset.confirm")) + .setName(Text.translatable("gui.ygasi.reset.confirm.title")) .addLoreLine(Text.translatable("gui.ygasi.reset.confirm.lore")) .setCallback((index, clickType, actionType) -> reset(player)) ); gui.setSlot(14, new GuiElementBuilder() .setItem(Items.RED_CONCRETE) - .setName(Text.translatable("gui.ygasi.reset.deny")) + .setName(Text.translatable("gui.ygasi.reset.deny.title")) .addLoreLine(Text.translatable("gui.ygasi.reset.deny.lore")) .setCallback((index, clickType, actionType) -> BranchGui.gui(player)) ); @@ -50,11 +49,11 @@ public class ResetGui { player.experienceLevel -= 10; player.closeHandledScreen(); YgasiUtils.revokeAllAdvancements(player, "minecraft", "ygasi/"); - player.sendMessage(Text.translatable("gui.ygasi.branch.reset.main"), false); + player.sendMessage(Text.translatable("gui.ygasi.reset.success"), false); player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))); BranchGui.gui(player); } else { - player.sendMessage(Text.translatable("gui.ygasi.branch.reset.no.xp"), false); + player.sendMessage(Text.translatable("gui.ygasi.reset.fail"), false); player.closeHandledScreen(); } } diff --git a/src/main/java/dev/mayaqq/ygasi/gui/SkillGui.java b/src/main/java/dev/mayaqq/ygasi/gui/SkillGui.java index d12375d..f453379 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/SkillGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/SkillGui.java @@ -7,6 +7,7 @@ import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; public class SkillGui extends SimpleGui { + // I'm doing the onOpen and onClose methods here because I want to play a sound when the gui is opened and closed for all of the guis so I don't have to do it in every gui class public SkillGui(ScreenHandlerType<?> type, ServerPlayerEntity player, boolean manipulatePlayerSlots) { super(type, player, manipulatePlayerSlots); } diff --git a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java index 499f911..9dfc5dc 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java @@ -12,14 +12,15 @@ import static dev.mayaqq.ygasi.registry.StatRegistry.SKILL_POINTS; public class WizardryGui { public static void gui(ServerPlayerEntity player) { + String title = Text.translatable("gui.ygasi.branch.wizardry.title").getString() + " " + Text.translatable("gui.ygasi.branch.title", player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))).getString(); try { if (!YgasiUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry")) { - player.sendMessage(Text.of("§cYou have not unlocked this branch yet!"), false); + player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), false); BranchGui.gui(player); } else { SkillGui gui = new SkillGui(ScreenHandlerType.GENERIC_9X6, player, false) {}; - gui.setTitle(Text.of( "§5§lWizardry " + "§3Skill Points: " + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))); + gui.setTitle(Text.of(title)); for (int x = 0; x <= 53; x++) { gui.setSlot(x, new GuiElementBuilder() |