mirror of https://github.com/kami-blue/client
Code cleanup in CoordsLog
This commit is contained in:
parent
c8653e09b3
commit
ed95fc0fe5
|
@ -8,7 +8,12 @@ import me.zeroeightsix.kami.util.Coordinate;
|
|||
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
||||
|
||||
@Module.Info(name = "CoordsLog", description = "Automatically writes the coordinates of the player to a file with a user defined delay between logs.", category = Module.Category.EXPERIMENTAL, showOnArray = Module.ShowOnArray.ON)
|
||||
@Module.Info(
|
||||
name = "CoordsLog",
|
||||
description = "Automatically writes the coordinates of the player to a file with a user defined delay between logs.",
|
||||
category = Module.Category.EXPERIMENTAL,
|
||||
showOnArray = Module.ShowOnArray.ON
|
||||
)
|
||||
public class CoordsLog extends Module {
|
||||
private Setting<Boolean> forceLogOnDeath = register(Settings.b("onDeath", true));
|
||||
private Setting<Boolean> deathInChat = register(Settings.b("logDeathInChat", true));
|
||||
|
@ -24,20 +29,21 @@ public class CoordsLog extends Module {
|
|||
public void onUpdate() {
|
||||
if (mc.player == null)
|
||||
return;
|
||||
|
||||
if (autoLog.getValue()) {
|
||||
timeout();
|
||||
}
|
||||
|
||||
if (0 < mc.player.getHealth() && playerIsDead) {
|
||||
playerIsDead = false;
|
||||
}
|
||||
|
||||
if (!playerIsDead && 0 >= mc.player.getHealth() && forceLogOnDeath.getValue()) {
|
||||
Coordinate deathPoint = logCoordinates("deathPoint");
|
||||
if (deathInChat.getValue()) {
|
||||
sendChatMessage("You died at " + deathPoint.x + " " + deathPoint.y + " " + deathPoint.z);
|
||||
playerIsDead = true;
|
||||
} else {
|
||||
playerIsDead = true;
|
||||
}
|
||||
playerIsDead = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +52,7 @@ public class CoordsLog extends Module {
|
|||
private void timeout() {
|
||||
if (startTime == 0)
|
||||
startTime = System.currentTimeMillis();
|
||||
|
||||
if (startTime + (delay.getValue() * 1000) <= System.currentTimeMillis()) { // 1 timeout = 1 second = 1000 ms
|
||||
startTime = System.currentTimeMillis();
|
||||
Coordinate pos = CoordUtil.getCurrentCoord();
|
||||
|
|
Loading…
Reference in New Issue