aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java
diff options
context:
space:
mode:
authorMaximusbarcz <maxim.baranek@gmail.com>2023-01-16 18:34:34 +0100
committerMaximusbarcz <maxim.baranek@gmail.com>2023-01-16 18:34:34 +0100
commitf7770f7e2b6d3029b207d8e574a9bb63b10a2651 (patch)
tree1204cf4b609666811955e3993522728fe408e4c6 /src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java
parent290ad0d1d979431fe8bfda966013a8de7b77a7fd (diff)
downloadygasi-f7770f7e2b6d3029b207d8e574a9bb63b10a2651.tar.gz
ygasi-f7770f7e2b6d3029b207d8e574a9bb63b10a2651.tar.bz2
ygasi-f7770f7e2b6d3029b207d8e574a9bb63b10a2651.zip
Improved Reset function, added more translations, added more features to AdvUtils, added more stuff to gui common (now you cannot accidentally click higher skill than the before making you lose skill points), made the entries in the main gui display a barrier because they will be done later after the first public beta release, tried and fail to improve PlayerConnectEvent and thats about it
Diffstat (limited to 'src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java')
-rw-r--r--src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java16
1 files changed, 11 insertions, 5 deletions
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 c6946b4..3f54ee6 100644
--- a/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java
+++ b/src/main/java/dev/mayaqq/ygasi/gui/common/GuiCommon.java
@@ -1,6 +1,7 @@
package dev.mayaqq.ygasi.gui.common;
import dev.mayaqq.ygasi.gui.BranchGui;
+import dev.mayaqq.ygasi.util.AdvUtils;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -39,6 +40,7 @@ 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];
gui.setSlot(itemIndex, new GuiElementBuilder()
.setItem(item)
.hideFlag(ItemStack.TooltipSection.MODIFIERS)
@@ -48,11 +50,15 @@ public class GuiCommon {
.setCallback((index, clickType, actionType) -> {
if (player.getStatHandler().getStat(Stats.CUSTOM.getOrCreateStat(SKILL_POINTS)) >= cost) {
try {
- 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);
- player.playSound(SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F);
-
+ if (AdvUtils.hasBeforeAdvancements(player, "minecraft", "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);
+ player.playSound(SoundEvents.BLOCK_ENCHANTMENT_TABLE_USE, SoundCategory.PLAYERS, 1.0F, 1.0F);
+ } else {
+ player.playSound(SoundEvents.BLOCK_ANVIL_BREAK, SoundCategory.PLAYERS, 1.0F, 1.0F);
+ player.sendMessage(Text.translatable("gui.ygasi.branches.no.previous"), true);
+ }
} catch (Exception e) {
throw new RuntimeException(e);
}