aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorolim <bobq4582@gmail.com>2024-02-07 18:52:54 +0000
committerolim <bobq4582@gmail.com>2024-02-07 18:52:54 +0000
commitf6d17c2ec7f33cf7ebc2fa8b7f21c9f541ba4ac2 (patch)
treea19167ce109602534253f1b1240b112f6cc24caa /src/main/java
parentc6915a199f151f05936cc6cb745f242e87a12c46 (diff)
downloadSkyblocker-f6d17c2ec7f33cf7ebc2fa8b7f21c9f541ba4ac2.tar.gz
Skyblocker-f6d17c2ec7f33cf7ebc2fa8b7f21c9f541ba4ac2.tar.bz2
Skyblocker-f6d17c2ec7f33cf7ebc2fa8b7f21c9f541ba4ac2.zip
add descriptions for functions
adds descriptions fall all new functions and removes unused renderBackground function
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java30
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java59
2 files changed, 72 insertions, 17 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java
index d6d7584e..26608f85 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/OverlayScreen.java
@@ -1,6 +1,8 @@
package de.hysky.skyblocker.skyblock.searchOverlay;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
+import it.unimi.dsi.fastutil.Pair;
+import it.unimi.dsi.fastutil.ints.IntIntPair;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
@@ -27,6 +29,10 @@ public class OverlayScreen extends Screen {
public OverlayScreen(Text title) {
super(title);
}
+
+ /**
+ * Creates the layout for the overlay screen.
+ */
@Override
protected void init() {
super.init();
@@ -95,7 +101,9 @@ public class OverlayScreen extends Screen {
this.setInitialFocus(searchField);
}
-
+ /**
+ * Renders the search icon and the label for the history
+ */
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
@@ -105,13 +113,9 @@ public class OverlayScreen extends Screen {
}
}
- @Override
- public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
- super.renderBackground(context, mouseX, mouseY, delta);
- //todo draw custom background
-
- }
-
+ /**
+ * Closes the overlay screen and gets the manager to send a packet update about the sign
+ */
@Override
public void close() {
assert this.client != null;
@@ -119,6 +123,10 @@ public class OverlayScreen extends Screen {
SearchOverManager.pushSearch();
super.close();
}
+
+ /**
+ * updates if the suggestions buttons should be visible based on if they have a value
+ */
@Override
public final void tick() {
super.tick();
@@ -135,10 +143,14 @@ public class OverlayScreen extends Screen {
}
}
+
+ /**
+ * When a key is pressed. If enter key pressed and search box selected close
+ */
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
super.keyPressed(keyCode,scanCode,modifiers);
- //if enter key pressed and search box selected close
+ //
if (keyCode == GLFW.GLFW_KEY_ENTER && searchField.isActive()){
close();
return true;
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java
index c076edc7..7bd6a259 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/searchOverlay/SearchOverManager.java
@@ -25,10 +25,18 @@ public class SearchOverManager {
private static final MinecraftClient CLIENT = MinecraftClient.getInstance();
+ /**
+ * website where actionable items are stored
+ */
private static final String THREE_DAY_AVERAGE = "https://moulberry.codes/auction_averages_lbin/3day.json";
+
private static final Pattern BAZAAR_ENCHANTMENT_PATTERN = Pattern.compile("ENCHANTMENT_(\\D*)_(\\d+)");
private static final Pattern AUCTION_PET_AND_RUNE_PATTERN = Pattern.compile("([A-Z0-9_]+);(\\d+)");
private static final Pattern AUCTION_PET_SKIN_PATTERN = Pattern.compile("PET_SKIN_(\\D*)");
+
+ /**
+ * converts index (in array) +1 to a roman numeral
+ */
private static final String[] ROMAN_NUMERALS = new String[]{
"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI",
"XII", "XIII", "XIV", "XV", "XVI", "XVII","XVIII", "XIX", "XX"
@@ -47,6 +55,10 @@ public class SearchOverManager {
public static HashSet<String> auctionItems =new HashSet<>();
public static String[] suggestionsArray = {};
+
+ /**
+ * uses the skyblock api and Moulberry auction to load a list of items in bazaar and auction house
+ */
public static void init() {
//get bazaar items
try {
@@ -139,7 +151,10 @@ public class SearchOverManager {
}
}
-
+ /**
+ * Capitalizes the first letter off every word in a string
+ * @param str string to capitalize
+ */
private static String capitalizeFully(String str) {
if (str == null || str.isEmpty()) {
return str;
@@ -149,16 +164,24 @@ public class SearchOverManager {
.map(t -> t.substring(0, 1).toUpperCase() + t.substring(1).toLowerCase())
.collect(Collectors.joining(" "));
}
-
- private static String trimItemColor(String string){
- if (string.isEmpty()) return string;
- if (string.startsWith("§") ){
- return string.substring(2);
+ /**
+ * Removes the item color text tags from the start of a string if it has one
+ * @param str string to remove color
+ */
+ private static String trimItemColor(String str){
+ if (str.isEmpty()) return str;
+ if (str.startsWith("§") ){
+ return str.substring(2);
}else {
- return string;
+ return str;
}
}
-
+ /**
+ * Receives data when a search is started and resets values
+ * @param sign the sign that is being edited
+ * @param front if it's the front of the sign
+ * @param isAuction if the sign is loaded from the auction house menu or bazaar
+ */
public static void updateSign(SignBlockEntity sign, boolean front, boolean isAuction) {
visible= true;
SignFront = front;
@@ -180,6 +203,10 @@ public class SearchOverManager {
suggestionsArray = new String[]{};
}
+ /**
+ * Updates the search value and the suggestions based on that value.
+ * @param newValue new search value
+ */
protected static void updateSearch(String newValue) {
search = newValue;
//update the suggestion values
@@ -192,6 +219,11 @@ public class SearchOverManager {
suggestionsArray = bazaarItems.stream().filter(item -> item.toLowerCase().contains(search.toLowerCase())).limit(totalSuggestions).toList().toArray(suggestionsArray);
}
}
+
+ /**
+ * Gets the suggestion in the suggestion array at the index
+ * @param index index of suggestion
+ */
protected static String getSuggestion(int index){
if (suggestionsArray.length> index && suggestionsArray[index] != null ){
return suggestionsArray[index];
@@ -199,6 +231,10 @@ public class SearchOverManager {
return "";
}
}
+ /**
+ * Gets the item name in the history array at the index
+ * @param index index of suggestion
+ */
protected static String getHistory(int index){
if (IsAuction){
if (SkyblockerConfigManager.get().general.searchOverlay.auctionHistory.size() >index){
@@ -212,6 +248,10 @@ public class SearchOverManager {
}
return null;
}
+
+ /**
+ * Add the current search value to the start of the history list and truncate to the max history value and save this to the config
+ */
private static void saveHistory(){
//save to history
int historyLength = SkyblockerConfigManager.get().general.searchOverlay.historyLength;
@@ -229,6 +269,9 @@ public class SearchOverManager {
SkyblockerConfigManager.save();
}
+ /**
+ *Saves the current search value and then splits it onto the first to lines of the sign making sure not to split a word in 2
+ */
protected static void pushSearch() {
//save to history
if (!search.isEmpty()){