import { P } from '../Squaremap.js'; class Player { constructor(json) { this.name = json.name; this.uuid = json.uuid; this.world = json.world; this.displayName = json.display_name !== undefined ? json.display_name : json.name; this.x = 0; this.z = 0; this.armor = 0; this.health = 20; this.tooltip = L.tooltip({ permanent: true, direction: "right", offset: [10, 0], pane: "nameplate" }); this.marker = L.marker(P.toLatLng(json.x, json.z), { icon: L.icon({ iconUrl: 'images/icon/player.png', iconSize: [17, 16], iconAnchor: [8, 9], tooltipAnchor: [0, 0] }), rotationAngle: (180 + json.yaw) }); if (P.worldList.curWorld.player_tracker.nameplates.enabled) { this.updateNameplate(json); this.marker.bindTooltip(this.tooltip); } } getHeadUrl() { return P.worldList.curWorld.player_tracker.nameplates.heads_url .replace(/{uuid}/g, this.uuid) .replace(/{name}/g, this.name); } updateNameplate(player) { let headImg = ""; let armorImg = ""; let healthImg = ""; if (P.worldList.curWorld.player_tracker.nameplates.show_heads) { headImg = ``; } if (P.worldList.curWorld.player_tracker.nameplates.show_armor && player.armor != null) { armorImg = ``; } if (P.worldList.curWorld.player_tracker.nameplates.show_health && player.health != null) { healthImg = ``; } this.tooltip.setContent(`