Support disabling player marker images

- showplayerfaces: false in Dynmap, player-tracker.nameplate.show-head: false in Pl3xmap
- Remove showSkin option in favour of 'none' image size
This commit is contained in:
James Lyne 2021-09-29 19:58:39 +01:00
parent 5896d4504c
commit bf383afb8d
6 changed files with 19 additions and 21 deletions

View File

@ -48,7 +48,6 @@ export default defineComponent({
//The player marker
marker = new PlayerMarker(props.player, {
showSkin: componentSettings.value!.showSkins,
imageSize: componentSettings.value!.imageSize,
showHealth: componentSettings.value!.showHealth,
showArmor: componentSettings.value!.showArmor,

1
src/index.d.ts vendored
View File

@ -321,7 +321,6 @@ interface LiveAtlasPlayerMarkerConfig {
layerName: string;
layerPriority: number;
imageSize: LiveAtlasPlayerImageSize;
showSkins: boolean;
showHealth: boolean;
showArmor: boolean;
}

View File

@ -28,7 +28,6 @@ playerImage.className = 'player__icon';
export interface PlayerIconOptions extends BaseIconOptions {
imageSize: LiveAtlasPlayerImageSize,
showSkin: boolean,
showHealth: boolean,
showArmor: boolean,
}
@ -68,16 +67,17 @@ export class PlayerIcon extends Layer implements Icon<PlayerIconOptions> {
this._playerName = document.createElement('span');
this._playerName.className = 'player__name';
if (this.options.imageSize != 'none') {
this._playerImage = playerImage.cloneNode() as HTMLImageElement;
this._playerImage.height = this._playerImage.width = getImagePixelSize(this.options.imageSize);
if (this.options.showSkin) {
getMinecraftHead(this._player, this.options.imageSize).then(head => {
this._playerImage!.src = head.src;
}).catch(() => {});
}
this._playerInfo.appendChild(this._playerImage);
}
this._playerInfo.appendChild(this._playerName);
if (this.options.showHealth) {

View File

@ -21,7 +21,6 @@ import {watch} from "@vue/runtime-core";
import {WatchStopHandle} from "vue";
export interface PlayerMarkerOptions extends MarkerOptions {
showSkin: boolean,
imageSize: LiveAtlasPlayerImageSize,
showHealth: boolean,
showArmor: boolean,
@ -40,7 +39,6 @@ export class PlayerMarker extends Marker {
this._PlayerIcon = options.icon = new PlayerIcon(player, {
imageSize: options.imageSize,
showSkin: options.showSkin,
showHealth: options.showHealth,
showArmor: options.showArmor,
});

View File

@ -94,15 +94,15 @@ export default class Pl3xmapMapProvider extends MapProvider {
if(worldResponse.player_tracker?.enabled) {
const health = !!worldResponse.player_tracker?.nameplates?.show_health,
armor = !!worldResponse.player_tracker?.nameplates?.show_armor;
armor = !!worldResponse.player_tracker?.nameplates?.show_armor,
images = !!worldResponse.player_tracker?.nameplates?.show_heads;
worldConfig.components.playerMarkers = {
grayHiddenPlayers: true,
hideByDefault: !!worldResponse.player_tracker?.default_hidden,
layerName: worldResponse.player_tracker?.label || '',
layerPriority: worldResponse.player_tracker?.priority,
imageSize: health && armor ? 'large' : 'small',
showSkins: true,
imageSize: images ? (health && armor ? 'large' : 'small') : 'none',
showHealth: health,
showArmor: armor,
}

View File

@ -22,7 +22,7 @@ import {
LiveAtlasComponentConfig,
LiveAtlasDimension,
LiveAtlasLine,
LiveAtlasMarker,
LiveAtlasMarker, LiveAtlasPlayerImageSize,
LiveAtlasServerConfig,
LiveAtlasServerMessageConfig,
LiveAtlasWorldDefinition
@ -139,6 +139,7 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
(response.components || []).forEach((component: any) => {
const type = component.type || "unknown";
let imageSize: LiveAtlasPlayerImageSize = 'large';
switch (type) {
case "markers":
@ -149,23 +150,24 @@ export function buildComponents(response: any): LiveAtlasComponentConfig {
break;
case "playermarkers":
if(!component.showplayerfaces) {
imageSize = 'none';
} else if(component.smallplayerfaces) {
imageSize = 'small';
} else if(component.showplayerbody) {
imageSize = 'body';
}
components.playerMarkers = {
grayHiddenPlayers: response.grayplayerswhenhidden || false,
hideByDefault: component.hidebydefault || false,
layerName: component.label || "Players",
layerPriority: component.layerprio || 0,
showSkins: component.showplayerfaces || false,
imageSize: 'large',
imageSize,
showHealth: component.showplayerhealth || false,
showArmor: component.showplayerhealth || false,
}
if(component.smallplayerfaces) {
components.playerMarkers.imageSize = 'small'
} else if(component.showplayerbody) {
components.playerMarkers.imageSize = 'body';
}
break;
case "coord":