|
| 1 | +package net.runelite.client.plugins.microbot.SulphurNaguaAIO; // Stelle sicher, dass der Paketname stimmt |
| 2 | + |
| 3 | +import net.runelite.client.plugins.microbot.Microbot; |
| 4 | +import net.runelite.client.ui.overlay.OverlayPanel; |
| 5 | +import net.runelite.client.ui.overlay.OverlayPosition; |
| 6 | +import net.runelite.client.ui.overlay.components.LineComponent; |
| 7 | +import net.runelite.client.plugins.microbot.SulphurNaguaAIO.SulphurNaguaScript.SulphurNaguaState; // WICHTIGER IMPORT |
| 8 | + |
| 9 | +import javax.inject.Inject; |
| 10 | +import java.awt.*; |
| 11 | + |
| 12 | +public class SulphurNaguaOverlay extends OverlayPanel { |
| 13 | + // Farben und Konstanten |
| 14 | + private static final Color BACKGROUND_COLOR = new Color(0, 0, 0, 150); |
| 15 | + private static final Color NORMAL_COLOR = Color.WHITE; |
| 16 | + private static final Color WARNING_COLOR = Color.YELLOW; |
| 17 | + private static final Color DANGER_COLOR = Color.RED; |
| 18 | + private static final Color SUCCESS_COLOR = Color.GREEN; |
| 19 | + private static final Color PREPARATION_COLOR = new Color(0, 170, 255); // Hellblau für Vorbereitung |
| 20 | + |
| 21 | + private final SulphurNaguaPlugin plugin; |
| 22 | + |
| 23 | + @Inject |
| 24 | + SulphurNaguaOverlay(SulphurNaguaPlugin plugin) { |
| 25 | + super(plugin); |
| 26 | + setPosition(OverlayPosition.TOP_LEFT); |
| 27 | + setNaughty(); |
| 28 | + this.plugin = plugin; |
| 29 | + } |
| 30 | + |
| 31 | + @Override |
| 32 | + public Dimension render(Graphics2D graphics) { |
| 33 | + try { |
| 34 | + panelComponent.setPreferredSize(new Dimension(200, 300)); |
| 35 | + panelComponent.setBackgroundColor(BACKGROUND_COLOR); |
| 36 | + |
| 37 | + // Titel - Korrigierte, einfache Darstellung |
| 38 | + panelComponent.getChildren().add(LineComponent.builder() |
| 39 | + .left("Sulphur Nagua Fighter") |
| 40 | + .leftColor(Color.white) |
| 41 | + .build()); |
| 42 | + |
| 43 | + // Sicherheitsabfrage, um Abstürze zu verhindern, falls das Skript noch nicht initialisiert ist |
| 44 | + if (plugin.sulphurNaguaScript == null) { |
| 45 | + panelComponent.getChildren().add(LineComponent.builder() |
| 46 | + .left("Status:") |
| 47 | + .right("Initialisiere...") |
| 48 | + .build()); |
| 49 | + return super.render(graphics); |
| 50 | + } |
| 51 | + |
| 52 | + // Laufzeit |
| 53 | + panelComponent.getChildren().add(LineComponent.builder() |
| 54 | + .left("Laufzeit:") |
| 55 | + .right(plugin.getTimeRunning()) |
| 56 | + .rightColor(NORMAL_COLOR) |
| 57 | + .build()); |
| 58 | + |
| 59 | + // Aktueller Status |
| 60 | + panelComponent.getChildren().add(LineComponent.builder() |
| 61 | + .left("Status:") |
| 62 | + .right(plugin.sulphurNaguaScript.currentState.name()) |
| 63 | + // ----- HIER IST DIE KORREKTUR ----- |
| 64 | + // Die Farbe wird wieder dynamisch gesetzt |
| 65 | + .rightColor(getStateColor(plugin.sulphurNaguaScript.currentState)) |
| 66 | + .build()); |
| 67 | + |
| 68 | + // Kills |
| 69 | + panelComponent.getChildren().add(LineComponent.builder() |
| 70 | + .left("Kills:") |
| 71 | + .right(String.valueOf(plugin.sulphurNaguaScript.totalNaguaKills)) |
| 72 | + .rightColor(NORMAL_COLOR) |
| 73 | + .build()); |
| 74 | + |
| 75 | + // XP-Informationen |
| 76 | + var xpGained = plugin.getXpGained(); |
| 77 | + var xpPerHour = plugin.getXpPerHour(); |
| 78 | + panelComponent.getChildren().add(LineComponent.builder() |
| 79 | + .left("XP Gained:") |
| 80 | + .right(formatNumber(xpGained)) |
| 81 | + .rightColor(NORMAL_COLOR) |
| 82 | + .build()); |
| 83 | + |
| 84 | + panelComponent.getChildren().add(LineComponent.builder() |
| 85 | + .left("XP/Stunde:") |
| 86 | + .right(formatNumber(xpPerHour)) |
| 87 | + .rightColor(xpPerHour > 0 ? SUCCESS_COLOR : NORMAL_COLOR) |
| 88 | + .build()); |
| 89 | + |
| 90 | + // Footer mit Version |
| 91 | + panelComponent.getChildren().add(LineComponent.builder() |
| 92 | + .right("v" + SulphurNaguaScript.version) |
| 93 | + .rightColor(new Color(160, 160, 160)) |
| 94 | + .build()); |
| 95 | + |
| 96 | + } catch (Exception ex) { |
| 97 | + // Logge den Fehler, damit du im Microbot-Log nachsehen kannst, was schiefgeht |
| 98 | + Microbot.logStackTrace("SulphurNaguaOverlay Fehler:", ex); |
| 99 | + } |
| 100 | + return super.render(graphics); |
| 101 | + } |
| 102 | + |
| 103 | + private String formatNumber(long number) { |
| 104 | + return String.format("%,d", number); |
| 105 | + } |
| 106 | + |
| 107 | + |
| 108 | + private Color getStateColor(SulphurNaguaState state) { |
| 109 | + if (state == null) return NORMAL_COLOR; |
| 110 | + |
| 111 | + switch (state) { |
| 112 | + case FIGHTING: |
| 113 | + return DANGER_COLOR; |
| 114 | + case WALKING: |
| 115 | + return WARNING_COLOR; |
| 116 | + case PREPARATION: |
| 117 | + return PREPARATION_COLOR; |
| 118 | + case BANKING: |
| 119 | + default: |
| 120 | + return NORMAL_COLOR; |
| 121 | + } |
| 122 | + } |
| 123 | +} |
| 124 | + |
0 commit comments