Rename DynmapPlayer to LiveAtlasPlayer, rename some fields, add uuid field

This commit is contained in:
James Lyne 2021-07-24 02:27:25 +01:00
parent 44b3a7e276
commit 1d27e05f7c
14 changed files with 80 additions and 82 deletions

View File

@ -44,11 +44,10 @@ import LinkControl from "@/components/map/control/LinkControl.vue";
import ChatControl from "@/components/map/control/ChatControl.vue"; import ChatControl from "@/components/map/control/ChatControl.vue";
import LogoControl from "@/components/map/control/LogoControl.vue"; import LogoControl from "@/components/map/control/LogoControl.vue";
import {MutationTypes} from "@/store/mutation-types"; import {MutationTypes} from "@/store/mutation-types";
import {DynmapPlayer} from "@/dynmap";
import LiveAtlasLeafletMap from "@/leaflet/LiveAtlasLeafletMap"; import LiveAtlasLeafletMap from "@/leaflet/LiveAtlasLeafletMap";
import {LoadingControl} from "@/leaflet/control/LoadingControl"; import {LoadingControl} from "@/leaflet/control/LoadingControl";
import MapContextMenu from "@/components/map/MapContextMenu.vue"; import MapContextMenu from "@/components/map/MapContextMenu.vue";
import {Coordinate} from "@/index"; import {Coordinate, LiveAtlasPlayer} from "@/index";
export default defineComponent({ export default defineComponent({
components: { components: {
@ -277,7 +276,7 @@ export default defineComponent({
this.leaflet.getContainer().focus(); this.leaflet.getContainer().focus();
} }
}, },
updateFollow(player: DynmapPlayer, newFollow: boolean) { updateFollow(player: LiveAtlasPlayer, newFollow: boolean) {
const store = useStore(), const store = useStore(),
followMapName = store.state.configuration.followMap, followMapName = store.state.configuration.followMap,
currentWorld = store.state.currentWorld; currentWorld = store.state.currentWorld;
@ -285,17 +284,17 @@ export default defineComponent({
let targetWorld = null; let targetWorld = null;
if(!this.leaflet) { if(!this.leaflet) {
console.warn(`Cannot follow ${player.account}. Map not yet initialized.`); console.warn(`Cannot follow ${player.name}. Map not yet initialized.`);
return; return;
} }
if(player.hidden) { if(player.hidden) {
console.warn(`Cannot follow ${player.account}. Player is hidden from the map.`); console.warn(`Cannot follow ${player.name}. Player is hidden from the map.`);
return; return;
} }
if(!player.location.world) { if(!player.location.world) {
console.warn(`Cannot follow ${player.account}. Player isn't in a known world.`); console.warn(`Cannot follow ${player.name}. Player isn't in a known world.`);
return; return;
} }
@ -306,7 +305,7 @@ export default defineComponent({
} }
if (!targetWorld) { if (!targetWorld) {
console.warn(`Cannot follow ${player.account}. Player isn't in a known world.`); console.warn(`Cannot follow ${player.name}. Player isn't in a known world.`);
return; return;
} }

View File

@ -17,15 +17,16 @@
<script lang="ts"> <script lang="ts">
import {defineComponent, computed, ref, onMounted, onUnmounted} from "@vue/runtime-core"; import {defineComponent, computed, ref, onMounted, onUnmounted} from "@vue/runtime-core";
import {LayerGroup} from 'leaflet'; import {LayerGroup} from 'leaflet';
import {DynmapChat, DynmapPlayer} from "@/dynmap"; import {DynmapChat} from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
import {PlayerMarker} from "@/leaflet/marker/PlayerMarker"; import {PlayerMarker} from "@/leaflet/marker/PlayerMarker";
import {Popup} from "leaflet"; import {Popup} from "leaflet";
import {LiveAtlasPlayer} from "@/index";
export default defineComponent({ export default defineComponent({
props: { props: {
player: { player: {
type: Object as () => DynmapPlayer, type: Object as () => LiveAtlasPlayer,
required: true required: true
}, },
layerGroup: { layerGroup: {
@ -96,7 +97,7 @@ export default defineComponent({
break; break;
} }
if(message.type === 'chat' && message.playerAccount === props.player.account) { if(message.type === 'chat' && message.playerAccount === props.player.name) {
messages.push(message); messages.push(message);
} }
} }

View File

@ -21,7 +21,7 @@
<div :class="{'following__target': true, 'following__target--hidden': target.hidden}"> <div :class="{'following__target': true, 'following__target--hidden': target.hidden}">
<img width="32" height="32" class="target__icon" :src="image" alt="" /> <img width="32" height="32" class="target__icon" :src="image" alt="" />
<span class="target__info"> <span class="target__info">
<span class="target__name" v-html="target.name"></span> <span class="target__name" v-html="target.displayName"></span>
<span class="target__status" v-show="target.hidden">{{ messageHidden }}</span> <span class="target__status" v-show="target.hidden">{{ messageHidden }}</span>
</span> </span>
<button class="target__unfollow" type="button" :title="messageUnfollowTitle" <button class="target__unfollow" type="button" :title="messageUnfollowTitle"
@ -31,25 +31,25 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import {DynmapPlayer} from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
import {MutationTypes} from "@/store/mutation-types"; import {MutationTypes} from "@/store/mutation-types";
import {computed, defineComponent, onMounted, ref, watch} from "@vue/runtime-core"; import {computed, defineComponent, onMounted, ref, watch} from "@vue/runtime-core";
import {getMinecraftHead} from '@/util'; import {getMinecraftHead} from '@/util';
import defaultImage from '@/assets/images/player_face.png'; import defaultImage from '@/assets/images/player_face.png';
import {LiveAtlasPlayer} from "@/index";
export default defineComponent({ export default defineComponent({
name: 'FollowTarget', name: 'FollowTarget',
props: { props: {
target: { target: {
type: Object as () => DynmapPlayer, type: Object as () => LiveAtlasPlayer,
required: true required: true
} }
}, },
setup(props) { setup(props) {
const store = useStore(), const store = useStore(),
image = ref(defaultImage), image = ref(defaultImage),
account = ref(props.target.account), account = ref(props.target.name),
heading = computed(() => store.state.messages.followingHeading), heading = computed(() => store.state.messages.followingHeading),
messageUnfollow = computed(() => store.state.messages.followingUnfollow), messageUnfollow = computed(() => store.state.messages.followingUnfollow),
@ -124,4 +124,4 @@ export default defineComponent({
margin-top: 0; margin-top: 0;
} }
} }
</style> </style>

View File

@ -62,7 +62,7 @@ export default defineComponent({
const query = searchQuery.value.toLowerCase(); const query = searchQuery.value.toLowerCase();
return query ? store.state.sortedPlayers.filter(p => { return query ? store.state.sortedPlayers.filter(p => {
return p.account.toLowerCase().indexOf(query) > -1; return p.name.toLowerCase().indexOf(query) > -1;
}) : store.state.sortedPlayers; }) : store.state.sortedPlayers;
}), }),
maxPlayers = computed(() => store.state.configuration.maxPlayers), maxPlayers = computed(() => store.state.configuration.maxPlayers),

View File

@ -15,29 +15,29 @@
--> -->
<template> <template>
<input :id="`player-${player.account}`" type="radio" name="player" v-bind:value="player.account" v-model="followTarget" <input :id="`player-${player.name}`" type="radio" name="player" v-bind:value="player.name" v-model="followTarget"
@click.prevent="onInputClick" /> @click.prevent="onInputClick" />
<label :for="`player-${player.account}`" <label :for="`player-${player.name}`"
:class="{'player': true, 'player--hidden' : !!player.hidden, 'player--other-world': otherWorld}" :title="title" :class="{'player': true, 'player--hidden' : !!player.hidden, 'player--other-world': otherWorld}" :title="title"
@click.prevent="onLabelClick"> @click.prevent="onLabelClick">
<img width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" /> <img width="16" height="16" class="player__icon" :src="image" alt="" aria-hidden="true" />
<span class="player__name" v-html="player.name"></span> <span class="player__name" v-html="player.displayName"></span>
</label> </label>
</template> </template>
<script lang="ts"> <script lang="ts">
import {defineComponent, computed, ref, onMounted} from 'vue'; import {defineComponent, computed, ref, onMounted} from 'vue';
import {DynmapPlayer} from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
import {MutationTypes} from "@/store/mutation-types"; import {MutationTypes} from "@/store/mutation-types";
import {getMinecraftHead} from '@/util'; import {getMinecraftHead} from '@/util';
import defaultImage from '@/assets/images/player_face.png'; import defaultImage from '@/assets/images/player_face.png';
import {LiveAtlasPlayer} from "@/index";
export default defineComponent({ export default defineComponent({
name: 'PlayerListItem', name: 'PlayerListItem',
props: { props: {
player: { player: {
type: Object as () => DynmapPlayer, type: Object as () => LiveAtlasPlayer,
required: true required: true
} }
}, },
@ -59,7 +59,7 @@ export default defineComponent({
} }
}), }),
followTarget = computed(() => store.state.followTarget ? store.state.followTarget.account : undefined), followTarget = computed(() => store.state.followTarget ? store.state.followTarget.name : undefined),
pan = () => { pan = () => {
if(!props.player.hidden) { if(!props.player.hidden) {

14
src/dynmap.d.ts vendored
View File

@ -20,7 +20,7 @@ import {LogoControlOptions} from "@/leaflet/control/LogoControl";
import {ClockControlOptions} from "@/leaflet/control/ClockControl"; import {ClockControlOptions} from "@/leaflet/control/ClockControl";
import { import {
Coordinate, Coordinate,
LiveAtlasLocation, LiveAtlasPlayer,
LiveAtlasServerMessageConfig, LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition, LiveAtlasWorldDefinition,
LiveAtlasWorldState LiveAtlasWorldState
@ -110,21 +110,11 @@ interface DynmapUpdateResponse {
worldState: LiveAtlasWorldState; worldState: LiveAtlasWorldState;
configHash: number; configHash: number;
playerCount: number; playerCount: number;
players: Set<DynmapPlayer>; players: Set<LiveAtlasPlayer>;
updates: DynmapUpdates; updates: DynmapUpdates;
timestamp: number; timestamp: number;
} }
interface DynmapPlayer {
account: string;
armor: number;
health: number;
name: string;
sort: number;
hidden: boolean;
location: LiveAtlasLocation;
}
interface DynmapMarkerSet { interface DynmapMarkerSet {
id: string, id: string,
label: string; label: string;

15
src/index.d.ts vendored
View File

@ -1,5 +1,5 @@
import {State} from "@/store"; import {State} from "@/store";
import {DynmapPlayer, DynmapUrlConfig} from "@/dynmap"; import {DynmapUrlConfig} from "@/dynmap";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
declare module "*.png" { declare module "*.png" {
@ -108,7 +108,18 @@ export type LiveAtlasUIElement = 'layers' | 'chat' | 'players' | 'maps' | 'setti
export type LiveAtlasSidebarSection = 'servers' | 'players' | 'maps'; export type LiveAtlasSidebarSection = 'servers' | 'players' | 'maps';
export type LiveAtlasDimension = 'overworld' | 'nether' | 'end'; export type LiveAtlasDimension = 'overworld' | 'nether' | 'end';
interface LiveAtlasSortedPlayers extends Array<DynmapPlayer> { interface LiveAtlasPlayer {
name: string;
displayName: string;
uuid?: string;
armor: number;
health: number;
sort: number;
hidden: boolean;
location: LiveAtlasLocation;
}
interface LiveAtlasSortedPlayers extends Array<LiveAtlasPlayer> {
dirty?: boolean; dirty?: boolean;
} }

View File

@ -18,9 +18,9 @@
*/ */
import {MarkerOptions, DivIcon, DomUtil} from 'leaflet'; import {MarkerOptions, DivIcon, DomUtil} from 'leaflet';
import {DynmapPlayer} from "@/dynmap";
import {getMinecraftHead} from '@/util'; import {getMinecraftHead} from '@/util';
import playerImage from '@/assets/images/player_face.png'; import playerImage from '@/assets/images/player_face.png';
import {LiveAtlasPlayer} from "@/index";
const noSkinImage: HTMLImageElement = document.createElement('img'); const noSkinImage: HTMLImageElement = document.createElement('img');
noSkinImage.height = 16; noSkinImage.height = 16;
@ -49,7 +49,7 @@ export interface PlayerIconOptions extends MarkerOptions {
} }
export class PlayerIcon extends DivIcon { export class PlayerIcon extends DivIcon {
private readonly _player: DynmapPlayer; private readonly _player: LiveAtlasPlayer;
private _container?: HTMLDivElement; private _container?: HTMLDivElement;
private _playerImage?: HTMLImageElement; private _playerImage?: HTMLImageElement;
private _playerInfo?: HTMLSpanElement; private _playerInfo?: HTMLSpanElement;
@ -65,7 +65,7 @@ export class PlayerIcon extends DivIcon {
// @ts-ignore // @ts-ignore
options: PlayerIconOptions; options: PlayerIconOptions;
constructor(player: DynmapPlayer, options: PlayerIconOptions) { constructor(player: LiveAtlasPlayer, options: PlayerIconOptions) {
super(options); super(options);
this._player = player; this._player = player;
} }
@ -87,7 +87,7 @@ export class PlayerIcon extends DivIcon {
this._playerName = document.createElement('span'); this._playerName = document.createElement('span');
this._playerName.className = 'player__name'; this._playerName.className = 'player__name';
this._playerName.innerHTML = this._currentName = player.name; this._playerName.innerHTML = this._currentName = player.displayName;
if (this.options.showSkinFace) { if (this.options.showSkinFace) {
let size; let size;
@ -151,8 +151,8 @@ export class PlayerIcon extends DivIcon {
return; return;
} }
if(this._player!.name !== this._currentName) { if(this._player!.displayName !== this._currentName) {
this._playerName!.innerHTML = this._currentName = this._player!.name; this._playerName!.innerHTML = this._currentName = this._player!.displayName;
} }
if(this.options.showHealth) { if(this.options.showHealth) {

View File

@ -15,8 +15,8 @@
*/ */
import {LatLng, MarkerOptions, Marker, Util} from 'leaflet'; import {LatLng, MarkerOptions, Marker, Util} from 'leaflet';
import {DynmapPlayer} from "@/dynmap";
import {PlayerIcon} from "@/leaflet/icon/PlayerIcon"; import {PlayerIcon} from "@/leaflet/icon/PlayerIcon";
import {LiveAtlasPlayer} from "@/index";
export interface PlayerMarkerOptions extends MarkerOptions { export interface PlayerMarkerOptions extends MarkerOptions {
smallFace: boolean, smallFace: boolean,
@ -26,9 +26,9 @@ export interface PlayerMarkerOptions extends MarkerOptions {
} }
export class PlayerMarker extends Marker { export class PlayerMarker extends Marker {
private _player: DynmapPlayer; private _player: LiveAtlasPlayer;
constructor(player: DynmapPlayer, options: PlayerMarkerOptions) { constructor(player: LiveAtlasPlayer, options: PlayerMarkerOptions) {
super(new LatLng(0, 0), options); super(new LatLng(0, 0), options);
this._player = player; this._player = player;
options.draggable = false; options.draggable = false;

View File

@ -16,7 +16,7 @@
import { import {
LiveAtlasDimension, LiveAtlasDimension,
LiveAtlasDynmapServerDefinition, LiveAtlasServerDefinition, LiveAtlasDynmapServerDefinition, LiveAtlasPlayer, LiveAtlasServerDefinition,
LiveAtlasServerMessageConfig, LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition LiveAtlasWorldDefinition
} from "@/index"; } from "@/index";
@ -25,8 +25,7 @@ import {
DynmapCircle, DynmapCircle,
DynmapComponentConfig, DynmapComponentConfig,
DynmapLine, DynmapLine,
DynmapMarker, DynmapMarkerSet, DynmapMarkerSetUpdates, DynmapPlayer, DynmapMarker, DynmapMarkerSet, DynmapMarkerSetUpdates, DynmapServerConfig, DynmapTileUpdate, DynmapUpdate, DynmapUpdateResponse,
DynmapServerConfig, DynmapTileUpdate, DynmapUpdate, DynmapUpdateResponse,
DynmapUpdates DynmapUpdates
} from "@/dynmap"; } from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
@ -698,16 +697,16 @@ export default class DynmapMapProvider extends MapProvider {
this.updateAbort = new AbortController(); this.updateAbort = new AbortController();
const response = await DynmapMapProvider.fetchJSON(url, this.updateAbort.signal); const response = await DynmapMapProvider.fetchJSON(url, this.updateAbort.signal);
const players: Set<DynmapPlayer> = new Set(); const players: Set<LiveAtlasPlayer> = new Set();
(response.players || []).forEach((player: any) => { (response.players || []).forEach((player: any) => {
const world = player.world && player.world !== '-some-other-bogus-world-' ? player.world : undefined; const world = player.world && player.world !== '-some-other-bogus-world-' ? player.world : undefined;
players.add({ players.add({
account: player.account || "", name: player.account || "",
displayName: player.name || "",
health: player.health || 0, health: player.health || 0,
armor: player.armor || 0, armor: player.armor || 0,
name: player.name || "",
sort: player.sort || 0, sort: player.sort || 0,
hidden: !world, hidden: !world,
location: { location: {

View File

@ -23,9 +23,9 @@ import {
DynmapAreaUpdate, DynmapCircleUpdate, DynmapLineUpdate, DynmapAreaUpdate, DynmapCircleUpdate, DynmapLineUpdate,
DynmapMarkerSet, DynmapMarkerSet,
DynmapMarkerUpdate, DynmapMarkerUpdate,
DynmapPlayer, DynmapTileUpdate, DynmapTileUpdate,
} from "@/dynmap"; } from "@/dynmap";
import {LiveAtlasWorldDefinition} from "@/index"; import {LiveAtlasPlayer, LiveAtlasWorldDefinition} from "@/index";
type AugmentedActionContext = { type AugmentedActionContext = {
commit<K extends keyof Mutations>( commit<K extends keyof Mutations>(
@ -46,7 +46,7 @@ export interface Actions {
):Promise<void> ):Promise<void>
[ActionTypes.SET_PLAYERS]( [ActionTypes.SET_PLAYERS](
{commit}: AugmentedActionContext, {commit}: AugmentedActionContext,
payload: Set<DynmapPlayer> payload: Set<LiveAtlasPlayer>
):Promise<Map<string, DynmapMarkerSet>> ):Promise<Map<string, DynmapMarkerSet>>
[ActionTypes.POP_MARKER_UPDATES]( [ActionTypes.POP_MARKER_UPDATES](
{commit}: AugmentedActionContext, {commit}: AugmentedActionContext,
@ -156,17 +156,17 @@ export const actions: ActionTree<State, State> & Actions = {
state.currentMapProvider!.stopUpdates(); state.currentMapProvider!.stopUpdates();
}, },
[ActionTypes.SET_PLAYERS]({commit, state}, players: Set<DynmapPlayer>) { [ActionTypes.SET_PLAYERS]({commit, state}, players: Set<LiveAtlasPlayer>) {
const keep: Set<string> = new Set(); const keep: Set<string> = new Set();
for(const player of players) { for(const player of players) {
keep.add(player.account); keep.add(player.name);
} }
//Remove any players that aren't in the set //Remove any players that aren't in the set
commit(MutationTypes.SYNC_PLAYERS, keep); commit(MutationTypes.SYNC_PLAYERS, keep);
const processQueue = (players: Set<DynmapPlayer>, resolve: Function) => { const processQueue = (players: Set<LiveAtlasPlayer>, resolve: Function) => {
commit(MutationTypes.SET_PLAYERS_ASYNC, players); commit(MutationTypes.SET_PLAYERS_ASYNC, players);
if(!players.size) { if(!players.size) {

View File

@ -24,7 +24,6 @@ import {
DynmapLine, DynmapMarker, DynmapLine, DynmapMarker,
DynmapMarkerSet, DynmapMarkerSet,
DynmapMarkerSetUpdates, DynmapMarkerSetUpdates,
DynmapPlayer,
DynmapServerConfig, DynmapTileUpdate, DynmapServerConfig, DynmapTileUpdate,
DynmapChat DynmapChat
} from "@/dynmap"; } from "@/dynmap";
@ -38,7 +37,7 @@ import {
LiveAtlasParsedUrl, LiveAtlasParsedUrl,
LiveAtlasGlobalConfig, LiveAtlasGlobalConfig,
LiveAtlasGlobalMessageConfig, LiveAtlasGlobalMessageConfig,
LiveAtlasServerMessageConfig, LiveAtlasDynmapServerDefinition LiveAtlasServerMessageConfig, LiveAtlasDynmapServerDefinition, LiveAtlasPlayer
} from "@/index"; } from "@/index";
import DynmapMapProvider from "@/providers/DynmapMapProvider"; import DynmapMapProvider from "@/providers/DynmapMapProvider";
@ -70,7 +69,7 @@ export type Mutations<S = State> = {
[MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void [MutationTypes.POP_LINE_UPDATES](state: S, payload: {markerSet: string, amount: number}): void
[MutationTypes.POP_TILE_UPDATES](state: S, amount: number): void [MutationTypes.POP_TILE_UPDATES](state: S, amount: number): void
[MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set<DynmapPlayer>): Set<DynmapPlayer> [MutationTypes.SET_PLAYERS_ASYNC](state: S, players: Set<LiveAtlasPlayer>): Set<LiveAtlasPlayer>
[MutationTypes.SYNC_PLAYERS](state: S, keep: Set<string>): void [MutationTypes.SYNC_PLAYERS](state: S, keep: Set<string>): void
[MutationTypes.CLEAR_PLAYERS](state: S): void [MutationTypes.CLEAR_PLAYERS](state: S): void
[MutationTypes.SET_CURRENT_SERVER](state: S, server: string): void [MutationTypes.SET_CURRENT_SERVER](state: S, server: string): void
@ -80,8 +79,8 @@ export type Mutations<S = State> = {
[MutationTypes.SET_PARSED_URL](state: S, payload: LiveAtlasParsedUrl): void [MutationTypes.SET_PARSED_URL](state: S, payload: LiveAtlasParsedUrl): void
[MutationTypes.CLEAR_PARSED_URL](state: S): void [MutationTypes.CLEAR_PARSED_URL](state: S): void
[MutationTypes.CLEAR_CURRENT_MAP](state: S): void [MutationTypes.CLEAR_CURRENT_MAP](state: S): void
[MutationTypes.SET_FOLLOW_TARGET](state: S, payload: DynmapPlayer): void [MutationTypes.SET_FOLLOW_TARGET](state: S, payload: LiveAtlasPlayer): void
[MutationTypes.SET_PAN_TARGET](state: S, payload: DynmapPlayer): void [MutationTypes.SET_PAN_TARGET](state: S, payload: LiveAtlasPlayer): void
[MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void [MutationTypes.CLEAR_FOLLOW_TARGET](state: S, a?: void): void
[MutationTypes.CLEAR_PAN_TARGET](state: S, a?: void): void [MutationTypes.CLEAR_PAN_TARGET](state: S, a?: void): void
@ -406,31 +405,31 @@ export const mutations: MutationTree<State> & Mutations = {
}, },
// Set up to 10 players at once // Set up to 10 players at once
[MutationTypes.SET_PLAYERS_ASYNC](state: State, players: Set<DynmapPlayer>): Set<DynmapPlayer> { [MutationTypes.SET_PLAYERS_ASYNC](state: State, players: Set<LiveAtlasPlayer>): Set<LiveAtlasPlayer> {
let count = 0; let count = 0;
for(const player of players) { for(const player of players) {
if(state.players.has(player.account)) { if(state.players.has(player.name)) {
const existing = state.players.get(player.account); const existing = state.players.get(player.name);
existing!.health = player.health; existing!.health = player.health;
existing!.armor = player.armor; existing!.armor = player.armor;
existing!.location = Object.assign(existing!.location, player.location); existing!.location = Object.assign(existing!.location, player.location);
existing!.hidden = player.hidden; existing!.hidden = player.hidden;
existing!.name = player.name; existing!.displayName = player.displayName;
existing!.sort = player.sort; existing!.sort = player.sort;
if(existing!.name !== player.name || existing!.sort !== player.sort) { if(existing!.displayName !== player.displayName || existing!.sort !== player.sort) {
state.sortedPlayers.dirty = true; state.sortedPlayers.dirty = true;
} }
} else { } else {
state.sortedPlayers.dirty = true; state.sortedPlayers.dirty = true;
state.players.set(player.account, { state.players.set(player.name, {
account: player.account, name: player.name,
health: player.health, health: player.health,
armor: player.armor, armor: player.armor,
location: player.location, location: player.location,
name: player.name, displayName: player.displayName,
sort: player.sort, sort: player.sort,
hidden: player.hidden, hidden: player.hidden,
}); });
@ -450,7 +449,7 @@ export const mutations: MutationTree<State> & Mutations = {
return a.sort - b.sort; return a.sort - b.sort;
} }
return a.account.toLowerCase().localeCompare(b.account.toLowerCase()); return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
}) as LiveAtlasSortedPlayers; }) as LiveAtlasSortedPlayers;
} }
@ -460,7 +459,7 @@ export const mutations: MutationTree<State> & Mutations = {
//Removes all players not found in the provided keep set //Removes all players not found in the provided keep set
[MutationTypes.SYNC_PLAYERS](state: State, keep: Set<string>) { [MutationTypes.SYNC_PLAYERS](state: State, keep: Set<string>) {
for(const [key, player] of state.players) { for(const [key, player] of state.players) {
if(!keep.has(player.account)) { if(!keep.has(player.name)) {
state.sortedPlayers.splice(state.sortedPlayers.indexOf(player), 1); state.sortedPlayers.splice(state.sortedPlayers.indexOf(player), 1);
state.players.delete(key); state.players.delete(key);
} }
@ -547,12 +546,12 @@ export const mutations: MutationTree<State> & Mutations = {
}, },
//Set the follow target, which the map will automatically pan to keep in view //Set the follow target, which the map will automatically pan to keep in view
[MutationTypes.SET_FOLLOW_TARGET](state: State, player: DynmapPlayer) { [MutationTypes.SET_FOLLOW_TARGET](state: State, player: LiveAtlasPlayer) {
state.followTarget = player; state.followTarget = player;
}, },
//Set the pan target, which the map will immediately pan to once //Set the pan target, which the map will immediately pan to once
[MutationTypes.SET_PAN_TARGET](state: State, player: DynmapPlayer) { [MutationTypes.SET_PAN_TARGET](state: State, player: LiveAtlasPlayer) {
state.panTarget = player; state.panTarget = player;
}, },

View File

@ -16,7 +16,6 @@
import { import {
DynmapComponentConfig, DynmapMarkerSet, DynmapMarkerSetUpdates, DynmapComponentConfig, DynmapMarkerSet, DynmapMarkerSetUpdates,
DynmapPlayer,
DynmapServerConfig, DynmapTileUpdate, DynmapServerConfig, DynmapTileUpdate,
DynmapChat DynmapChat
} from "@/dynmap"; } from "@/dynmap";
@ -29,7 +28,7 @@ import {
LiveAtlasUIElement, LiveAtlasUIElement,
LiveAtlasWorldDefinition, LiveAtlasWorldDefinition,
LiveAtlasParsedUrl, LiveAtlasParsedUrl,
LiveAtlasMessageConfig, LiveAtlasMapProvider LiveAtlasMessageConfig, LiveAtlasMapProvider, LiveAtlasPlayer
} from "@/index"; } from "@/index";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
@ -45,7 +44,7 @@ export type State = {
worlds: Map<string, LiveAtlasWorldDefinition>; worlds: Map<string, LiveAtlasWorldDefinition>;
maps: Map<string, LiveAtlasMapDefinition>; maps: Map<string, LiveAtlasMapDefinition>;
players: Map<string, DynmapPlayer>; players: Map<string, LiveAtlasPlayer>;
sortedPlayers: LiveAtlasSortedPlayers; sortedPlayers: LiveAtlasSortedPlayers;
markerSets: Map<string, DynmapMarkerSet>; markerSets: Map<string, DynmapMarkerSet>;
@ -57,8 +56,8 @@ export type State = {
pendingSetUpdates: Map<string, DynmapMarkerSetUpdates>; pendingSetUpdates: Map<string, DynmapMarkerSetUpdates>;
pendingTileUpdates: Array<DynmapTileUpdate>; pendingTileUpdates: Array<DynmapTileUpdate>;
followTarget?: DynmapPlayer; followTarget?: LiveAtlasPlayer;
panTarget?: DynmapPlayer; panTarget?: LiveAtlasPlayer;
currentMapProvider?: Readonly<LiveAtlasMapProvider>; currentMapProvider?: Readonly<LiveAtlasMapProvider>;
currentServer?: LiveAtlasServerDefinition; currentServer?: LiveAtlasServerDefinition;

View File

@ -14,9 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
import {DynmapPlayer} from "@/dynmap";
import {useStore} from "@/store"; import {useStore} from "@/store";
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition"; import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
import {LiveAtlasPlayer} from "@/index";
interface HeadQueueEntry { interface HeadQueueEntry {
cacheKey: string; cacheKey: string;
@ -52,8 +52,8 @@ export const getMinecraftTime = (serverTime: number) => {
}; };
} }
export const getMinecraftHead = (player: DynmapPlayer | string, size: string): Promise<HTMLImageElement> => { export const getMinecraftHead = (player: LiveAtlasPlayer | string, size: string): Promise<HTMLImageElement> => {
const account = typeof player === 'string' ? player : player.account, const account = typeof player === 'string' ? player : player.name,
cacheKey = `${account}-${size}`; cacheKey = `${account}-${size}`;
if(headCache.has(cacheKey)) { if(headCache.has(cacheKey)) {