mirror of
https://code.chipmunk.land/ChomeNS/chipmunkmod.git
synced 2025-11-13 17:36:16 +00:00
refactor: remove the infamous icu self care ported from SMP
This commit is contained in:
parent
c9594fe248
commit
d6a93ffef9
2 changed files with 0 additions and 37 deletions
|
|
@ -37,17 +37,9 @@ public class SelfCareCommand {
|
|||
.executes(m -> setSelfCare(m, "cspy"))
|
||||
)
|
||||
)
|
||||
.then(
|
||||
literal("icu")
|
||||
.then(
|
||||
argument("boolean", bool())
|
||||
.executes(m -> setSelfCare(m, "icu"))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// setSelfCare is probably not a good name for this
|
||||
public static int setSelfCare (CommandContext<FabricClientCommandSource> context, String type) {
|
||||
final FabricClientCommandSource source = context.getSource();
|
||||
final boolean bool = getBool(context, "boolean");
|
||||
|
|
@ -65,10 +57,6 @@ public class SelfCareCommand {
|
|||
SelfCare.INSTANCE.cspyEnabled = bool;
|
||||
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
case "icu" -> {
|
||||
SelfCare.INSTANCE.icuEnabled = bool;
|
||||
source.sendFeedback(Text.literal("The iControlU self care is now " + (bool ? "enabled" : "disabled")));
|
||||
}
|
||||
}
|
||||
|
||||
return Command.SINGLE_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import net.minecraft.client.network.ClientPlayerEntity;
|
|||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.Timer;
|
||||
|
|
@ -25,7 +24,6 @@ public class SelfCare implements Listener {
|
|||
public boolean opEnabled = true;
|
||||
public boolean gamemodeEnabled = true;
|
||||
public boolean cspyEnabled = true;
|
||||
public boolean icuEnabled = true;
|
||||
|
||||
private int gameMode;
|
||||
|
||||
|
|
@ -33,13 +31,10 @@ public class SelfCare implements Listener {
|
|||
|
||||
private Timer timer;
|
||||
private Timer chatTimer;
|
||||
private Timer icuTimer;
|
||||
|
||||
private boolean cspy = false;
|
||||
public boolean hasSkin = false;
|
||||
|
||||
private int positionPacketsPerSecond = 0;
|
||||
|
||||
public static final SelfCare INSTANCE = new SelfCare(MinecraftClient.getInstance(), 70L, 500L); // make the intervals in config?
|
||||
|
||||
public SelfCare(MinecraftClient client, long interval, long chatInterval) {
|
||||
|
|
@ -68,20 +63,11 @@ public class SelfCare implements Listener {
|
|||
}
|
||||
};
|
||||
|
||||
final TimerTask icuTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
positionPacketsPerSecond = 0;
|
||||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
chatTimer = new Timer();
|
||||
icuTimer = new Timer();
|
||||
|
||||
timer.schedule(task, interval, interval);
|
||||
chatTimer.schedule(chatTask, chatInterval, chatInterval);
|
||||
icuTimer.schedule(icuTask, 1000L, 1000L);
|
||||
}
|
||||
|
||||
public void cleanup() {
|
||||
|
|
@ -93,9 +79,6 @@ public class SelfCare implements Listener {
|
|||
chatTimer.cancel();
|
||||
chatTimer.purge();
|
||||
|
||||
icuTimer.cancel();
|
||||
icuTimer.purge();
|
||||
|
||||
gameMode = -1;
|
||||
|
||||
hasSkin = false;
|
||||
|
|
@ -127,7 +110,6 @@ public class SelfCare implements Listener {
|
|||
|
||||
if (player != null && !player.hasPermissionLevel(2) && opEnabled && serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]");
|
||||
else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
|
||||
else if (positionPacketsPerSecond >= 10 && icuEnabled) CommandCore.INSTANCE.run("sudo * icu stop");
|
||||
}
|
||||
|
||||
public void chatTick() {
|
||||
|
|
@ -144,7 +126,6 @@ public class SelfCare implements Listener {
|
|||
public void packetReceived(Packet<?> packet) {
|
||||
if (packet instanceof GameJoinS2CPacket) packetReceived((GameJoinS2CPacket) packet);
|
||||
else if (packet instanceof GameStateChangeS2CPacket) packetReceived((GameStateChangeS2CPacket) packet);
|
||||
else if (packet instanceof PlayerPositionLookS2CPacket) packetReceived((PlayerPositionLookS2CPacket) packet);
|
||||
}
|
||||
|
||||
public void packetReceived(GameJoinS2CPacket packet) {
|
||||
|
|
@ -156,10 +137,4 @@ public class SelfCare implements Listener {
|
|||
|
||||
gameMode = (int) packet.getValue();
|
||||
}
|
||||
|
||||
public void packetReceived(PlayerPositionLookS2CPacket packet) {
|
||||
if (timer == null) return;
|
||||
|
||||
positionPacketsPerSecond++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue