Code cleanup in CoordsLog

This commit is contained in:
Dominika 2020-05-18 11:20:47 -04:00
parent c8653e09b3
commit ed95fc0fe5
No known key found for this signature in database
GPG Key ID: B4A5A6DCA70F861F
1 changed files with 11 additions and 4 deletions

View File

@ -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();