Changes:
All checks were successful
Build Plugin / build-test (push) Successful in 44s

- Fix Status Color Bug
- Add /playtime
- Add /timer
This commit is contained in:
2024-11-25 12:39:49 +00:00
parent befce5d7d0
commit dc564e7baf
10 changed files with 187 additions and 18 deletions

View File

@ -15,15 +15,20 @@ import java.util.UUID;
public class PlayerConfig {
File file = null;
int cfg_version = 0;
int cfg_version = 1;
public static class PlayerEntry {
public String status = "";
public String name = "";
public PlayerEntry() {}
public PlayerEntry(String s, String n) {
public boolean timer = false;
public PlayerEntry() {
}
public PlayerEntry(String s, String n, boolean t) {
status = s;
name = n;
timer = t;
}
}
@ -44,11 +49,6 @@ public class PlayerConfig {
JsonObject js = prs.parse(r).getAsJsonObject();
r.close();
int pver = js.get("version").getAsInt();
if (pver != cfg_version) {
// Use PVER to not create a complete new config
file.delete();
return false;
}
player_map.clear();
// Load Data
for (Map.Entry<String, JsonElement> e : js.entrySet()) {
@ -59,8 +59,16 @@ public class PlayerConfig {
PlayerEntry pe = new PlayerEntry();
pe.name = e.getValue().getAsJsonObject().get("name").getAsString();
pe.status = e.getValue().getAsJsonObject().get("status").getAsString();
if (pver >= 1) {
pe.timer = e.getValue().getAsJsonObject().get("timer").getAsBoolean();
}
player_map.put(key, pe);
}
if (pver != cfg_version) {
// Use PVER to update Config
Save();
return false;
}
} catch (IOException e) {
e.printStackTrace();
return true;
@ -75,6 +83,7 @@ public class PlayerConfig {
JsonObject o = new JsonObject();
o.addProperty("name", e.getValue().name);
o.addProperty("status", e.getValue().status);
o.addProperty("timer", e.getValue().timer);
js.add(e.getKey().toString(), o);
}
try {
@ -103,6 +112,7 @@ public class PlayerConfig {
public String getStatus(UUID ref) {
return this.player_map.get(ref).status;
}
public void setStatus(UUID ref, String value) {
this.player_map.get(ref).status = value;
}
@ -110,7 +120,16 @@ public class PlayerConfig {
public String getName(UUID ref) {
return this.player_map.get(ref).name;
}
public void setName(UUID ref, String value) {
this.player_map.get(ref).name = value;
}
public boolean getTimer(UUID ref) {
return this.player_map.get(ref).timer;
}
public void setTimer(UUID ref, boolean value) {
this.player_map.get(ref).timer = value;
}
}