aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-02-18 21:56:45 +0000
committerolim <bobq4582@gmail.com>2024-02-18 21:56:45 +0000
commitb3e4dabf7ffce74c8cd137d1ea7418c4ca1026dd (patch)
tree2bf3697f4ea9f7c5180eb1f90b4abc3023c56bda /src/main
parent9376765c8d3072d2398f244d5e9242b171125f99 (diff)
downloadSkyblocker-b3e4dabf7ffce74c8cd137d1ea7418c4ca1026dd.tar.gz
Skyblocker-b3e4dabf7ffce74c8cd137d1ea7418c4ca1026dd.tar.bz2
Skyblocker-b3e4dabf7ffce74c8cd137d1ea7418c4ca1026dd.zip
fix most formatting issues
tried to find all of the formatting problems left in my code
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java20
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java6
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java30
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java36
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigScreen.java12
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java3
6 files changed, 26 insertions, 81 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 60a64fad..4877fdb6 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRule.java
@@ -1,12 +1,8 @@
package de.hysky.skyblocker.skyblock.chat;
import de.hysky.skyblocker.utils.Utils;
-import net.minecraft.client.sound.Sound;
-import net.minecraft.item.ItemStack;
import net.minecraft.sound.SoundEvent;
-import net.minecraft.sound.SoundEvents;
-import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
@@ -16,8 +12,8 @@ import java.util.regex.Pattern;
public class ChatRule {
private String name;
- //inputs
+ //inputs
private Boolean enabled;
private Boolean isPartialMatch;
private Boolean isRegex;
@@ -29,7 +25,7 @@ public class ChatRule {
private Boolean hideMessage;
private Boolean showActionBar;
private Boolean showAnnouncement;
- private String replaceMessage; //todo extract parts of original message
+ private String replaceMessage;
private SoundEvent customSound;
/**
* Creates a chat rule with default options.
@@ -51,7 +47,7 @@ public class ChatRule {
this.customSound = null;
}
- public Boolean getEnabled() { //todo remove unused getters and set
+ public Boolean getEnabled() {
return enabled;
}
@@ -211,16 +207,6 @@ public class ChatRule {
public void setName(String name) {
this.name = name;
}
-
- public enum LocationOption {
- None,
- Island,
- Hub,
- Garden; //todo add more
-
- }
-
-
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
index 0ee3c2c5..2cb6ca5c 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleAnnouncementScreen.java
@@ -9,10 +9,8 @@ import net.minecraft.text.Text;
public class ChatRuleAnnouncementScreen {
-
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
private static float timer;
-
private static Text text = null;
public static void init() {
@@ -22,11 +20,8 @@ public class ChatRuleAnnouncementScreen {
}
render(context, tickDelta);
});
-
}
-
-
/**
* renders {@link ChatRuleAnnouncementScreen#text} to the middle of the top of the screen.
* @param context render context
@@ -46,6 +41,7 @@ public class ChatRuleAnnouncementScreen {
matrices.pop();
}
+
protected static void setText(Text newText) {
text = newText;
timer = SkyblockerConfigManager.get().messages.chatRuleConfig.announcementLength;
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 cb9a2da6..31611991 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRuleConfigScreen.java
@@ -19,7 +19,6 @@ import java.util.Map;
import static java.util.Map.entry;
public class ChatRuleConfigScreen extends Screen {
-
private static final int SPACER_X = 5;
private static final int SPACER_Y = 25;
@@ -35,17 +34,12 @@ public class ChatRuleConfigScreen extends Screen {
private final int chatRuleIndex;
private final ChatRule chatRule;
-
- //widgets
- private ButtonWidget finishButton;
-
private TextFieldWidget nameInput;
private TextFieldWidget filterInput;
private ButtonWidget partialMatchToggle;
private ButtonWidget regexToggle;
private ButtonWidget ignoreCaseToggle;
private TextFieldWidget locationsInput;
-
private ButtonWidget hideMessageToggle;
private ButtonWidget actionBarToggle;
private ButtonWidget announcementToggle;
@@ -55,16 +49,12 @@ public class ChatRuleConfigScreen extends Screen {
//textLocations
private IntIntPair nameLabelTextPos;
private IntIntPair inputsLabelTextPos;
-
private IntIntPair filterLabelTextPos;
private IntIntPair partialMatchTextPos;
private IntIntPair regexTextPos;
private IntIntPair ignoreCaseTextPos;
-
private IntIntPair locationLabelTextPos;
-
private IntIntPair outputsLabelTextPos;
-
private IntIntPair hideMessageTextPos;
private IntIntPair actionBarTextPos;
private IntIntPair announcementTextPos;
@@ -75,8 +65,6 @@ public class ChatRuleConfigScreen extends Screen {
private final Screen parent;
-
-
public ChatRuleConfigScreen(Screen parent, int chatRuleIndex) {
super(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen"));
this.chatRuleIndex = chatRuleIndex;
@@ -91,7 +79,7 @@ public class ChatRuleConfigScreen extends Screen {
if (client == null) return;
//start centered on the X and 1/3 down on the Y
IntIntPair currentPos = IntIntPair.of((this.width - getMaxUsedWidth()) / 2,(int)((this.height -getMaxUsedHeight()) * 0.33));
- int lineXOffset = 0;
+ int lineXOffset;
nameLabelTextPos = currentPos;
lineXOffset = client.textRenderer.getWidth(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.name")) + SPACER_X;
@@ -221,11 +209,9 @@ public class ChatRuleConfigScreen extends Screen {
replaceMessageInput.setTooltip(Tooltip.of(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.replace.@Tooltip")));
replaceMessageInput.setText(chatRule.getReplaceMessage());
- finishButton = ButtonWidget.builder(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.finish"), a -> {
- close();
- })
+ ButtonWidget finishButton = ButtonWidget.builder(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen.finish"), a -> close())
.position(this.width - 75 - SPACER_Y, this.height - SPACER_Y)
- .size(75,20)
+ .size(75, 20)
.build();
addDrawableChild(nameInput);
@@ -243,7 +229,7 @@ public class ChatRuleConfigScreen extends Screen {
}
/**
- * works out the width of the maximum line
+ * Works out the width of the maximum line
* @return the max used width
*/
private int getMaxUsedWidth() {
@@ -259,8 +245,12 @@ public class ChatRuleConfigScreen extends Screen {
return total;
}
+ /**
+ * Works out the height used
+ * @return height used by the gui
+ */
private int getMaxUsedHeight() {
- //there are 7 rows so just times the spacer by 7
+ //there are 8 rows so just times the spacer by 8
return SPACER_Y * 8;
}
@@ -318,6 +308,4 @@ public class ChatRuleConfigScreen extends Screen {
}
return soundsLookup.keySet().stream().toList().get(currentSoundIndex);
}
-
-
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java
index 87455a2b..c5d7fcc8 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigListWidget.java
@@ -17,8 +17,6 @@ import java.awt.*;
import java.util.List;
public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfigListWidget.AbstractChatRuleEntry> {
-
-
private final ChatRulesConfigScreen screen;
private Boolean hasChanged;
@@ -45,7 +43,6 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
return super.getScrollbarPositionX() + 50;
}
-
protected void addRuleAfterSelected() {
hasChanged = true;
int newIndex = children().indexOf(getSelectedOrNull()) + 1;
@@ -58,13 +55,11 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
return super.removeEntry(entry);
}
-
protected void saveRules() {
hasChanged = false;
ChatRulesHandler.saveChatRules();
}
-
protected boolean hasChanges(){
return (hasChanged || children().stream().filter(chatRuleConfigEntry.class::isInstance).map(chatRuleConfigEntry.class::cast).anyMatch(chatRuleConfigEntry::isChange));
}
@@ -94,22 +89,18 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
private class chatRuleConfigEntry extends AbstractChatRuleEntry {
//data
- private int chatRuleIndex;
- private ChatRule chatRule;
+ private final int chatRuleIndex;
+ private final ChatRule chatRule;
private final List<? extends Element> children;
-
-
- //widgets
+ //widgets
private final ButtonWidget enabledButton;
private final ButtonWidget openConfigButton;
private final ButtonWidget deleteButton;
-
- //text locations
+ //text location
private final int nameX = width / 2 - 125;
-
//saved data
private double oldScrollAmount = 0;
@@ -118,15 +109,10 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
this.chatRuleIndex = chatRuleIndex;
this.chatRule = ChatRulesHandler.chatRuleList.get(chatRuleIndex);
- //initialize the widgets
-
- enabledButton = ButtonWidget.builder(enabledButtonText() , a -> {
- toggleEnabled();
- })
+ enabledButton = ButtonWidget.builder(enabledButtonText() , a -> toggleEnabled())
.size(50,20)
.position(width / 2 - 25,5)
- .build()
- ;
+ .build();
openConfigButton = ButtonWidget.builder(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.editRule"), a -> {
client.setScreen(new ChatRuleConfigScreen(screen, chatRuleIndex));
@@ -134,17 +120,15 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
.size(50,20)
.position(width / 2 + 45,5)
.tooltip(Tooltip.of(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.editRule.@Tooltip")))
- .build()
- ;
+ .build();
+
deleteButton = ButtonWidget.builder(Text.translatable("selectServer.delete"), a -> {
oldScrollAmount = getScrollAmount();
client.setScreen(new ConfirmScreen(this::deleteEntry, Text.translatable("skyblocker.shortcuts.deleteQuestion"), Text.translatable("skyblocker.shortcuts.deleteWarning", chatRule.getName()), Text.translatable("selectServer.deleteButton"), ScreenTexts.CANCEL));
})
.size(50,20)
.position(width / 2 + 105,5)
- .build()
- ;
-
+ .build();
children = List.of(enabledButton, openConfigButton, deleteButton);
}
@@ -182,7 +166,7 @@ public class ChatRulesConfigListWidget extends ElementListWidget<ChatRulesConfig
@Override
public void appendNarrations(NarrationMessageBuilder builder) {
- builder.put(NarrationPart.TITLE); //todo add more e.g. , targetName, replacementName
+ builder.put(NarrationPart.TITLE,chatRule.getName());
}
});
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigScreen.java
index 11ea5a7a..1a6815dc 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigScreen.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesConfigScreen.java
@@ -12,14 +12,8 @@ import net.minecraft.text.Text;
public class ChatRulesConfigScreen extends Screen {
private ChatRulesConfigListWidget chatRulesConfigListWidget;
- private ButtonWidget buttonNew;
- private ButtonWidget buttonDone;
private final Screen parent;
- public ChatRulesConfigScreen() {
- this(null);
- }
-
public ChatRulesConfigScreen(Screen parent) {
super(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.ruleScreen"));
this.parent = parent;
@@ -43,9 +37,9 @@ public class ChatRulesConfigScreen extends Screen {
close();
}
}).build());
- buttonNew = ButtonWidget.builder(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.new"), buttonNew -> chatRulesConfigListWidget.addRuleAfterSelected()).build();
- adder.add(buttonNew);
- buttonDone = ButtonWidget.builder(ScreenTexts.DONE, button -> {
+ ButtonWidget buttonNew1 = ButtonWidget.builder(Text.translatable("text.autoconfig.skyblocker.option.messages.chatRules.screen.new"), buttonNew -> chatRulesConfigListWidget.addRuleAfterSelected()).build();
+ adder.add(buttonNew1);
+ ButtonWidget buttonDone = ButtonWidget.builder(ScreenTexts.DONE, button -> {
chatRulesConfigListWidget.saveRules();
if (client != null) {
close();
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 c9efe749..bde55aed 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chat/ChatRulesHandler.java
@@ -81,7 +81,6 @@ public class ChatRulesHandler {
catch (Exception e) {
LOGGER.error("[Skyblocker] Failed to load locations!", e);
}
- System.out.println(locations);
}
protected static void saveChatRules() {
@@ -146,7 +145,6 @@ public class ChatRulesHandler {
* @param codedString the string with color codes in
* @return formatted text
*/
-
protected static MutableText formatText(String codedString) {
if (codedString.contains(String.valueOf(Formatting.FORMATTING_CODE_PREFIX)) || codedString.contains("&")){
MutableText newText = Text.literal("");
@@ -166,5 +164,4 @@ public class ChatRulesHandler {
}
return Text.literal(codedString);
}
-
}