diff options
Diffstat (limited to 'src/main/java')
3 files changed, 32 insertions, 3 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java index f2ecefc6..93897988 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java @@ -47,6 +47,21 @@ public class ChatRule { this.customSound = null; } + public ChatRule(String name, Boolean enabled, Boolean isPartialMatch, Boolean isRegex, Boolean isIgnoreCase, String filter, String validLocations, Boolean hideMessage, Boolean showActionBar, Boolean showAnnouncement, String replaceMessage, SoundEvent customSound) { + this.name = name; + this.enabled = enabled; + this.isPartialMatch = isPartialMatch; + this.isRegex = isRegex; + this.isIgnoreCase = isIgnoreCase; + this.filter = filter; + this.validLocations = validLocations; + this.hideMessage = hideMessage; + this.showActionBar = showActionBar; + this.showAnnouncement = showAnnouncement; + this.replaceMessage = replaceMessage; + this.customSound = customSound; + } + protected String getName() { return name; } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java index 59e2efed..92cd72d7 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java @@ -155,6 +155,7 @@ public class ChatRuleConfigScreen extends Screen { locationsInput = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, currentPos.leftInt() + lineXOffset, currentPos.rightInt(), 200, 20, Text.of("")); locationsInput.setText(chatRule.getValidLocations()); MutableText locationToolTip = Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.locations.@Tooltip"); + locationToolTip.append("\n"); ChatRulesHandler.locationsList.forEach(location -> locationToolTip.append(" " + location + ",\n")); locationsInput.setTooltip(Tooltip.of(locationToolTip)); currentPos = IntIntPair.of(currentPos.leftInt(),currentPos.rightInt() + SPACER_Y); @@ -300,10 +301,12 @@ public class ChatRuleConfigScreen extends Screen { context.drawTextWithShadow(this.textRenderer,Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.replace"), replaceMessageLabelTextPos.leftInt(), replaceMessageLabelTextPos.rightInt() + yOffset, 0xFFFFFF); } + /** + * Saves and returns to parent screen + */ @Override public void close() { - //todo add checks to see if valid rule e.g. has name - //and if valid save a + if (client != null ) { save(); client.setScreen(parent); diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java index bde55aed..aa9343d8 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java @@ -9,6 +9,7 @@ import de.hysky.skyblocker.utils.Http; import de.hysky.skyblocker.utils.Utils; import net.fabricmc.fabric.api.client.message.v1.ClientReceiveMessageEvents; import net.minecraft.client.MinecraftClient; +import net.minecraft.sound.SoundEvents; import net.minecraft.text.MutableText; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -55,13 +56,23 @@ public class ChatRulesHandler { LOGGER.info("[Skyblocker] Loaded chat rules"); } catch (NoSuchFileException e) { - //todo create default chat rules + registerDefaultChatRules(); LOGGER.warn("[Skyblocker] chat rule file not found, using default rules. This is normal when using for the first time."); } catch (IOException e) { LOGGER.error("[Skyblocker] Failed to load shortcuts file", e); } } + private static void registerDefaultChatRules() { + //clean hub chat + ChatRule cleanHubRule = new ChatRule("Clean Hub Chat", false, true, true, true, "(selling)|(buying)|(lowb)|(visit)|(/p)|(/ah)|(my ah)", "hub", true, false, false, "", null); + //mining Ability + ChatRule miningAbilityRule = new ChatRule("Mining Ability Alert", false, true, false, true, "is now available!", "Crystal Hollows, Dwarven Mines", false, false, true, "&1Ability", SoundEvents.ENTITY_ARROW_HIT_PLAYER); + + chatRuleList.add(cleanHubRule); + chatRuleList.add(miningAbilityRule); + } + private static void loadLocations() { try { String response = Http.sendGetRequest("https://api.hypixel.net/v2/resources/games"); |