Skip to content

Commit

Permalink
fix find a player with emojis don't work
Browse files Browse the repository at this point in the history
  • Loading branch information
ZetaMap committed Nov 5, 2021
1 parent 87317ce commit 8fd4227
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
23 changes: 17 additions & 6 deletions src/main/java/data/TempData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Player, TempData> 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,
Expand All @@ -27,14 +26,26 @@ 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);
}

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<TempData> copy() {
return data.values().toSeq();
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/moreCommandsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/util/Strings.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 8fd4227

Please sign in to comment.