From 408204a8f11c685358e23f917c63bac4bb4baa48 Mon Sep 17 00:00:00 2001 From: Lezurex Date: Sat, 30 Jan 2021 19:41:47 +0100 Subject: [PATCH] Add party detector Fix int parsing bug in Swiss German --- config/splash.properties | 2 +- options.txt | 12 +++---- .../events/MessageReceiveEventHandler.java | 31 ++++++++++++------- .../statsaddon/utils/StatsDisplayUtil.java | 9 ++++-- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/config/splash.properties b/config/splash.properties index c5ce458..4714dd5 100644 --- a/config/splash.properties +++ b/config/splash.properties @@ -1,5 +1,5 @@ #Splash screen properties -#Sat Jan 30 19:04:06 CET 2021 +#Sat Jan 30 19:19:39 CET 2021 logoTexture=textures/gui/title/mojang.png background=0xFFFFFF font=0x0 diff --git a/options.txt b/options.txt index 7144b80..c865a39 100644 --- a/options.txt +++ b/options.txt @@ -90,15 +90,15 @@ key_key.hotbar.6:7 key_key.hotbar.7:8 key_key.hotbar.8:9 key_key.hotbar.9:10 -soundCategory_master:0.08278146 +soundCategory_master:0.3245033 soundCategory_music:0.0 -soundCategory_record:0.15492958 +soundCategory_record:1.0 soundCategory_weather:0.0 -soundCategory_block:0.16197184 +soundCategory_block:1.0 soundCategory_hostile:0.0 -soundCategory_neutral:0.15492958 -soundCategory_player:0.0 -soundCategory_ambient:0.14788732 +soundCategory_neutral:1.0 +soundCategory_player:1.0 +soundCategory_ambient:1.0 modelPart_cape:true modelPart_jacket:true modelPart_left_sleeve:true diff --git a/src/main/java/com/voxcrafterlp/statsaddon/events/MessageReceiveEventHandler.java b/src/main/java/com/voxcrafterlp/statsaddon/events/MessageReceiveEventHandler.java index 671fedd..7a9dfbf 100644 --- a/src/main/java/com/voxcrafterlp/statsaddon/events/MessageReceiveEventHandler.java +++ b/src/main/java/com/voxcrafterlp/statsaddon/events/MessageReceiveEventHandler.java @@ -26,7 +26,7 @@ public void register() { @Override public boolean onReceive(String formatted, String unFormatted) { - if(StatsAddon.getInstance().getCurrentGamemode() != null && unFormatted.contains("»") && !unFormatted.contains(LabyMod.getInstance().getPlayerName())) { + if (StatsAddon.getInstance().getCurrentGamemode() != null && unFormatted.contains("»") && !unFormatted.contains(LabyMod.getInstance().getPlayerName())) { new Thread(() -> { try { Thread.sleep(StatsAddon.getInstance().cooldown); @@ -36,7 +36,7 @@ public boolean onReceive(String formatted, String unFormatted) { List playerInfos = Lists.newCopyOnWriteArrayList(); Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap().forEach((loadedPlayer) -> { - if(!StatsAddon.getInstance().getPlayersJoined().contains(loadedPlayer)) { + if (!StatsAddon.getInstance().getPlayersJoined().contains(loadedPlayer)) { playerInfos.add(loadedPlayer); StatsAddon.getInstance().getPlayersJoined().add(loadedPlayer); } @@ -46,27 +46,34 @@ public boolean onReceive(String formatted, String unFormatted) { new StatsDisplayUtil().displayStats(playerInfos); }).start(); } - if(StatsAddon.getInstance().getCurrentGamemode() != null && StatsAddon.getInstance().enabled) { + if (StatsAddon.getInstance().getCurrentGamemode() != null && StatsAddon.getInstance().enabled) { new Thread(() -> { - if(unFormatted.toLowerCase().contains("-=")) { + if (unFormatted.toLowerCase().contains("-=")) { lastPlayerName = getNameFromStatsLine(unFormatted); } - if(unFormatted.toLowerCase().contains("ranking:") && unFormatted.startsWith(" ")) { + if (unFormatted.toLowerCase().contains("ranking:") && unFormatted.startsWith(" ")) { String[] content = formatted.split("\u00A7e"); - if(content.length == 2) { + if (content.length == 2) { - if(!content[1].contains("-")) { - int rank = Integer.parseInt(content[1].replace("\u00A7e", "").replace(" ", "").replace(".", "").replace(",", "").replace("'", "").replace("\u00A7r", "")); - if(rank < StatsAddon.getInstance().warnLevel) { + if (!content[1].contains("-")) { + int rank = Integer.parseInt(content[1] + .replace("\u00A7e", "") + .replace(" ", "") + .replace(".", "") + .replace(",", "") + .replace("'", "") + .replace("\u00A7r", "") + .replace("`", "")); + if (rank < StatsAddon.getInstance().warnLevel) { try { Thread.sleep(20); } catch (InterruptedException exception) { exception.printStackTrace(); } - if(!lastPlayerName.equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getName())) { + if (!lastPlayerName.equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getName())) { LabyMod.getInstance().displayMessageInChat(StatsAddon.getInstance().getGamemodePrefix() + "\u00A74Achtung! \u00A77Potentiell gef\u00E4hrlicher Gegner\u00A77!"); LabyMod.getInstance().displayMessageInChat(StatsAddon.getInstance().getGamemodePrefix() + "\u00A77Platz \u00A7e#" + rank + " \u00A77Name\u00A78: \u00A7c" + lastPlayerName); - if(StatsAddon.getInstance().alertEnabled) { + if (StatsAddon.getInstance().alertEnabled) { new Thread(() -> { for (int i = 0; i < 5; i++) { Minecraft.getMinecraft().thePlayer.playSound("note.pling", 1, 1); @@ -91,7 +98,7 @@ public boolean onReceive(String formatted, String unFormatted) { } private String getNameFromStatsLine(String string) { - if(string.contains("-=")) { + if (string.contains("-=")) { String[] words = string.split(" "); return words[3].replace("\u00A76", ""); } diff --git a/src/main/java/com/voxcrafterlp/statsaddon/utils/StatsDisplayUtil.java b/src/main/java/com/voxcrafterlp/statsaddon/utils/StatsDisplayUtil.java index 8489d15..f7bbf57 100644 --- a/src/main/java/com/voxcrafterlp/statsaddon/utils/StatsDisplayUtil.java +++ b/src/main/java/com/voxcrafterlp/statsaddon/utils/StatsDisplayUtil.java @@ -19,10 +19,13 @@ public void displayStats(List playerInfos) { new Thread(() -> { for(NetworkPlayerInfo playerInfo: playerInfos) { if (StatsAddon.getInstance().getCurrentGamemode() != null) { - if (!playerInfo.getPlayerTeam().getColorSuffix().toLowerCase().replace("i", "y").replace("á", "a").contains("party")) { - if (playerInfo.getGameProfile() != Minecraft.getMinecraft().thePlayer.getGameProfile()) { + if (!playerInfo.getPlayerTeam().getColorSuffix().toLowerCase() + .replace("i", "y") + .replace("á", "a") + .contains("party")) { + if (!playerInfo.getGameProfile().getName().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getName())) { if (!StatsAddon.getInstance().checkedPlayers.contains(playerInfo)) { - Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + this.getCommand(playerInfo.getDisplayName().toString())); + Minecraft.getMinecraft().thePlayer.sendChatMessage("/" + this.getCommand(playerInfo.getGameProfile().getName())); playerInfos.remove(playerInfo); StatsAddon.getInstance().checkedPlayers.add(playerInfo); try {