From b92120e801e4d7ceee6728463d9fb269e29e4450 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Fri, 18 Dec 2020 16:04:06 +0000 Subject: [PATCH] Handle hidden/offworld players - Respect server config for greying out players in other worlds - Always grey out players hidden due to other restrictions - Allow following for hidden players, and show their hidden status on the follow popup --- src/api.ts | 6 ++- src/components/Map.vue | 5 ++ src/components/sidebar/FollowTarget.vue | 23 +++++++-- src/components/sidebar/PlayerListItem.vue | 58 ++++++++++++++++++++--- src/dynmap.d.ts | 12 +++-- src/store/mutations.ts | 2 + src/store/state.ts | 1 + 7 files changed, 92 insertions(+), 15 deletions(-) diff --git a/src/api.ts b/src/api.ts index 77690f6..5cc1982 100644 --- a/src/api.ts +++ b/src/api.ts @@ -43,6 +43,7 @@ function buildServerConfig(response: any): DynmapServerConfig { return { version: response.dynmapversion || '', allowChat: response.allowwebchat || false, + grayHiddenPlayers: response.grayplayerswhenhidden || false, chatRequiresLogin: response['webchat-requires-login'] || false, chatInterval: response['webchat-interval'] || 5, defaultMap: response.defaultmap || undefined, @@ -488,17 +489,20 @@ export default { const players: Set = new Set(); (response.players || []).forEach((player: any) => { + const world = player.world && player.world !== '-some-other-bogus-world-' ? player.world : undefined; + players.add({ account: player.account || "", health: player.health || 0, armor: player.armor || 0, name: player.name ? sanitizer.sanitize(player.name) : "Steve", sort: player.sort || 0, + hidden: !world, location: { x: player.x || 0, y: player.y || 0, z: player.z || 0, - world: player.world || undefined, + world: world, } }); }); diff --git a/src/components/Map.vue b/src/components/Map.vue index b1ad265..aeb802e 100644 --- a/src/components/Map.vue +++ b/src/components/Map.vue @@ -232,6 +232,11 @@ export default defineComponent({ return; } + if(player.hidden) { + console.warn(`Cannot follow ${player.name}. Player is hidden from the map.`); + return; + } + if(!player.location.world) { console.warn(`Cannot follow ${player.name}. Player isn't in a known world.`); return; diff --git a/src/components/sidebar/FollowTarget.vue b/src/components/sidebar/FollowTarget.vue index 4475e43..ae9eba9 100644 --- a/src/components/sidebar/FollowTarget.vue +++ b/src/components/sidebar/FollowTarget.vue @@ -18,9 +18,12 @@