Skip to content

Commit 4cd4144

Browse files
committed
Updated AutoLogMixin for recent AutoLog changes
1 parent e16a723 commit 4cd4144

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/main/java/dev/stardust/mixin/meteor/AutoLogMixin.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public AutoLogMixin(Category category, String name, String description) {
4141
@Shadow
4242
@Final
4343
private Setting<Boolean> toggleOff;
44+
@Shadow
45+
@Final
46+
private Setting<Boolean> smartToggle;
4447

4548
@Unique
4649
private boolean didLog = false;
@@ -53,7 +56,7 @@ public AutoLogMixin(Category category, String name, String description) {
5356

5457
@Override
5558
public void onDeactivate() {
56-
if (toggleOff.get() && didLog) {
59+
if (toggleOff.get() || smartToggle.get() && didLog) {
5760
MeteorClient.EVENT_BUS.subscribe(this);
5861
}
5962
}
@@ -71,16 +74,15 @@ private void addIllegalDisconnectSetting(CallbackInfo ci) {
7174

7275
@Inject(method = "onTick",at = @At("HEAD"), cancellable = true)
7376
private void preventNullPointerExceptions(CallbackInfo ci) {
74-
if (!Utils.canUpdate()) ci.cancel();
77+
if (!Utils.canUpdate() || !isActive()) ci.cancel();
7578
}
7679

77-
@Inject(method = "disconnect", at = @At("HEAD"), cancellable = true)
78-
private void maybeForceKick(String reason, CallbackInfo ci) {
80+
@Inject(method = "disconnect(Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true, remap = true)
81+
private void maybeIllegalDisconnect(Text reason, CallbackInfo ci) {
7982
if (forceKick != null && forceKick.get()) {
8083
ci.cancel();
8184
didLog = true;
82-
if (toggleOff.get()) toggle();
83-
disconnectReason = Text.literal("§8[§aAutoLog§8] §f" + reason);
85+
disconnectReason = Text.literal("§8[§a§oAutoLog§8] §f" + reason.getString());
8486
StardustUtil.illegalDisconnect(true, Stardust.illegalDisconnectMethodSetting.get());
8587
}
8688
}
@@ -91,7 +93,7 @@ private void onPacketReceive(PacketEvent.Receive event) {
9193
if (disconnectReason == null || !(event.packet instanceof DisconnectS2CPacket packet)) return;
9294
if (didLog) {
9395
((DisconnectS2CPacketAccessor)(Object) packet).setReason(disconnectReason);
94-
MeteorClient.EVENT_BUS.unsubscribe(this);
96+
if (!isActive()) MeteorClient.EVENT_BUS.unsubscribe(this);
9597
disconnectReason = null;
9698
didLog = false;
9799
}

0 commit comments

Comments
 (0)