diff options
author | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-20 23:06:47 +0100 |
---|---|---|
committer | Maximusbarcz <maxim.baranek@gmail.com> | 2023-01-20 23:06:47 +0100 |
commit | adaecef7df47ccdbfbda6f438c28696ff1ce8822 (patch) | |
tree | 46397c9d175ca67a69b7033189fec26dd6c6b4ae /src/main/java/dev/mayaqq/ygasi/gui | |
parent | 531bb27e7eb07e08e1e423d0cf01c297fef890f6 (diff) | |
download | ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.tar.gz ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.tar.bz2 ygasi-adaecef7df47ccdbfbda6f438c28696ff1ce8822.zip |
I redid all the advancements and also started work on the second Offence2 ability
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/gui')
8 files changed, 32 insertions, 36 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java index 728f976..3c8e486 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java @@ -57,14 +57,14 @@ public class BranchGui { //branch items //mercenary gui button - if (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/mercenary")) { gui.setSlot(11, new GuiElementBuilder() .setItem(Items.DIAMOND_SWORD) .setCustomModelData(1) .hideFlag(ItemStack.TooltipSection.MODIFIERS) .addLoreLine(Text.translatable("gui.ygasi.branch.cost", cost)) .setName(Text.translatable("gui.ygasi.branch.mercenary.title").formatted(Formatting.BOLD)) - .setCallback((index, clickType, actionType) -> save(player, "mercenary", "gui.ygasi.branch.mercenary.title")) + .setCallback((index, clickType, actionType) -> save(player, "mercenary/mercenary", "gui.ygasi.branch.mercenary.title")) ); } else { gui.setSlot(11, new GuiElementBuilder() @@ -89,7 +89,7 @@ public class BranchGui { /* //wizardry gui button - if (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "wizardry/wizardry")) { gui.setSlot(13, new GuiElementBuilder() .setItem(Items.BLAZE_ROD) .addLoreLine(Text.translatable("gui.ygasi.branch.cost", cost)) @@ -173,7 +173,7 @@ public class BranchGui { } //grant the player the root advancement of ygasi - AdvUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu"); + AdvUtils.grantAdvancementCriterion(player, new Identifier("ygasi", "root"), "opened_skill_menu"); gui.open(); } catch (Exception e) { @@ -182,15 +182,15 @@ public class BranchGui { } //this happens when you try to unlock a branch public static void save(ServerPlayerEntity player, String branch, String branchName) { - boolean hasMercenary = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary"); - boolean hasWizadry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry"); - boolean hasDrudiry = AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry"); + boolean hasMercenary = AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/mercenary"); + boolean hasWizadry = AdvUtils.getAdvancementProgress(player, "ygasi", "wizardry/wizardry"); + boolean hasDrudiry = AdvUtils.getAdvancementProgress(player, "ygasi", "druidry/druidry"); //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) { //remove the spent skill points player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - ConfigRegistry.CONFIG.branchCost / 2); - AdvUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/extra"), "unlocked_extra"); + AdvUtils.grantAdvancementCriterion(player, new Identifier("ygasi", "extra/extra"), "unlocked_extra"); player.sendMessage(Text.translatable("gui.ygasi.branch.unlock", Text.translatable(branchName)), false); ExtraGui.gui(player); } else { @@ -201,19 +201,19 @@ public class BranchGui { if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= ConfigRegistry.CONFIG.branchCost) { //grant the player the advancement of the branch they unlocked final Map<String, Class<?>> BRANCH_TO_GUI = new HashMap<>() {{ - put("mercenary", MercenaryGui.class); - put("wizardry", WizardryGui.class); - put("druidry", DruidryGui.class); + put("mercenary/mercenary", MercenaryGui.class); + put("wizardry/wizardry", WizardryGui.class); + put("druidry/druidry", DruidryGui.class); }}; - Identifier advancementId = new Identifier("minecraft", "ygasi/" + branch); + Identifier advancementId = new Identifier("ygasi", branch); Class<?> guiClass = BRANCH_TO_GUI.get(branch); if (hasMercenary || hasWizadry || hasDrudiry) { player.sendMessage(Text.translatable("gui.ygasi.branch.no.unlock"), true); player.playSound(SoundEvents.BLOCK_ANVIL_BREAK, SoundCategory.PLAYERS, 1.0F, 1.0F); player.closeHandledScreen(); } else { - AdvUtils.grantAdvancementCriterion(player, advancementId, "unlocked_" + branch); + AdvUtils.grantAdvancementCriterion(player, advancementId, "unlocked_" + branch.split("/")[0]); unlockSuccess(player, branchName); try { Method guiMethod = guiClass.getMethod("gui", ServerPlayerEntity.class); diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java index bfd3e23..eecd65a 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java @@ -58,8 +58,7 @@ public class ConfigGui { .setCallback((index, clickType, actionType) -> { ConfigRegistry.CONFIG.enableSkillBook = !ConfigRegistry.CONFIG.enableSkillBook; player.playSound(SoundEvent.of(click), SoundCategory.PLAYERS, 1.0F, 1.0F); - gui.close(); - gui(player, false); + gui(player, fromBranch); }) ); diff --git a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java index d9896ae..5ed24cb 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/DruidryGui.java @@ -15,7 +15,7 @@ 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 (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/druidry")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "druidry/druidry")) { player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), 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 index 2715952..77efa0c 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/ExtraGui.java @@ -15,7 +15,7 @@ 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 (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/extra")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "extra/extra")) { player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), false); BranchGui.gui(player); } else { diff --git a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java index cdbb989..a190372 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/MercenaryGui.java @@ -20,7 +20,7 @@ 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", Text.of("§3" + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))).getString(); try { - if (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/mercenary")) { player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), true); BranchGui.gui(player); } else { @@ -39,8 +39,8 @@ public class MercenaryGui { gui.setSlot(49, new GuiElementBuilder() .setItem(Items.DIAMOND_BLOCK) .setName(Text.translatable("gui.ygasi.branch.mercenary.title")) - .addLoreLine(Text.translatable("gui.ygasi.branch.title", Text.of((String.valueOf(player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)))).formatted(Formatting.DARK_GRAY))) - )); + .addLoreLine(Text.translatable("gui.ygasi.branch.title", Text.of("§3" + player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS))))) + ); int[] positions = {38, 19, 1, 40, 22, 4, 42, 25, 7}; String[] advancementNames = {"offence1", "offence2", "offence3", "ninja1", "ninja2", "ninja3", "defence1", "defence2", "defence3"}; @@ -63,19 +63,19 @@ public class MercenaryGui { int position = positions[i]; String advancementName = advancementNames[i]; String nameKey = nameKeys[i]; - if (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/" + advancementName)) { - if (AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/offence1") && (advancementName.startsWith("ninja") || advancementName.startsWith("defence"))) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/" + advancementName)) { + if (AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/offence1") && (advancementName.startsWith("ninja") || advancementName.startsWith("defence"))) { GuiCommon.setDoneItem(gui, position, Items.BARRIER, nameKey, false); GuiCommon.filler(gui, 50, false); - } else if (AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/ninja1") && (advancementName.startsWith("defence") || advancementName.startsWith("offence"))) { + } else if (AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/ninja1") && (advancementName.startsWith("defence") || advancementName.startsWith("offence"))) { GuiCommon.setDoneItem(gui, position, Items.BARRIER, nameKey, false); GuiCommon.filler(gui, 50, false); GuiCommon.filler(gui, 48, false); - } else if (AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/defence1") && (advancementName.startsWith("offence") || advancementName.startsWith("ninja"))) { + } else if (AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/defence1") && (advancementName.startsWith("offence") || advancementName.startsWith("ninja"))) { GuiCommon.setDoneItem(gui, position, Items.BARRIER, nameKey, false); GuiCommon.filler(gui, 48, false); } else { - GuiCommon.setSkillSlot(gui, player, position, items[i], nameKey, costs[i], classes[i], MercenaryGui.class); + GuiCommon.setSkillSlot(gui, player, position, items[i], nameKey, "mercenary/" + advancementName, costs[i], classes[i], MercenaryGui.class); } if (position - 9 >= 0) { GuiCommon.filler(gui, position - 9, false); diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java index c4a60a4..b3eadbb 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java @@ -1,6 +1,6 @@ package dev.mayaqq.ygasi.gui; -import dev.mayaqq.ygasi.abilities.mercenary.*; +import de.dafuqs.revelationary.api.advancements.AdvancementUtils; import dev.mayaqq.ygasi.gui.common.SkillGui; import dev.mayaqq.ygasi.registry.ConfigRegistry; import dev.mayaqq.ygasi.util.AdvUtils; @@ -39,13 +39,11 @@ public class ResetGui { .setCallback((index, clickType, actionType) -> { if (player.experienceLevel >= ConfigRegistry.CONFIG.resetCost) { reset(player); - player.closeHandledScreen(); player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.PLAYERS, 1.0F, 1.0F); player.experienceLevel -= ConfigRegistry.CONFIG.resetCost; BranchGui.gui(player); } else { player.sendMessage(Text.translatable("gui.ygasi.reset.fail"), true); - gui.close(); BranchGui.gui(player); } }) @@ -61,12 +59,12 @@ public class ResetGui { gui.open(); } public static void reset(ServerPlayerEntity player) { - AdvUtils.revokeAllAdvancements(player, "minecraft", "ygasi/root"); - if (AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) { - AdvUtils.revokeAllAdvancements(player, "minecraft", "ygasi/mercenary"); + if (AdvUtils.getAdvancementProgress(player, "ygasi", "mercenary/mercenary")) { + AdvUtils.revokeAllAdvancements(player, "ygasi", "mercenary"); String[] subBranches = {"mercenary.Offence", "mercenary.Ninja", "mercenary.Defence"}; resetBranch(subBranches, player); } + AdvancementUtils.reprocessAdvancementUnlocks(player, "ygasi"); player.sendMessage(Text.translatable("gui.ygasi.reset.success"), true); player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS_TOTAL))); } diff --git a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java index 672f829..32bad0c 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/WizardryGui.java @@ -15,7 +15,7 @@ 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 (!AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/wizardry")) { + if (!AdvUtils.getAdvancementProgress(player, "ygasi", "wizardry/wizardry")) { player.sendMessage(Text.translatable("gui.ygasi.branches.fail"), false); BranchGui.gui(player); } else { diff --git a/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java b/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java index 3f54ee6..242e794 100644 --- a/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java +++ b/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java @@ -39,18 +39,17 @@ public class GuiCommon { ); } } - public static void setSkillSlot(SkillGui gui, ServerPlayerEntity player, int itemIndex, Item item, String nameKey, int cost, Class<?> skillClass, Class<?> guiClass) { - String advName = nameKey.split("\\.")[3]; + public static void setSkillSlot(SkillGui gui, ServerPlayerEntity player, int itemIndex, Item item, String nameKey, String advName ,int cost, Class<?> skillClass, Class<?> guiClass) { gui.setSlot(itemIndex, new GuiElementBuilder() .setItem(item) .hideFlag(ItemStack.TooltipSection.MODIFIERS) .setName(Text.translatable(nameKey)) .addLoreLine(Text.translatable(nameKey + ".lore")) - .addLoreLine(Text.translatable("gui.ygasi.branch.cost", Text.of("§8" + cost))) + .addLoreLine(Text.translatable("gui.ygasi.branch.cost", Text.of("§3" + cost))) .setCallback((index, clickType, actionType) -> { if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= cost) { try { - if (AdvUtils.hasBeforeAdvancements(player, "minecraft", "ygasi/"+ advName)) { + if (AdvUtils.hasBeforeAdvancements(player, "ygasi", advName)) { skillClass.getMethod("give", ServerPlayerEntity.class).invoke(null, player); player.getStatHandler().setStat(player, Stats.CUSTOM.getOrCreateStat(SKILL_POINTS), player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) - cost); guiClass.getMethod("gui", ServerPlayerEntity.class).invoke(null, player); |