From 8fd4227388d27093fb4b322d4d18da2871b1a6e2 Mon Sep 17 00:00:00 2001 From: ZetaMap <56844734+ZetaMap@users.noreply.github.com> Date: Fri, 5 Nov 2021 20:04:43 +0100 Subject: [PATCH] fix find a player with emojis don't work --- src/main/java/data/TempData.java | 23 +++++++++++++++++------ src/main/java/moreCommandsPlugin.java | 3 +-- src/main/java/util/Strings.java | 11 +++++++++++ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/data/TempData.java b/src/main/java/data/TempData.java index c1fa385..8fe4df3 100644 --- a/src/main/java/data/TempData.java +++ b/src/main/java/data/TempData.java @@ -2,22 +2,21 @@ import arc.struct.ObjectMap; import arc.struct.Seq; -import arc.util.Strings; -import mindustry.game.Team; import mindustry.gen.Player; +import util.Strings; public class TempData { private static ObjectMap data = new ObjectMap<>(); public static final String creatorID = "k6uyrb9D3dEAAAAArLs28w=="; public final Player player; - public Team spectate = null; - public final String realName, stripedName; + public mindustry.game.Team spectate = null; + public final String realName, noColorName, stripedName; public float savedBuildSpeed = 0; public int hue = 0; public boolean votedVNW = false, - votedRTV = false, + votedRTV = false, rainbowed = false, hasEffect = false, isMuted = false, @@ -27,7 +26,8 @@ public class TempData { public TempData(Player p){ this.player = p; this.realName = p.name; - this.stripedName = Strings.stripGlyphs(Strings.stripColors(p.name.strip())); + this.noColorName = Strings.stripColors(p.name.strip()); + this.stripedName = String.valueOf(Strings.stripGlyphs(this.noColorName)); this.isCreator = p.uuid().equals(creatorID); } @@ -35,6 +35,17 @@ public boolean spectate() { return this.spectate != null; } + public String toString() { + return "TempData{" + + "spectate: " + this.spectate + ", realName: " + this.realName + + ", noColorName: " + this.noColorName + ", stripedName: " + this.stripedName + + ", savedBuildSpeed: " + this.savedBuildSpeed + ", hue: " + this.hue + + ", votedVNW: " + this.votedVNW + ", votedRTV: " + this.votedRTV + + ", rainbowed: " + this.rainbowed + ", hasEffect: " + this.hasEffect + + ", isMuted: " + this.isMuted + ", inGodmode: " + this.inGodmode + + ", isCreator: " + this.isCreator + "}"; + } + public static Seq copy() { return data.values().toSeq(); diff --git a/src/main/java/moreCommandsPlugin.java b/src/main/java/moreCommandsPlugin.java index 846d606..6ac6972 100644 --- a/src/main/java/moreCommandsPlugin.java +++ b/src/main/java/moreCommandsPlugin.java @@ -673,7 +673,7 @@ public void run() { for (int i=0; i<5; i++) Call.effect(mindustry.content.Fx.bubble, player.x, player.y, 10, arc.graphics.Color.valueOf(Integer.toHexString(java.awt.Color.getHSBColor(target.hue / 360f, 1f, 1f).getRGB()).substring(2))); - player.name = Strings.RGBString(target.stripedName, target.hue); + player.name = Strings.RGBString(target.noColorName, target.hue); Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } @@ -1294,7 +1294,6 @@ public void run() { if (netServer.admins.unbanPlayerID(arg[0])) Players.info(player, "Unbanned player: [accent]%s", arg[0]); else Players.err(player, "That IP/ID is not banned!"); }); - } private void loadSettings() { diff --git a/src/main/java/util/Strings.java b/src/main/java/util/Strings.java index 27838c8..7f8737b 100644 --- a/src/main/java/util/Strings.java +++ b/src/main/java/util/Strings.java @@ -62,4 +62,15 @@ public static boolean canParseByteList(String[] list) { return true; } + public static String stripGlyphs(CharSequence str){ + StringBuilder out = new StringBuilder(); + + for(int i = 0; i < str.length(); i++){ + int c = str.charAt(i); + if(c >= 0xE000 && c <= 0xF8FF) continue; + out.append((char)c); + } + + return out.toString(); + } }