aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-15 18:40:24 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-15 18:40:24 +0100
commitd115e4365d0a5a492a55e56a7a4dcf034419e1b4 (patch)
treee9aec4f8b180c4a6b90d194f31e95a8df8863bb4 /src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
parent5bcb1830298caad87a63f44c4e7f1553074cf4c8 (diff)
downloadygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.gz
ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.tar.bz2
ygasi-d115e4365d0a5a492a55e56a7a4dcf034419e1b4.zip
More stuff! The Mercenary gui is basically done other than the translations, I tried and failed to add modrinth publishing thing to gradle, I redid some stuff, I added stuff, I removed stuff and mainly... I broke the reset command (it works but says it broke) and I have no idea how to fix it!
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java57
1 files changed, 19 insertions, 38 deletions
diff --git a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
index 74c1c5e..21934a8 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/ConfigGui.java
@@ -11,6 +11,8 @@ import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.Text;
+import java.lang.reflect.Field;
+
import static dev.mayaqq.ygasi.Ygasi.click;
public class ConfigGui {
@@ -57,6 +59,15 @@ public class ConfigGui {
);
gui.setSlot(3, new GuiElementBuilder()
+ .setItem(Items.RED_TERRACOTTA)
+ .setName(Text.translatable("config.ygasi.resetCost.title"))
+ .addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.resetCost))))
+ .setCallback((index, clickType, actionType) -> {
+ textInput(player, "resetCost");
+ })
+ );
+
+ gui.setSlot(4, new GuiElementBuilder()
.setItem(Items.STICK)
.setName(Text.translatable("config.ygasi.T1Cost.title"))
.addLoreLine(Text.translatable("config.ygasi.current").append(Text.of(String.valueOf(ConfigRegistry.CONFIG.T1Cost))))
@@ -65,7 +76,7 @@ public class ConfigGui {
})
);
- gui.setSlot(4, new GuiElementBuilder()
+ gui.setSlot(5, new GuiElementBuilder()
.setItem(Items.STICK)
.setCount(2)
.setName(Text.translatable("config.ygasi.T2Cost.title"))
@@ -75,7 +86,7 @@ public class ConfigGui {
})
);
- gui.setSlot(5, new GuiElementBuilder()
+ gui.setSlot(6, new GuiElementBuilder()
.setItem(Items.STICK)
.setCount(3)
.setName(Text.translatable("config.ygasi.T3Cost.title"))
@@ -94,42 +105,12 @@ public class ConfigGui {
SignGui gui = new SignGui(player) {
@Override
public void onClose() {
- switch (option) {
- case "pointsRewarded" -> {
- try {
- ConfigRegistry.CONFIG.pointsRewarded = Integer.parseInt(this.getLine(0).getString());
- } catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
- }
- }
- case "branchCost" -> {
- try {
- ConfigRegistry.CONFIG.branchCost = Integer.parseInt(this.getLine(0).getString());
- } catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
- }
- }
- case "T1Cost" -> {
- try {
- ConfigRegistry.CONFIG.T1Cost = Integer.parseInt(this.getLine(0).getString());
- } catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
- }
- }
- case "T2Cost" -> {
- try {
- ConfigRegistry.CONFIG.T2Cost = Integer.parseInt(this.getLine(0).getString());
- } catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
- }
- }
- case "T3Cost" -> {
- try {
- ConfigRegistry.CONFIG.T3Cost = Integer.parseInt(this.getLine(0).getString());
- } catch (NumberFormatException e) {
- player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
- }
- }
+ try {
+ Field field = ConfigRegistry.CONFIG.getClass().getDeclaredField(option);
+ field.setAccessible(true);
+ field.set(ConfigRegistry.CONFIG, Integer.parseInt(this.getLine(0).getString()));
+ } catch (Exception e) {
+ player.sendMessage(Text.translatable("config.ygasi.invalid.number"), true);
}
gui(player);
}