Skip to content

Commit 12e1e9d

Browse files
committed
add utils folder
1 parent 5c3392c commit 12e1e9d

File tree

4 files changed

+81
-5
lines changed

4 files changed

+81
-5
lines changed

src/main/java/xyz/omegaware/addon/OmegawareAddons.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@ public void onInitialize() {
7171
Modules.get().add(new TPAAutomationModule());
7272
Modules.get().add(new BeaconRangeModule());
7373
Modules.get().add(new ChatFilterModule());
74-
//Modules.get().add(new TSRKitBotModule()); // Commented out because it is not ready yet
7574
Modules.get().add(new ItemFrameDupeModule());
7675
Modules.get().add(new BetterStashFinderModule());
7776

77+
if (System.getenv("env").equals("dev")) {
78+
Modules.get().add(new TSRKitBotModule()); // Is not ready yet
79+
}
80+
7881
if (BaritoneUtils.IS_AVAILABLE) {
7982
Modules.get().add(new BetterBaritoneBuild());
8083
}

src/main/java/xyz/omegaware/addon/modules/TSRKitBotModule.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
import net.minecraft.text.Text;
2020
import net.minecraft.util.Formatting;
2121
import xyz.omegaware.addon.OmegawareAddons;
22+
import xyz.omegaware.addon.utils.Logger;
2223

2324
import java.io.*;
2425
import java.net.http.HttpResponse;
2526
import java.nio.file.Files;
2627

28+
import static xyz.omegaware.addon.utils.ServerCheck.isNot6B6T;
29+
2730
public class TSRKitBotModule extends Module {
2831
public TSRKitBotModule() {
2932
super(OmegawareAddons.CATEGORY, "TSR-Clan-KitBot-API", "Make kit requests to the TSR Clan KitBot API.");
@@ -328,10 +331,9 @@ private static void conditionallyPrintOrders(String... statusFlag) {
328331

329332
@Override
330333
public void onActivate() {
331-
if (!OmegawareAddons.is6B6T()) {
332-
ChatUtils.sendMsg(OmegawareAddons.PREFIX.copy()
333-
.append(Text.literal("The TSR Clan KitBot API module is only intended for use on 6b6t.").formatted(Formatting.RED)));
334-
this.toggle();
334+
if (isNot6B6T()) {
335+
Logger.error("%s is only intended for use on 6b6t.", name);
336+
toggle();
335337
return;
336338
}
337339

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package xyz.omegaware.addon.utils;
2+
3+
import meteordevelopment.meteorclient.utils.player.ChatUtils;
4+
import net.minecraft.text.Text;
5+
import net.minecraft.util.Formatting;
6+
7+
public class Logger {
8+
9+
public static final Text PREFIX = Text.empty()
10+
.append(Text.literal("[").formatted(Formatting.WHITE))
11+
.append(Text.literal("OmegaWare").formatted(Formatting.AQUA))
12+
.append(Text.literal("] ").formatted(Formatting.WHITE));
13+
14+
/**
15+
* Sends a message to the chat with the given format string and arguments, prefixed with the OmegaWare prefix.
16+
* <pre>
17+
* Example:
18+
* Logger.info("Found %d %sdiamonds!", 10, Formatting.AQUA);
19+
* </pre>
20+
*/
21+
public static void info(String message, Object... args) {
22+
ChatUtils.sendMsg(PREFIX.copy().append(Text.literal(String.format(message, args))));
23+
}
24+
25+
/**
26+
* Sends a warning message to the chat with the given format string and arguments, prefixed with the OmegaWare prefix.
27+
* The message will be yellow in color.
28+
* <pre>
29+
* Example:
30+
* Logger.warn( %d %sdiamonds went missing", 5, Formatting.AQUA);
31+
* </pre>
32+
*/
33+
public static void warn(String message, Object... args) {
34+
ChatUtils.sendMsg(PREFIX.copy().append(Text.literal(String.format(message, args))).formatted(Formatting.YELLOW));
35+
}
36+
37+
/**
38+
* Sends an error message to the chat with the given format string and arguments, prefixed with the OmegaWare prefix.
39+
* The message will be red.
40+
* <pre>
41+
* Example:
42+
* Logger.error("those %d %sdiamonds turned out to be fake", 5, Formatting.AQUA);
43+
* </pre>
44+
*/
45+
public static void error(String message, Object... args) {
46+
ChatUtils.sendMsg(PREFIX.copy().append(Text.literal(String.format(message, args))).formatted(Formatting.RED));
47+
}
48+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package xyz.omegaware.addon.utils;
2+
3+
import net.minecraft.client.network.ServerInfo;
4+
import static meteordevelopment.meteorclient.MeteorClient.mc;
5+
6+
public class ServerCheck {
7+
8+
public static boolean isNot6B6T() {
9+
if (System.getenv("env").equals("dev")) return false; // Bypass check in dev environment
10+
if (mc.isIntegratedServerRunning()) return true;
11+
ServerInfo server = mc.getCurrentServerEntry();
12+
if (server == null) return false;
13+
return !server.name.endsWith("6b6t.org");
14+
}
15+
16+
// Idk how to turn off the module from here
17+
// public static void checkIf6B6T() {
18+
// if (isNot6B6T()) {
19+
// Logger.error("%s is only intended for use on 6b6t.org.");
20+
// // toggle off the module
21+
// }
22+
// }
23+
}

0 commit comments

Comments
 (0)