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;
|
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 {
|
public class CoordsLog extends Module {
|
||||||
private Setting<Boolean> forceLogOnDeath = register(Settings.b("onDeath", true));
|
private Setting<Boolean> forceLogOnDeath = register(Settings.b("onDeath", true));
|
||||||
private Setting<Boolean> deathInChat = register(Settings.b("logDeathInChat", true));
|
private Setting<Boolean> deathInChat = register(Settings.b("logDeathInChat", true));
|
||||||
|
@ -24,20 +29,21 @@ public class CoordsLog extends Module {
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
if (mc.player == null)
|
if (mc.player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (autoLog.getValue()) {
|
if (autoLog.getValue()) {
|
||||||
timeout();
|
timeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < mc.player.getHealth() && playerIsDead) {
|
if (0 < mc.player.getHealth() && playerIsDead) {
|
||||||
playerIsDead = false;
|
playerIsDead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playerIsDead && 0 >= mc.player.getHealth() && forceLogOnDeath.getValue()) {
|
if (!playerIsDead && 0 >= mc.player.getHealth() && forceLogOnDeath.getValue()) {
|
||||||
Coordinate deathPoint = logCoordinates("deathPoint");
|
Coordinate deathPoint = logCoordinates("deathPoint");
|
||||||
if (deathInChat.getValue()) {
|
if (deathInChat.getValue()) {
|
||||||
sendChatMessage("You died at " + deathPoint.x + " " + deathPoint.y + " " + deathPoint.z);
|
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() {
|
private void timeout() {
|
||||||
if (startTime == 0)
|
if (startTime == 0)
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
if (startTime + (delay.getValue() * 1000) <= System.currentTimeMillis()) { // 1 timeout = 1 second = 1000 ms
|
if (startTime + (delay.getValue() * 1000) <= System.currentTimeMillis()) { // 1 timeout = 1 second = 1000 ms
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
Coordinate pos = CoordUtil.getCurrentCoord();
|
Coordinate pos = CoordUtil.getCurrentCoord();
|
||||||
|
|
Loading…
Reference in New Issue