| 11 | import util.Strings; |
| 12 | |
| 13 | public class TempData { |
| 14 | private static ObjectMap<Player, TempData> data = new ObjectMap<>(); |
| 15 | public static ObjectMap<String, Seq<TempData>> localeOrdonedPlayer = new ObjectMap<>(); |
| 16 | public static final String creatorID = "k6uyrb9D3dEAAAAArLs28w=="; |
| 17 | |
| 18 | public final Player player; |
| 19 | public final MSG msgData = new MSG(); |
| 20 | public mindustry.game.Team spectate = null; |
| 21 | public Effects effect = Effects.getByName("none"); |
| 22 | public mindustry.gen.Unit lastUnit; |
| 23 | public final Locale locale; |
| 24 | public final String realName, noColorName, stripedName, nameColor; |
| 25 | public String tag = "", noColorTag = "", rainbowedName = ""; |
| 26 | public int hue = 0; |
| 27 | public boolean votedVNW = false, votedRTV = false, rainbowed = false, hasEffect = false, isMuted = false, inGodmode = false, isCreator; |
| 28 | |
| 29 | private TempData(Player p) { |
| 30 | this.player = p; |
| 31 | this.lastUnit = p.unit(); |
| 32 | this.locale = Locale.forLanguageTag(p.locale().replace('_', '-')); |
| 33 | this.realName = p.name; |
| 34 | this.noColorName = Strings.stripColors(p.name).strip(); |
| 35 | this.stripedName = Strings.stripGlyphs(this.noColorName).strip(); |
| 36 | this.nameColor = "[#" + this.player.color.toString() + "]"; |
| 37 | this.isCreator = p.uuid().equals(creatorID); |
| 38 | } |
| 39 | |
| 40 | public boolean spectate() { |
| 41 | return this.spectate != null; |
| 42 | } |
| 43 | |
| 44 | public void applyTag() { |
| 45 | if (PVars.tags && PVars.playerTags.containsKey(this.player.uuid())) { |
| 46 | this.tag = "[gold][[[white]" + PVars.playerTags.get(this.player.uuid()) + "[gold]] "; |
| 47 | this.noColorTag = Strings.stripColors(this.tag).strip().substring(1) + " "; |
| 48 | |
| 49 | } else if (PVars.tags && this.player.admin) { |
| 50 | this.tag = "[gold][[[scarlet]<Admin>[gold]] "; |
| 51 | this.noColorTag = "[<Admin>] "; |
| 52 | |
| 53 | } else { |
| 54 | this.tag = ""; |
| 55 | this.noColorTag = this.tag; |
| 56 | } |
| 57 | |
| 58 | this.player.name = (this.tag.isBlank() ? "" : this.tag + this.nameColor) + this.realName; |
| 59 | } |
| 60 | |
| 61 | public String getName() { |
| 62 | return this.rainbowed ? this.rainbowedName : this.nameColor + this.realName; |
| 63 | } |
| 64 | |
| 65 | public void reset() { |
| 66 | TempData newData = new TempData(this.player); |
| 67 | |
| 68 | if (spectate()) this.player.team(this.spectate); |
| 69 | this.player.unit().health = this.player.unit().maxHealth; |
| 70 | this.lastUnit = newData.lastUnit; |