Add missing 'enabled' state to various AbstractDebuggers + only send debug info if when enabled

This commit is contained in:
Shadowrs
2018-09-03 03:31:22 +01:00
parent 2997038f0c
commit d0822df743
6 changed files with 134 additions and 39 deletions
+24 -4
View File
@@ -1,27 +1,47 @@
package org.rev317.min.debug;
import org.parabot.core.Context;
import org.parabot.core.paint.AbstractDebugger;
import org.parabot.core.paint.PaintDebugger;
import org.parabot.core.ui.Logger;
import org.rev317.min.api.methods.Npcs;
import org.rev317.min.api.methods.Players;
import org.rev317.min.api.wrappers.Npc;
import java.awt.*;
public class DNpcs extends AbstractDebugger {
private boolean enabled;
private long lastCheck = System.currentTimeMillis();
private int cached;
@Override
public void paint(Graphics g) {
if (System.currentTimeMillis() - lastCheck > 1000L) {
lastCheck = System.currentTimeMillis();
cached = Npcs.getNearest().length;
}
PaintDebugger p = Context.getInstance().getPaintDebugger();
p.addLine("Close NPCs: " + cached);
}
@Override
public boolean isEnabled() {
return false;
return enabled;
}
@Override
public void toggle() {
for (Npc n : Npcs.getNearest()) {
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
enabled = !enabled;
if (enabled) {
if (Npcs.getNearest().length == 0) {
Logger.addMessage("There are no NPCs close to you.");
return;
}
for (Npc n : Npcs.getNearest()) {
System.out.println("ID: " + n.getDef().getId() + " Distance: " + n.distanceTo() + " Location: " + n.getLocation().toString());
}
}
}
}