Skip to content

Commit 7ff3741

Browse files
committed
use Logger
1 parent b5c5fe7 commit 7ff3741

File tree

8 files changed

+66
-293
lines changed

8 files changed

+66
-293
lines changed

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

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,12 @@ public class OmegawareAddons extends MeteorAddon {
3030
public static ModMetadata MOD_META;
3131
public static final Logger LOG = LogUtils.getLogger();
3232
public static final Category CATEGORY = new Category("OmegaWare");
33-
@SuppressWarnings("unused")
3433
public static final HudGroup HUD_GROUP = new HudGroup("OmegaWare");
3534

3635
public static File GetConfigFile(String key, String filename) {
3736
return new File(new File(new File(new File(MeteorClient.FOLDER, "omegaware"), key), Utils.getFileWorldName()), filename);
3837
}
3938

40-
public static String getCurrentServerAddress() {
41-
ServerInfo server = MinecraftClient.getInstance().getCurrentServerEntry();
42-
if (server == null) {
43-
return "singleplayer";
44-
}
45-
46-
if (server.address == null || server.address.isEmpty()) {
47-
return "unknown";
48-
}
49-
50-
return MinecraftClient.getInstance().getCurrentServerEntry().address;
51-
}
52-
53-
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
54-
public static boolean is6B6T() {
55-
String serverAddress = getCurrentServerAddress();
56-
return serverAddress.contains("6b6t.org");
57-
}
58-
59-
public static final Text PREFIX = Text.empty()
60-
.append(Text.literal("[").formatted(Formatting.WHITE))
61-
.append(Text.literal("OmegaWare").formatted(Formatting.AQUA))
62-
.append(Text.literal("] ").formatted(Formatting.WHITE));
63-
6439
@Override
6540
public void onInitialize() {
6641
LOG.info("Initializing OmegaWare Addons");

src/main/java/xyz/omegaware/addon/commands/ShulkerQueueCommand.java

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import net.minecraft.util.Formatting;
1010
import xyz.omegaware.addon.OmegawareAddons;
1111
import xyz.omegaware.addon.modules.ItemFrameDupeModule;
12+
import xyz.omegaware.addon.utils.Logger;
1213

1314
public class ShulkerQueueCommand extends Command {
1415
public ShulkerQueueCommand() {
@@ -19,116 +20,71 @@ public ShulkerQueueCommand() {
1920
public void build(LiteralArgumentBuilder<CommandSource> builder) {
2021
builder.then(literal("add").executes(context -> {
2122
if (mc.player == null) {
22-
Text msg = OmegawareAddons.PREFIX.copy()
23-
.append(Text.literal("Error: ").formatted(Formatting.RED))
24-
.append(Text.literal("Player was somehow null").formatted(Formatting.WHITE));
25-
ChatUtils.sendMsg(msg);
26-
23+
Logger.error("Player was somehow null");
2724
return SINGLE_SUCCESS;
2825
}
2926

3027
ItemStack stack = mc.player.getMainHandStack();
3128
if (stack.isEmpty()) {
32-
Text msg = OmegawareAddons.PREFIX.copy()
33-
.append(Text.literal("Error: ").formatted(Formatting.RED))
34-
.append(Text.literal("You must hold an item in your main hand").formatted(Formatting.WHITE));
35-
ChatUtils.sendMsg(msg);
36-
29+
Logger.error("You must hold an item in your main hand");
3730
return SINGLE_SUCCESS;
3831
}
3932
ItemFrameDupeModule.shulkerQueue.add(stack.copy());
4033

41-
Text msg = OmegawareAddons.PREFIX.copy()
42-
.append(Text.literal("Added ").formatted(Formatting.GREEN))
43-
.append(stack.toHoverableText())
44-
.append(Text.literal(" to the shulker queue").formatted(Formatting.WHITE));
45-
ChatUtils.sendMsg(msg);
34+
Logger.info("%sAdded %s to the shulker queue", Formatting.GREEN, stack.toHoverableText());
4635

4736
return SINGLE_SUCCESS;
4837
}));
4938

5039
builder.then(literal("remove").executes(context -> {
5140
if (mc.player == null) {
52-
Text msg = OmegawareAddons.PREFIX.copy()
53-
.append(Text.literal("Error: ").formatted(Formatting.RED))
54-
.append(Text.literal("Player was somehow null").formatted(Formatting.WHITE));
55-
ChatUtils.sendMsg(msg);
56-
41+
Logger.error("Player was somehow null");
5742
return SINGLE_SUCCESS;
5843
}
5944

6045
ItemStack stack = mc.player.getMainHandStack();
6146
if (stack.isEmpty()) {
62-
Text msg = OmegawareAddons.PREFIX.copy()
63-
.append(Text.literal("Error: ").formatted(Formatting.RED))
64-
.append(Text.literal("You must hold an item in your main hand").formatted(Formatting.WHITE));
65-
ChatUtils.sendMsg(msg);
66-
47+
Logger.error("You must hold an item in your main hand");
6748
return SINGLE_SUCCESS;
6849
}
6950
if (!ItemFrameDupeModule.shulkerQueue.contains(stack.copy())) {
70-
Text msg = OmegawareAddons.PREFIX.copy()
71-
.append(Text.literal("Error: ").formatted(Formatting.RED))
72-
.append(Text.literal("Item is not in the shulker queue").formatted(Formatting.WHITE));
73-
ChatUtils.sendMsg(msg);
74-
51+
Logger.error("Item is not in the shulker queue");
7552
return SINGLE_SUCCESS;
7653
}
7754

7855
ItemFrameDupeModule.shulkerQueue.remove(stack.copy());
7956

80-
Text msg = OmegawareAddons.PREFIX.copy()
81-
.append(Text.literal("Removed ").formatted(Formatting.RED))
82-
.append(stack.toHoverableText())
83-
.append(Text.literal(" from the shulker queue").formatted(Formatting.WHITE));
84-
ChatUtils.sendMsg(msg);
85-
57+
Logger.info("%sRemoved%s %s from the shulker queue", Formatting.RED, Formatting.WHITE ,stack.toHoverableText());
8658
return SINGLE_SUCCESS;
8759
}));
8860

8961
builder.then(literal("list").executes(context -> {
9062
if (mc.player == null) {
91-
Text msg = OmegawareAddons.PREFIX.copy()
92-
.append(Text.literal("Error: ").formatted(Formatting.RED))
93-
.append(Text.literal("Player was somehow null").formatted(Formatting.WHITE));
94-
ChatUtils.sendMsg(msg);
95-
63+
Logger.error("Player was somehow null");
9664
return SINGLE_SUCCESS;
9765
}
9866

9967
if (ItemFrameDupeModule.shulkerQueue.isEmpty()) {
100-
Text msg = OmegawareAddons.PREFIX.copy()
101-
.append(Text.literal("Shulker queue is empty").formatted(Formatting.WHITE));
102-
ChatUtils.sendMsg(msg);
68+
Logger.info("Shulker queue is empty");
10369
} else {
104-
Text msg = OmegawareAddons.PREFIX.copy()
105-
.append(Text.literal("Shulker queue: ").formatted(Formatting.YELLOW));
106-
ChatUtils.sendMsg(msg);
107-
108-
ItemFrameDupeModule.shulkerQueue.forEach(itemStack -> {
109-
Text itemText = itemStack.toHoverableText();
110-
ChatUtils.sendMsg(itemText);
111-
});
70+
StringBuilder sb = new StringBuilder("Shulker queue: ");
71+
ItemFrameDupeModule.shulkerQueue.forEach(itemStack -> sb.append(itemStack.toHoverableText().getString()).append("\n"));
72+
Logger.info(sb.toString());
11273
}
11374

11475
return SINGLE_SUCCESS;
11576
}));
11677

11778
builder.then(literal("clear").executes(context -> {
11879
if (mc.player == null) {
119-
Text msg = OmegawareAddons.PREFIX.copy()
120-
.append(Text.literal("Error: ").formatted(Formatting.RED))
121-
.append(Text.literal("Player was somehow null").formatted(Formatting.WHITE));
122-
ChatUtils.sendMsg(msg);
80+
Logger.error("Player was somehow null");
12381

12482
return SINGLE_SUCCESS;
12583
}
12684

12785
ItemFrameDupeModule.shulkerQueue.clear();
12886

129-
Text msg = OmegawareAddons.PREFIX.copy()
130-
.append(Text.literal("Cleared the shulker queue").formatted(Formatting.WHITE));
131-
ChatUtils.sendMsg(msg);
87+
Logger.info("Cleared the shulker queue");
13288

13389
return SINGLE_SUCCESS;
13490
}));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import meteordevelopment.meteorclient.systems.modules.misc.AutoReconnect;
2727
import meteordevelopment.meteorclient.utils.Utils;
2828
import meteordevelopment.meteorclient.utils.network.MeteorExecutor;
29-
import meteordevelopment.meteorclient.utils.player.ChatUtils;
3029
import meteordevelopment.meteorclient.utils.player.InvUtils;
3130
import meteordevelopment.meteorclient.utils.player.SlotUtils;
3231
import meteordevelopment.meteorclient.utils.render.color.SettingColor;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import net.minecraft.util.math.BlockPos;
3030
import net.minecraft.util.math.ChunkPos;
3131
import xyz.omegaware.addon.OmegawareAddons;
32+
import xyz.omegaware.addon.utils.Logger;
3233

3334
import java.io.*;
3435
import java.util.ArrayList;
@@ -149,7 +150,7 @@ private void onChunkData(ChunkDataEvent event) {
149150
autoReconnect.toggle();
150151
}
151152

152-
String prefix = OmegawareAddons.PREFIX.getString();
153+
String prefix = Logger.PREFIX.getString();
153154
MutableText text = Text.literal(String.format("%s%s%s%s %s", Formatting.GRAY, Formatting.BLUE, prefix.substring(0, prefix.length() - 1), Formatting.GRAY, Formatting.RED) + String.format("Found stash at %s, %s.", chunk.x, chunk.z)).append("\n");
154155

155156
disconnectOnStashFound.set(false); // Disable the setting to prevent infinite disconnects

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import meteordevelopment.meteorclient.gui.widgets.containers.WVerticalList;
99
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
1010
import meteordevelopment.meteorclient.settings.*;
11-
import meteordevelopment.meteorclient.utils.player.ChatUtils;
1211
import net.minecraft.text.Text;
1312
import net.minecraft.util.Formatting;
1413
import xyz.omegaware.addon.OmegawareAddons;
@@ -227,10 +226,7 @@ public WWidget getWidget(GuiTheme theme) {
227226

228227
WButton btn = theme.button("Print number of filtered messages");
229228
btn.action = () -> {
230-
Text msg = OmegawareAddons.PREFIX.copy()
231-
.append(Text.literal("Total Filtered Messages: ").formatted(Formatting.GREEN))
232-
.append(Text.literal(filteredCount.toString()).formatted(Formatting.WHITE));
233-
ChatUtils.sendMsg(msg);
229+
Logger.info("%sTotal Filtered Messages: %s%d", Formatting.GREEN, Formatting.WHITE, filteredCount);
234230
};
235231
hList.add(btn);
236232

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import meteordevelopment.meteorclient.settings.Setting;
77
import meteordevelopment.meteorclient.settings.SettingGroup;
88
import meteordevelopment.meteorclient.systems.modules.Module;
9-
import meteordevelopment.meteorclient.utils.player.ChatUtils;
109
import meteordevelopment.meteorclient.utils.player.FindItemResult;
1110
import meteordevelopment.meteorclient.utils.player.InvUtils;
1211
import meteordevelopment.orbit.EventHandler;
@@ -15,8 +14,6 @@
1514
import net.minecraft.item.Item;
1615
import net.minecraft.item.ItemStack;
1716
import net.minecraft.item.Items;
18-
import net.minecraft.text.Text;
19-
import net.minecraft.util.Formatting;
2017
import net.minecraft.util.Hand;
2118
import net.minecraft.util.hit.BlockHitResult;
2219
import net.minecraft.util.math.BlockPos;

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import meteordevelopment.meteorclient.settings.*;
44
import meteordevelopment.meteorclient.systems.friends.Friends;
55
import meteordevelopment.meteorclient.utils.player.ChatUtils;
6-
import net.minecraft.text.Text;
76
import net.minecraft.util.Formatting;
87
import xyz.omegaware.addon.OmegawareAddons;
98
import meteordevelopment.meteorclient.events.game.ReceiveMessageEvent;
@@ -99,9 +98,6 @@ public TPAAutomationModule() {
9998

10099
@Override
101100
public void onActivate() {
102-
Logger.warn("TPAAutomationModule is not yet fully implemented.");
103-
Logger.error("TPAAutomationModule is not yet fully implemented.");
104-
105101
if (isNot6B6T()) {
106102
Logger.error("%s is only intended for use on 6b6t.", name.replace("-", " "));
107103
toggle();
@@ -139,38 +135,19 @@ private void onMessageReceive(ReceiveMessageEvent event) {
139135

140136
String username = matcher.group(1);
141137

142-
if (printTpaDetected.get()) {
143-
Text tpaDetected = OmegawareAddons.PREFIX.copy()
144-
.append(Text.literal("TPA Detected: ").formatted(Formatting.RED))
145-
.append(Text.literal(username).formatted(Formatting.WHITE))
146-
.append(Text.literal("!").formatted(Formatting.WHITE));
147-
148-
ChatUtils.sendMsg(tpaDetected);
149-
}
150-
151-
Text accepted = OmegawareAddons.PREFIX.copy()
152-
.append(Text.literal("Auto-Accepted: ").formatted(Formatting.GREEN))
153-
.append(Text.literal(username).formatted(Formatting.WHITE))
154-
.append(Text.literal("!").formatted(Formatting.WHITE));
155-
156-
Text ignored = OmegawareAddons.PREFIX.copy()
157-
.append(Text.literal("Ignored: ").formatted(Formatting.RED))
158-
.append(Text.literal(username).formatted(Formatting.WHITE))
159-
.append(Text.literal("!").formatted(Formatting.WHITE));
138+
if (printTpaDetected.get()) Logger.info("%sTPA Detected:%s %s!", Formatting.RED, Formatting.WHITE, username);
160139

161140
if (approvedUsers.get().contains(username) || (acceptFriends.get() && Friends.get().get(username) != null) || (acceptTSRBots.get() && TSR_KIT_BOT_USERS.contains(username))) {
162141
ChatUtils.sendPlayerMsg("/tpy " + username);
163142

164-
if (printTpaAccepted.get()) ChatUtils.sendMsg(accepted);
143+
if (printTpaAccepted.get()) Logger.info("%sAuto Accepted:%s %s!", Formatting.GREEN, Formatting.WHITE, username);
165144

166145
} else if (autoDeny.get()){
167146
ChatUtils.sendPlayerMsg("/tpn " + username);
168147

169-
if (printTpaIgnored.get()) ChatUtils.sendMsg(ignored);
148+
if (printTpaIgnored.get()) Logger.info("%sIgnored:%s %s!", Formatting.RED, Formatting.WHITE, username);
170149
}
171150

172-
if (filterTpaMessages.get() && printTpaDetected.get()) {
173-
event.cancel();
174-
}
151+
if (filterTpaMessages.get() && printTpaDetected.get()) event.cancel();
175152
}
176153
}

0 commit comments

Comments
 (0)