Cleanup
This commit is contained in:
@@ -30,9 +30,7 @@ public class Config {
|
||||
public boolean coordsEnabled = true;
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
private static final Path PATH = FabricLoader.getInstance()
|
||||
.getConfigDir()
|
||||
.resolve("citrus-dev.json");
|
||||
private static final Path PATH = FabricLoader.getInstance().getConfigDir().resolve("citrus-dev.json");
|
||||
|
||||
private static Config instance;
|
||||
public int fpsP = 4;
|
||||
|
||||
@@ -22,7 +22,6 @@ public class Module_Coords {
|
||||
|
||||
private static final Config CONFIG = Config.get();
|
||||
|
||||
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
|
||||
static boolean toggle = CONFIG.coordsEnabled;
|
||||
private static boolean shown = false;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ public class Module_FPS {
|
||||
|
||||
private static final Config CONFIG = Config.get();
|
||||
|
||||
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
|
||||
static boolean toggle = CONFIG.fpsEnabled;
|
||||
private static boolean shown = false;
|
||||
|
||||
|
||||
@@ -23,11 +23,10 @@ public class Module_KeyStrokes {
|
||||
private static FlowLayout bottomRow;
|
||||
|
||||
private static FlowLayout wBox, aBox, sBox, dBox;
|
||||
private static ScalableLabel wLabel, aLabel, sLabel, dLabel; // was LabelComponent
|
||||
private static ScalableLabel wLabel, aLabel, sLabel, dLabel;
|
||||
|
||||
private static final Config CONFIG = Config.get();
|
||||
|
||||
// Loaded from Config instead of hardcoded, so the toggle survives a restart.
|
||||
static boolean toggle = CONFIG.keyEnabled;
|
||||
private static boolean shown = false;
|
||||
|
||||
@@ -48,7 +47,7 @@ public class Module_KeyStrokes {
|
||||
private static final Surface GLASS_PANEL = Surface.blur(5f, 15f)
|
||||
.and(Surface.flat(0x40FFFFFF));
|
||||
|
||||
private static int keySize = 16; // was: private static final int KEY_SIZE = 16;
|
||||
private static int keySize = 16;
|
||||
private static FlowLayout leftSpacer, rightSpacer;
|
||||
private static final int PRESSED_COLOR = 0x70FFFFFF;
|
||||
private static final int IDLE_COLOR = 0x40FFFFFF;
|
||||
@@ -118,7 +117,7 @@ public class Module_KeyStrokes {
|
||||
}
|
||||
|
||||
private static float labelScaleFor(int size) {
|
||||
return size / 16f; // 16px box = 1.0x scale (matches the default keySize)
|
||||
return size / 16f;
|
||||
}
|
||||
|
||||
public static void setKeySize(int size) {
|
||||
@@ -144,8 +143,7 @@ public class Module_KeyStrokes {
|
||||
if (keyContainer == null) return;
|
||||
|
||||
if (toggle && !shown) {
|
||||
keyContainer.clearChildren(); // <-- safety net against duplicate adds
|
||||
// keyContainer.surface(GLASS_PANEL);
|
||||
keyContainer.clearChildren();
|
||||
keyContainer.padding(Insets.of(4));
|
||||
keyContainer.child(topRow);
|
||||
keyContainer.child(bottomRow);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package de.fullrisk.citrusDev.UI;
|
||||
|
||||
import io.wispforest.owo.ui.base.BaseOwoScreen;
|
||||
import io.wispforest.owo.ui.component.UIComponents;
|
||||
import io.wispforest.owo.ui.container.FlowLayout;
|
||||
import io.wispforest.owo.ui.container.UIContainers;
|
||||
import io.wispforest.owo.ui.core.HorizontalAlignment;
|
||||
import io.wispforest.owo.ui.core.OwoUIAdapter;
|
||||
import io.wispforest.owo.ui.core.VerticalAlignment;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import io.wispforest.owo.ui.core.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
|
||||
import net.minecraft.network.chat.FontDescription;
|
||||
import net.minecraft.resources.Identifier;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import de.fullrisk.citrusDev.UIHelper.ScalableLabel;
|
||||
import de.fullrisk.citrusDev.UIHelper.ScalableButton;
|
||||
import de.fullrisk.citrusDev.UIHelper.ScaleValue;
|
||||
|
||||
public class OverviewScreen{
|
||||
|
||||
}
|
||||
@@ -18,7 +18,6 @@ public class QuestsPanel {
|
||||
|
||||
private static final int ACCENT = 0x64de4b;
|
||||
|
||||
// holds the currently open panel's Handle (if any) so tick() can refresh it
|
||||
private static Handle activeHandle;
|
||||
private static int tickCounter = 0;
|
||||
|
||||
@@ -43,8 +42,6 @@ public class QuestsPanel {
|
||||
this.barWidth = barWidth;
|
||||
this.quests = quests;
|
||||
|
||||
// seed with whatever's already unlocked on open, so we don't spam
|
||||
// toasts for quests the player unlocked before opening this screen
|
||||
for (QuestData quest : quests) {
|
||||
if (quest.isUnlocked()) {
|
||||
notifiedTitles.add(quest.title());
|
||||
|
||||
@@ -74,7 +74,6 @@ public class CitrusToast implements Toast {
|
||||
int w = WIDTH;
|
||||
int h = HEIGHT;
|
||||
|
||||
// glass background, matching GLASS_PANEL style
|
||||
owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF);
|
||||
owo.drawRectOutline(RenderPipelines.GUI, x, y, w, h, 0x64de4b);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.sounds.SoundEvents;
|
||||
|
||||
public class ModuleRow {
|
||||
|
||||
/** Bridge to whatever boolean field actually holds the module's on/off state. */
|
||||
public interface ToggleState {
|
||||
boolean get();
|
||||
void set(boolean value);
|
||||
|
||||
@@ -104,7 +104,6 @@ public class SettingsControls {
|
||||
return button;
|
||||
}
|
||||
|
||||
// keep the old call sites compiling; defaults to index 0
|
||||
public static FlowLayout makeCyclingButton(Surface baseSurface, List<ButtonState> states) {
|
||||
return makeCyclingButton(baseSurface, states, 0);
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ public class CitrusDevClient implements ClientModInitializer {
|
||||
while (openScreenKey.consumeClick()) {
|
||||
if (client.player != null && client.player.isShiftKeyDown()) {
|
||||
String lastModule = Config.get().lastModule;
|
||||
client.setScreen(new MyScreen(lastModule)); // sneak + RShift: last module
|
||||
client.setScreen(new MyScreen(lastModule));
|
||||
} else {
|
||||
client.setScreen(new MyScreen(null)); // RShift alone: general tab
|
||||
client.setScreen(new MyScreen(null));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,3 @@
|
||||
// PLACE THIS FILE AT:
|
||||
// src/client/java/de/fullrisk/citrusDev/client/PlaytimeTracker.java
|
||||
//
|
||||
// NOT under src/main/java — MinecraftClient and client.player only exist
|
||||
// on the client source set. That is the actual cause of the
|
||||
// "Cannot resolve symbol" errors, not a mistake in this code.
|
||||
|
||||
package de.fullrisk.citrusDev.client;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -19,15 +12,9 @@ import com.google.gson.JsonParser;
|
||||
|
||||
public class PlaytimeTracker {
|
||||
|
||||
//ticks zu backend schicken
|
||||
private static final String BACKEND_URL = "http://62.116.42.223:25501/api/heartbeat";
|
||||
|
||||
private static final String BACKEND_URL =
|
||||
"http://62.116.42.223:25501/api/heartbeat";
|
||||
|
||||
private static final HttpClient HTTP =
|
||||
HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
|
||||
|
||||
private static int ticks = 0;
|
||||
private static int currentPlaytimeSeconds = 0;
|
||||
@@ -42,16 +29,14 @@ public class PlaytimeTracker {
|
||||
if (ticks >= 60) {
|
||||
ticks = 0;
|
||||
sendHeartbeat();
|
||||
getPlaytime(); // <-- add this
|
||||
|
||||
getPlaytime();
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendHeartbeat() {
|
||||
Verifier.sendTokenForVerification();
|
||||
|
||||
Minecraft client =
|
||||
Minecraft.getInstance();
|
||||
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
|
||||
if (client.player == null) {
|
||||
System.out.println("No player yet");
|
||||
@@ -86,15 +71,9 @@ public class PlaytimeTracker {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//playtime vom server holen
|
||||
|
||||
private static final String PLAYTIME_URL =
|
||||
"http://62.116.42.223:25501/api/player/%s/playtime";
|
||||
|
||||
private static final String PLAYTIME_URL = "http://62.116.42.223:25501/api/player/%s/playtime";
|
||||
|
||||
public static void getPlaytime() {
|
||||
|
||||
Minecraft client = Minecraft.getInstance();
|
||||
|
||||
if (client.player == null) {
|
||||
@@ -103,57 +82,24 @@ public class PlaytimeTracker {
|
||||
|
||||
UUID uuid = client.player.getUUID();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(URI.create(
|
||||
PLAYTIME_URL.formatted(uuid)
|
||||
))
|
||||
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(PLAYTIME_URL.formatted(uuid)))
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
|
||||
HTTP.sendAsync(
|
||||
request,
|
||||
HttpResponse.BodyHandlers.ofString()
|
||||
)
|
||||
HTTP.sendAsync(request, HttpResponse.BodyHandlers.ofString())
|
||||
.thenAccept(response -> {
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
|
||||
String json = response.body();
|
||||
|
||||
JsonObject data =
|
||||
JsonParser.parseString(json)
|
||||
.getAsJsonObject();
|
||||
JsonObject data = JsonParser.parseString(json).getAsJsonObject();
|
||||
|
||||
|
||||
currentPlaytimeSeconds =
|
||||
data.get("playtime_seconds")
|
||||
.getAsInt();
|
||||
|
||||
|
||||
// Compare playtime here
|
||||
if (currentPlaytimeSeconds >= 3600) {
|
||||
System.out.println(
|
||||
"Player has more than 1 hour!"
|
||||
);
|
||||
}
|
||||
else {
|
||||
System.out.println(
|
||||
"Player needs more time"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
System.out.println(
|
||||
"Seconds played: " + currentPlaytimeSeconds
|
||||
);
|
||||
currentPlaytimeSeconds = data.get("playtime_seconds").getAsInt();
|
||||
|
||||
} else {
|
||||
System.out.println(
|
||||
"Failed: " + response.statusCode()
|
||||
);
|
||||
System.err.println("Failed: " + response.statusCode());
|
||||
throw new RuntimeException("Failed to get playtime: " + response.statusCode());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ public class Verifier {
|
||||
|
||||
private static final String VERIFY_URL = "http://62.116.42.223:25501/api/verify";
|
||||
|
||||
private static final HttpClient HTTP = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
private static final HttpClient HTTP = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(10)).build();
|
||||
|
||||
public static void sendTokenForVerification() {
|
||||
String accessToken = Authentication.getAccessToken();
|
||||
|
||||
@@ -27,10 +27,8 @@ public abstract class SliderComponentMixin {
|
||||
|
||||
OwoUIGraphics owo = OwoUIGraphics.of(graphics);
|
||||
|
||||
// glass track
|
||||
owo.fill(RenderPipelines.GUI, x, y, x + w, y + h, 0x40FFFFFF);
|
||||
|
||||
// handle
|
||||
int handleWidth = 4;
|
||||
int handleX = x + (int) (slider.value() * (w - handleWidth));
|
||||
owo.fill(RenderPipelines.GUI, handleX, y, handleX + handleWidth, y + h, 0xFFFFFFFF);
|
||||
|
||||
Reference in New Issue
Block a user