aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java24
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java13
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java4
-rw-r--r--src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java2
-rw-r--r--src/main/resources/data/ygasi/lang/en_us.json4
5 files changed, 31 insertions, 16 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
index 8c1fa4b..728f976 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/BranchGui.java
@@ -1,5 +1,6 @@
package dev.mayaqq.ygasi.gui;
+import dev.mayaqq.ygasi.Ygasi;
import dev.mayaqq.ygasi.gui.common.SkillGui;
import dev.mayaqq.ygasi.util.AdvUtils;
import eu.pb4.sgui.api.elements.*;
@@ -9,6 +10,7 @@ import net.minecraft.item.Items;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.sound.SoundCategory;
+import net.minecraft.sound.SoundEvent;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.text.Text;
@@ -157,6 +159,19 @@ public class BranchGui {
.setCallback((index, clickType, actionType) -> ResetGui.gui(player))
);
+ //config button for admins
+ if (player.hasPermissionLevel(4)) {
+ gui.setSlot(0, new GuiElementBuilder()
+ .setItem(Items.COMPARATOR)
+ .setName(Text.translatable("gui.ygasi.branch.config.title"))
+ .addLoreLine(Text.translatable("gui.ygasi.branch.config.lore"))
+ .setCallback((index, clickType, actionType) -> {
+ ConfigGui.gui(player, true);
+ player.playSound(SoundEvent.of(Ygasi.click), SoundCategory.PLAYERS, 1.0F, 1.0F);
+ })
+ );
+ }
+
//grant the player the root advancement of ygasi
AdvUtils.grantAdvancementCriterion(player, new Identifier("minecraft", "ygasi/root"), "opened_skill_menu");
@@ -191,21 +206,14 @@ public class BranchGui {
put("druidry", DruidryGui.class);
}};
- final Map<String, String> BRANCH_TO_ADVANCEMENT = new HashMap<>() {{
- put("mercenary", "unlocked_mercenary");
- put("wizardry", "unlocked_wizardry");
- put("druidry", "unlocked_druidry");
- }};
-
Identifier advancementId = new Identifier("minecraft", "ygasi/" + branch);
- String advancementCriterion = BRANCH_TO_ADVANCEMENT.get(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, advancementCriterion);
+ AdvUtils.grantAdvancementCriterion(player, advancementId, "unlocked_" + branch);
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 21934a8..bfd3e23 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
@@ -1,5 +1,6 @@
package dev.mayaqq.ygasi.gui;
+import dev.mayaqq.ygasi.Ygasi;
import dev.mayaqq.ygasi.registry.ConfigRegistry;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import eu.pb4.sgui.api.gui.SignGui;
@@ -17,12 +18,16 @@ import static dev.mayaqq.ygasi.Ygasi.click;
public class ConfigGui {
- public static void gui(ServerPlayerEntity player) {
+ public static void gui(ServerPlayerEntity player, Boolean fromBranch) {
SimpleGui gui = new SimpleGui(ScreenHandlerType.GENERIC_9X6, player, false) {
@Override
public void onClose() {
- ConfigRegistry.save();
super.onClose();
+ ConfigRegistry.save();
+ if (fromBranch) {
+ BranchGui.gui(player);
+ player.playSound(SoundEvent.of(Ygasi.click), SoundCategory.PLAYERS, 1.0F, 1.0F);
+ }
}
};
@@ -54,7 +59,7 @@ public class ConfigGui {
ConfigRegistry.CONFIG.enableSkillBook = !ConfigRegistry.CONFIG.enableSkillBook;
player.playSound(SoundEvent.of(click), SoundCategory.PLAYERS, 1.0F, 1.0F);
gui.close();
- gui(player);
+ gui(player, false);
})
);
@@ -112,7 +117,7 @@ public class ConfigGui {
} catch (Exception e) {
player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
- gui(player);
+ gui(player, false);
}
};
gui.open();
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java
index c74280f..2f79874 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/ResetGui.java
@@ -63,6 +63,7 @@ public class ResetGui {
public static void reset(ServerPlayerEntity player) {
//check if player experience level is greater than 10
//revoke the abilities first
+ AdvUtils.revokeAllAdvancements(player, "minecraft", "ygasi/root");
if (AdvUtils.getAdvancementProgress(player, "minecraft", "ygasi/mercenary")) {
AdvUtils.revokeAllAdvancements(player, "minecraft", "ygasi/mercenary");
String[] subBranches = {"mercenary.Offence", "mercenary.Ninja", "mercenary.Defence"};
@@ -75,9 +76,8 @@ public class ResetGui {
private static void resetBranch (String[] subBranches, ServerPlayerEntity player) {
for (String subBranch : subBranches) {
for (int i = 1; i < 4; i++) {
- String branch = subBranch + i;
try {
- Class<?> branchClass = Class.forName("dev.mayaqq.ygasi.abilities." + branch);
+ Class<?> branchClass = Class.forName("dev.mayaqq.ygasi.abilities." + subBranch + i);
branchClass.getMethod("revoke", ServerPlayerEntity.class).invoke(null, player);
} catch (Exception e) {
diff --git a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
index f46de64..bdd93d6 100644
--- a/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
+++ b/src/main/java/dev/mayaqq/ygasi/registry/CommandRegistry.java
@@ -83,7 +83,7 @@ public class CommandRegistry {
}))))
.then(literal("config")
.executes(context -> {
- ConfigGui.gui(context.getSource().getPlayer());
+ ConfigGui.gui(context.getSource().getPlayer(), false);
return 1;
})
.then(literal("reload")
diff --git a/src/main/resources/data/ygasi/lang/en_us.json b/src/main/resources/data/ygasi/lang/en_us.json
index 1fc826b..3a8257d 100644
--- a/src/main/resources/data/ygasi/lang/en_us.json
+++ b/src/main/resources/data/ygasi/lang/en_us.json
@@ -15,13 +15,15 @@
"gui.ygasi.branch.druidry.title": "§a§lDruidry",
"gui.ygasi.branch.extra.title": "§9§lExtra",
"gui.ygasi.branch.info.title": "§6§lInfo",
- "gui.ygasi.branch.info.main": "§6§lYgasi Skill Advancement System:\n§r§3When using Ygasi, every time you get an Advancement, you will get a §6Skill Point!§3 Then when you gather enough skill points throughout your journey you can unlock new interesting skills in the §6skill book§3 and improve your game experience, from protecting yourself from falling to summoning a horde of undead you can do everything with just a bit of patience, skill and fun!",
+ "gui.ygasi.branch.info.main": "§6§lYgasi Skill Advancement System:\n§r§3When using Ygasi,; every time you get an Advancement, you will get a §6Skill Point!§3 Then when you gather enough skill points throughout your journey you can unlock new interesting skills in the §6skill book§3 and improve your game experience, from protecting yourself from falling to summoning a horde of undead you can do everything with just a bit of patience, skill and fun!",
"gui.ygasi.branch.wip": "§c§l To be added in the future!",
"gui.ygasi.branch.reset.title": "§4§lReset",
"gui.ygasi.branch.reset.lore": "§8This will reset all your skills and give you back all of your skill points.",
"gui.ygasi.branch.reset.lore2": "§c§lThis action cannot be undone.",
"gui.ygasi.branch.reset.lore3": "§8Cost: %s §8Experience Levels",
+ "gui.ygasi.branch.config.title": "§5§lConfig",
+ "gui.ygasi.branch.config.lore": "§8Only visible for OPs.",
"gui.ygasi.branch.cost": "§3Cost: %s",
"gui.ygasi.branch.unlock": "§aYou have unlocked the %s §abranch!",
"gui.ygasi.branch.no.skill": "§cYou don't have enough skill points to unlock this branch!",