diff --git a/src/UnitInfo/core/HudUi.java b/src/UnitInfo/core/HudUi.java index a7d680f..d5f3437 100644 --- a/src/UnitInfo/core/HudUi.java +++ b/src/UnitInfo/core/HudUi.java @@ -51,6 +51,7 @@ public class HudUi { Teamc lockedTarget; ImageButton lockButton; boolean locked = false; + float charge; float a; int uiIndex = 0; @@ -59,7 +60,6 @@ public class HudUi { int waveamount; int coreamount; - BarInfo info = new BarInfo(); Seq strings = new Seq<>(new String[]{"","","","","",""}); Seq numbers = new Seq<>(new Float[]{0f,0f,0f,0f,0f,0f}); Seq colors = new Seq<>(new Color[]{Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear}); @@ -475,9 +475,9 @@ public class HudUi { }).padRight(Scl.scl(24 * 8f)); table.row(); table.update(() -> { - strings = info.returnStrings(getTarget()); - numbers = info.returnNumbers(getTarget()); - colors = info.returnColors(getTarget()); + strings = BarInfo.returnStrings(getTarget()); + numbers = BarInfo.returnNumbers(getTarget()); + colors = BarInfo.returnColors(getTarget()); if(getTarget() instanceof Turret.TurretBuild){ if(((Turret.TurretBuild) getTarget()).charging) charge += Time.delta; else charge = 0f; diff --git a/src/UnitInfo/core/PlayerParser.java b/src/UnitInfo/core/PlayerParser.java index 9bb85a5..0a50451 100644 --- a/src/UnitInfo/core/PlayerParser.java +++ b/src/UnitInfo/core/PlayerParser.java @@ -2,6 +2,7 @@ package UnitInfo.core; import UnitInfo.SVars; import arc.Events; +import arc.struct.ObjectMap; import arc.struct.Seq; import mindustry.Vars; import mindustry.game.EventType; @@ -14,20 +15,19 @@ import org.hjson.Stringify; import static UnitInfo.SVars.modRoot; public class PlayerParser{ - + ObjectMap> chats = new ObjectMap<>(); public void setEvent() { - Events.on(EventType.PlayerJoin.class, e -> { + Events.on(EventType.PlayerChatEvent.class, e -> { + if(chats.containsKey(e.player)) chats.get(e.player).add(e.message); + else chats.put(e.player, Seq.with(e.message)); writeJson(e.player); + save(); }); - Events.on(EventType.ServerLoadEvent.class, e->{ - Groups.player.each(this::writeJson); - }); - Events.on(EventType.WorldLoadEvent.class, e->{ - if(Vars.net.active()) Groups.player.each(this::writeJson); - }); + Events.run(EventType.Trigger.update, ()->{ - if(Vars.net.active()) - Groups.player.each(this::writeJson); + if(Vars.net.active()) Groups.player.each(this::writeJson); + + save(); }); } @@ -46,17 +46,18 @@ public class PlayerParser{ names.add(player1.name); }}); } - save(); } public void save() { JsonObject data = new JsonObject(); SVars.playerInfos.each(pi->{ JsonArray arr = new JsonArray(); + JsonArray chatArr = new JsonArray(); pi.names.each(arr::add); + if(chats.get(pi.player) != null) chats.get(pi.player).each(chatArr::add); data.add("names", arr); + data.add("chats", chatArr); }); - modRoot.child("players.hjson").writeString(data.toString(Stringify.HJSON)); } public static class PlayerInfo{