forked from ChomeNS/chipmunkmod
icu slef care
This commit is contained in:
parent
64fd0d1ad4
commit
82b5259b44
2 changed files with 30 additions and 5 deletions
|
@ -37,6 +37,13 @@ public class SelfCareCommand {
|
|||
.executes(m -> setSelfCare(m, "cspy"))
|
||||
)
|
||||
)
|
||||
.then(
|
||||
literal("icu")
|
||||
.then(
|
||||
argument("boolean", bool())
|
||||
.executes(m -> setSelfCare(m, "icu"))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -58,6 +65,10 @@ 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,6 +9,7 @@ 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;
|
||||
|
@ -24,17 +25,20 @@ public class SelfCare extends Listener {
|
|||
public boolean opEnabled = true;
|
||||
public boolean gamemodeEnabled = true;
|
||||
public boolean cspyEnabled = true;
|
||||
public boolean icuEnabled = true;
|
||||
|
||||
private int gameMode;
|
||||
|
||||
public String skin;
|
||||
|
||||
private Timer timer = null;
|
||||
private Timer chatTimer = null;
|
||||
private Timer timer = new Timer();
|
||||
private Timer chatTimer = new Timer();
|
||||
|
||||
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) {
|
||||
|
@ -62,9 +66,6 @@ public class SelfCare extends Listener {
|
|||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
chatTimer = new Timer();
|
||||
|
||||
timer.schedule(task, interval, interval);
|
||||
chatTimer.schedule(chatTask, chatInterval, chatInterval);
|
||||
}
|
||||
|
@ -109,6 +110,7 @@ public class SelfCare extends Listener {
|
|||
|
||||
if (player != null && !player.hasPermissionLevel(2) && opEnabled) { if (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 () {
|
||||
|
@ -122,6 +124,7 @@ public class SelfCare extends 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) {
|
||||
|
@ -133,4 +136,15 @@ public class SelfCare extends Listener {
|
|||
|
||||
gameMode = (int) packet.getValue();
|
||||
}
|
||||
|
||||
public void packetReceived(PlayerPositionLookS2CPacket packet) {
|
||||
positionPacketsPerSecond++;
|
||||
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
positionPacketsPerSecond--;
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue