2021-07-24 00:15:52 +00:00
|
|
|
/*
|
2021-07-25 14:12:40 +00:00
|
|
|
* Copyright 2021 James Lyne
|
2021-07-24 00:15:52 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2021-07-24 00:15:52 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2021-07-24 00:15:52 +00:00
|
|
|
*
|
2021-07-25 14:12:40 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2021-07-24 00:15:52 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import {
|
2021-07-25 00:57:59 +00:00
|
|
|
HeadQueueEntry,
|
2021-07-25 13:53:45 +00:00
|
|
|
LiveAtlasArea, LiveAtlasChat,
|
|
|
|
LiveAtlasCircle, LiveAtlasComponentConfig,
|
2021-07-24 00:15:52 +00:00
|
|
|
LiveAtlasDimension,
|
2021-07-24 03:06:19 +00:00
|
|
|
LiveAtlasLine,
|
|
|
|
LiveAtlasMarker,
|
|
|
|
LiveAtlasMarkerSet,
|
2021-07-25 13:53:45 +00:00
|
|
|
LiveAtlasPlayer, LiveAtlasServerConfig,
|
2021-07-24 03:06:19 +00:00
|
|
|
LiveAtlasServerDefinition,
|
2021-07-24 00:15:52 +00:00
|
|
|
LiveAtlasServerMessageConfig,
|
|
|
|
LiveAtlasWorldDefinition
|
|
|
|
} from "@/index";
|
|
|
|
import {
|
2021-07-25 13:53:45 +00:00
|
|
|
DynmapMarkerSetUpdates, DynmapTileUpdate, DynmapUpdate
|
2021-07-24 00:15:52 +00:00
|
|
|
} from "@/dynmap";
|
|
|
|
import LiveAtlasMapDefinition from "@/model/LiveAtlasMapDefinition";
|
|
|
|
import ChatError from "@/errors/ChatError";
|
|
|
|
import {MutationTypes} from "@/store/mutation-types";
|
|
|
|
import MapProvider from "@/providers/MapProvider";
|
|
|
|
import {ActionTypes} from "@/store/action-types";
|
|
|
|
import {endWorldNameRegex, netherWorldNameRegex, titleColoursRegex} from "@/util";
|
2021-07-28 00:56:41 +00:00
|
|
|
import {getPoints} from "@/util/areas";
|
|
|
|
import {getLinePoints} from "@/util/lines";
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
export default class DynmapMapProvider extends MapProvider {
|
|
|
|
private configurationAbort?: AbortController = undefined;
|
|
|
|
private markersAbort?: AbortController = undefined;
|
|
|
|
private updateAbort?: AbortController = undefined;
|
|
|
|
|
|
|
|
private updatesEnabled = false;
|
|
|
|
private updateTimeout: number = 0;
|
|
|
|
private updateTimestamp: Date = new Date();
|
|
|
|
private updateInterval: number = 3000;
|
|
|
|
|
2021-07-25 01:02:42 +00:00
|
|
|
constructor(config: LiveAtlasServerDefinition) {
|
|
|
|
super(config);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 13:53:45 +00:00
|
|
|
private static buildServerConfig(response: any): LiveAtlasServerConfig {
|
2021-07-24 00:15:52 +00:00
|
|
|
return {
|
|
|
|
defaultMap: response.defaultmap || undefined,
|
|
|
|
defaultWorld: response.defaultworld || undefined,
|
|
|
|
defaultZoom: response.defaultzoom || 0,
|
|
|
|
followMap: response.followmap || undefined,
|
2021-07-28 22:52:51 +00:00
|
|
|
followZoom: response.followzoom,
|
2021-07-24 00:15:52 +00:00
|
|
|
title: response.title.replace(titleColoursRegex, '') || 'Dynmap',
|
|
|
|
expandUI: response.sidebaropened && response.sidebaropened !== 'false', //Sent as a string for some reason
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private static buildMessagesConfig(response: any): LiveAtlasServerMessageConfig {
|
|
|
|
return {
|
|
|
|
chatPlayerJoin: response.joinmessage || '',
|
|
|
|
chatPlayerQuit: response.quitmessage || '',
|
|
|
|
chatAnonymousJoin: response['msg-hiddennamejoin'] || '',
|
|
|
|
chatAnonymousQuit: response['msg-hiddennamequit'] || '',
|
|
|
|
chatErrorNotAllowed: response['msg-chatnotallowed'] || '',
|
|
|
|
chatErrorRequiresLogin: response['msg-chatrequireslogin'] || '',
|
|
|
|
chatErrorCooldown: response.spammessage || '',
|
|
|
|
worldsHeading: response['msg-maptypes'] || '',
|
2021-07-28 21:27:43 +00:00
|
|
|
playersHeading: response['msg-players'] ? `${response['msg-players']} ({cur}/{max})` : '',
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private buildWorlds(response: any): Array<LiveAtlasWorldDefinition> {
|
|
|
|
const worlds: Map<string, LiveAtlasWorldDefinition> = new Map<string, LiveAtlasWorldDefinition>();
|
|
|
|
|
|
|
|
//Get all the worlds first so we can handle append_to_world properly
|
|
|
|
(response.worlds || []).forEach((world: any) => {
|
|
|
|
let worldType: LiveAtlasDimension = 'overworld';
|
|
|
|
|
|
|
|
if (netherWorldNameRegex.test(world.name) || (world.name == 'DIM-1')) {
|
|
|
|
worldType = 'nether';
|
|
|
|
} else if (endWorldNameRegex.test(world.name) || (world.name == 'DIM1')) {
|
|
|
|
worldType = 'end';
|
|
|
|
}
|
|
|
|
|
|
|
|
worlds.set(world.name, {
|
|
|
|
name: world.name,
|
2021-07-24 19:12:18 +00:00
|
|
|
displayName: world.title || '',
|
2021-07-24 00:15:52 +00:00
|
|
|
dimension: worldType,
|
|
|
|
protected: world.protected || false,
|
|
|
|
height: world.height || 256,
|
2021-07-24 19:12:18 +00:00
|
|
|
seaLevel: world.sealevel || 64,
|
2021-07-24 00:15:52 +00:00
|
|
|
center: {
|
|
|
|
x: world.center.x || 0,
|
|
|
|
y: world.center.y || 0,
|
|
|
|
z: world.center.z || 0
|
|
|
|
},
|
|
|
|
maps: new Map(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
(response.worlds || []).forEach((world: any) => {
|
|
|
|
(world.maps || []).forEach((map: any) => {
|
|
|
|
const worldName = map.append_to_world || world.name,
|
|
|
|
w = worlds.get(worldName);
|
|
|
|
|
|
|
|
if(!w) {
|
|
|
|
console.warn(`Ignoring map '${map.name}' associated with non-existent world '${worldName}'`);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-27 03:31:43 +00:00
|
|
|
w.maps.set(map.name, Object.freeze(new LiveAtlasMapDefinition({
|
2021-07-25 16:31:02 +00:00
|
|
|
world: w, //Ignore append_to_world here otherwise things break
|
2021-07-24 00:15:52 +00:00
|
|
|
background: map.background || '#000000',
|
|
|
|
backgroundDay: map.backgroundday || '#000000',
|
|
|
|
backgroundNight: map.backgroundnight || '#000000',
|
|
|
|
icon: map.icon || undefined,
|
|
|
|
imageFormat: map['image-format'] || 'png',
|
|
|
|
name: map.name || '(Unnamed map)',
|
|
|
|
nightAndDay: map.nightandday || false,
|
|
|
|
prefix: map.prefix || '',
|
|
|
|
protected: map.protected || false,
|
2021-07-24 19:12:18 +00:00
|
|
|
displayName: map.title || '',
|
2021-07-24 00:15:52 +00:00
|
|
|
mapToWorld: map.maptoworld || undefined,
|
|
|
|
worldToMap: map.worldtomap || undefined,
|
|
|
|
nativeZoomLevels: map.mapzoomout || 1,
|
|
|
|
extraZoomLevels: map.mapzoomin || 0
|
2021-07-27 03:31:43 +00:00
|
|
|
})));
|
2021-07-24 00:15:52 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
return Array.from(worlds.values());
|
|
|
|
}
|
|
|
|
|
2021-07-25 13:53:45 +00:00
|
|
|
private buildComponents(response: any): LiveAtlasComponentConfig {
|
|
|
|
const components: LiveAtlasComponentConfig = {
|
2021-07-24 00:15:52 +00:00
|
|
|
markers: {
|
|
|
|
showLabels: false,
|
|
|
|
},
|
|
|
|
chatBox: undefined,
|
|
|
|
chatBalloons: false,
|
|
|
|
playerMarkers: undefined,
|
|
|
|
coordinatesControl: undefined,
|
2021-07-24 03:03:36 +00:00
|
|
|
layerControl: response.showlayercontrol && response.showlayercontrol !== 'false', //Sent as a string for some reason
|
2021-07-24 00:15:52 +00:00
|
|
|
linkControl: false,
|
|
|
|
clockControl: undefined,
|
|
|
|
logoControls: [],
|
2021-07-24 14:19:30 +00:00
|
|
|
login: response['login-enabled'] || false,
|
2021-07-24 00:15:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
(response.components || []).forEach((component: any) => {
|
|
|
|
const type = component.type || "unknown";
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case "markers":
|
|
|
|
components.markers = {
|
|
|
|
showLabels: component.showlabel || false,
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "playermarkers":
|
|
|
|
components.playerMarkers = {
|
2021-07-28 22:52:03 +00:00
|
|
|
grayHiddenPlayers: response.grayplayerswhenhidden || false,
|
2021-07-24 00:15:52 +00:00
|
|
|
hideByDefault: component.hidebydefault || false,
|
|
|
|
layerName: component.label || "Players",
|
|
|
|
layerPriority: component.layerprio || 0,
|
|
|
|
showBodies: component.showplayerbody || false,
|
|
|
|
showSkinFaces: component.showplayerfaces || false,
|
|
|
|
showHealth: component.showplayerhealth || false,
|
|
|
|
smallFaces: component.smallplayerfaces || false,
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "coord":
|
|
|
|
components.coordinatesControl = {
|
|
|
|
showY: !(component.hidey || false),
|
|
|
|
label: component.label || "Location: ",
|
|
|
|
showRegion: component['show-mcr'] || false,
|
|
|
|
showChunk: component['show-chunk'] || false,
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "link":
|
|
|
|
components.linkControl = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "digitalclock":
|
|
|
|
components.clockControl = {
|
|
|
|
showDigitalClock: true,
|
|
|
|
showWeather: false,
|
|
|
|
showTimeOfDay: false,
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "timeofdayclock":
|
|
|
|
components.clockControl = {
|
|
|
|
showTimeOfDay: true,
|
|
|
|
showDigitalClock: component.showdigitalclock || false,
|
|
|
|
showWeather: component.showweather || false,
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "logo":
|
|
|
|
components.logoControls.push({
|
|
|
|
text: component.text || '',
|
|
|
|
url: component.linkurl || undefined,
|
|
|
|
position: component.position.replace('-', '') || 'topleft',
|
|
|
|
image: component.logourl || undefined,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "chat":
|
|
|
|
if (response.allowwebchat) {
|
|
|
|
components.chatSending = {
|
|
|
|
loginRequired: response['webchat-requires-login'] || false,
|
|
|
|
maxLength: response['chatlengthlimit'] || 256,
|
|
|
|
cooldown: response['webchat-interval'] || 5,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "chatbox":
|
|
|
|
components.chatBox = {
|
|
|
|
allowUrlName: component.allowurlname || false,
|
|
|
|
showPlayerFaces: component.showplayerfaces || false,
|
|
|
|
messageLifetime: component.messagettl || Infinity,
|
|
|
|
messageHistory: component.scrollback || Infinity,
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "chatballoon":
|
|
|
|
components.chatBalloons = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return components;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static buildMarkerSet(id: string, data: any): any {
|
|
|
|
return {
|
|
|
|
id,
|
|
|
|
label: data.label || "Unnamed set",
|
|
|
|
hidden: data.hide || false,
|
|
|
|
priority: data.layerprio || 0,
|
|
|
|
showLabels: data.showlabels || undefined,
|
|
|
|
minZoom: typeof data.minzoom !== 'undefined' && data.minzoom > -1 ? data.minzoom : undefined,
|
|
|
|
maxZoom: typeof data.maxzoom !== 'undefined' && data.maxzoom > -1 ? data.maxzoom : undefined,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildMarkers(data: any): Map<string, LiveAtlasMarker> {
|
|
|
|
const markers = Object.freeze(new Map()) as Map<string, LiveAtlasMarker>;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(data, key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
markers.set(key, DynmapMapProvider.buildMarker(data[key]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return markers;
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildMarker(marker: any): LiveAtlasMarker {
|
2021-07-24 00:15:52 +00:00
|
|
|
return {
|
|
|
|
label: marker.label || '',
|
2021-07-28 16:49:38 +00:00
|
|
|
isLabelHTML: marker.markup || false,
|
2021-07-24 00:15:52 +00:00
|
|
|
location: {
|
|
|
|
x: marker.x || 0,
|
|
|
|
y: marker.y || 0,
|
|
|
|
z: marker.z || 0,
|
|
|
|
},
|
|
|
|
dimensions: marker.dim ? marker.dim.split('x') : [16, 16],
|
|
|
|
icon: marker.icon || "default",
|
|
|
|
minZoom: typeof marker.minzoom !== 'undefined' && marker.minzoom > -1 ? marker.minzoom : undefined,
|
|
|
|
maxZoom: typeof marker.maxzoom !== 'undefined' && marker.maxzoom > -1 ? marker.maxzoom : undefined,
|
|
|
|
popupContent: marker.desc || undefined,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildAreas(data: any): Map<string, LiveAtlasArea> {
|
|
|
|
const areas = Object.freeze(new Map()) as Map<string, LiveAtlasArea>;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(data, key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
areas.set(key, DynmapMapProvider.buildArea(data[key]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return areas;
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildArea(area: any): LiveAtlasArea {
|
2021-07-28 00:56:41 +00:00
|
|
|
const opacity = area.fillopacity || 0,
|
|
|
|
x = area.x || [0, 0],
|
|
|
|
y: [number, number] = [area.ybottom || 0, area.ytop || 0],
|
|
|
|
z = area.z || [0, 0];
|
|
|
|
|
2021-07-28 01:14:20 +00:00
|
|
|
return Object.seal({
|
2021-07-24 00:15:52 +00:00
|
|
|
style: {
|
|
|
|
color: area.color || '#ff0000',
|
|
|
|
opacity: area.opacity || 1,
|
|
|
|
weight: area.weight || 1,
|
|
|
|
fillColor: area.fillcolor || '#ff0000',
|
|
|
|
fillOpacity: area.fillopacity || 0,
|
|
|
|
},
|
2021-07-28 00:56:41 +00:00
|
|
|
outline: !opacity,
|
|
|
|
points: getPoints(x, y, z, !opacity),
|
2021-07-24 00:15:52 +00:00
|
|
|
minZoom: typeof area.minzoom !== 'undefined' && area.minzoom > -1 ? area.minzoom : undefined,
|
|
|
|
maxZoom: typeof area.maxzoom !== 'undefined' && area.maxzoom > -1 ? area.maxzoom : undefined,
|
2021-07-28 16:49:38 +00:00
|
|
|
|
|
|
|
isPopupHTML: area.desc ? true : area.markup || false,
|
|
|
|
popupContent: area.desc || area.label || undefined,
|
2021-07-28 01:14:20 +00:00
|
|
|
});
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildLines(data: any): Map<string, LiveAtlasLine> {
|
|
|
|
const lines = Object.freeze(new Map()) as Map<string, LiveAtlasLine>;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(data, key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
lines.set(key, DynmapMapProvider.buildLine(data[key]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return lines;
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildLine(line: any): LiveAtlasLine {
|
2021-07-28 01:14:20 +00:00
|
|
|
return Object.seal({
|
2021-07-24 00:15:52 +00:00
|
|
|
style: {
|
|
|
|
color: line.color || '#ff0000',
|
|
|
|
opacity: line.opacity || 1,
|
|
|
|
weight: line.weight || 1,
|
|
|
|
},
|
2021-07-28 00:56:41 +00:00
|
|
|
points: getLinePoints(line.x || [0, 0], line.y || [0, 0], line.z || [0, 0]),
|
2021-07-24 00:15:52 +00:00
|
|
|
minZoom: typeof line.minzoom !== 'undefined' && line.minzoom > -1 ? line.minzoom : undefined,
|
|
|
|
maxZoom: typeof line.maxzoom !== 'undefined' && line.maxzoom > -1 ? line.maxzoom : undefined,
|
2021-07-28 16:49:38 +00:00
|
|
|
|
|
|
|
isPopupHTML: line.desc ? true : line.markup || false,
|
|
|
|
popupContent: line.desc || line.label || undefined,
|
2021-07-28 01:14:20 +00:00
|
|
|
});
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildCircles(data: any): Map<string, LiveAtlasCircle> {
|
|
|
|
const circles = Object.freeze(new Map()) as Map<string, LiveAtlasCircle>;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
for (const key in data) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(data, key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
circles.set(key, DynmapMapProvider.buildCircle(data[key]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return circles;
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:06:19 +00:00
|
|
|
private static buildCircle(circle: any): LiveAtlasCircle {
|
2021-07-28 01:14:20 +00:00
|
|
|
return Object.seal({
|
2021-07-24 00:15:52 +00:00
|
|
|
location: {
|
|
|
|
x: circle.x || 0,
|
|
|
|
y: circle.y || 0,
|
|
|
|
z: circle.z || 0,
|
|
|
|
},
|
|
|
|
radius: [circle.xr || 0, circle.zr || 0],
|
|
|
|
style: {
|
|
|
|
fillColor: circle.fillcolor || '#ff0000',
|
|
|
|
fillOpacity: circle.fillopacity || 0,
|
|
|
|
color: circle.color || '#ff0000',
|
|
|
|
opacity: circle.opacity || 1,
|
|
|
|
weight: circle.weight || 1,
|
|
|
|
},
|
|
|
|
minZoom: typeof circle.minzoom !== 'undefined' && circle.minzoom > -1 ? circle.minzoom : undefined,
|
|
|
|
maxZoom: typeof circle.maxzoom !== 'undefined' && circle.maxzoom > -1 ? circle.maxzoom : undefined,
|
2021-07-28 16:49:38 +00:00
|
|
|
|
|
|
|
isPopupHTML: circle.desc ? true : circle.markup || false,
|
|
|
|
popupContent: circle.desc || circle.label || undefined,
|
2021-07-28 01:14:20 +00:00
|
|
|
});
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 03:04:43 +00:00
|
|
|
private buildUpdates(data: Array<any>) {
|
2021-07-24 00:15:52 +00:00
|
|
|
const updates = {
|
|
|
|
markerSets: new Map<string, DynmapMarkerSetUpdates>(),
|
|
|
|
tiles: [] as DynmapTileUpdate[],
|
2021-07-25 13:53:45 +00:00
|
|
|
chat: [] as LiveAtlasChat[],
|
2021-07-24 00:15:52 +00:00
|
|
|
},
|
|
|
|
dropped = {
|
|
|
|
stale: 0,
|
|
|
|
noSet: 0,
|
|
|
|
noId: 0,
|
|
|
|
unknownType: 0,
|
|
|
|
unknownCType: 0,
|
|
|
|
incomplete: 0,
|
|
|
|
notImplemented: 0,
|
|
|
|
},
|
|
|
|
lastUpdate = this.updateTimestamp;
|
|
|
|
|
|
|
|
let accepted = 0;
|
|
|
|
|
|
|
|
for (const entry of data) {
|
|
|
|
switch (entry.type) {
|
|
|
|
case 'component': {
|
|
|
|
if (lastUpdate && entry.timestamp < lastUpdate) {
|
|
|
|
dropped.stale++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!entry.id) {
|
|
|
|
dropped.noId++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Set updates don't have a set field, the id is the set
|
|
|
|
const set = entry.msg.startsWith("set") ? entry.id : entry.set;
|
|
|
|
|
|
|
|
if (!set) {
|
|
|
|
dropped.noSet++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.ctype !== 'markers') {
|
|
|
|
dropped.unknownCType++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!updates.markerSets.has(set)) {
|
|
|
|
updates.markerSets.set(set, {
|
|
|
|
areaUpdates: [],
|
|
|
|
markerUpdates: [],
|
|
|
|
lineUpdates: [],
|
|
|
|
circleUpdates: [],
|
|
|
|
removed: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const markerSetUpdates = updates.markerSets.get(set),
|
|
|
|
update: DynmapUpdate = {
|
|
|
|
id: entry.id,
|
|
|
|
removed: entry.msg.endsWith('deleted'),
|
|
|
|
};
|
|
|
|
|
|
|
|
if (entry.msg.startsWith("set")) {
|
|
|
|
markerSetUpdates!.removed = update.removed;
|
|
|
|
markerSetUpdates!.payload = update.removed ? undefined : DynmapMapProvider.buildMarkerSet(set, entry);
|
|
|
|
} else if (entry.msg.startsWith("marker")) {
|
|
|
|
update.payload = update.removed ? undefined : DynmapMapProvider.buildMarker(entry);
|
|
|
|
markerSetUpdates!.markerUpdates.push(Object.freeze(update));
|
|
|
|
} else if (entry.msg.startsWith("area")) {
|
|
|
|
update.payload = update.removed ? undefined : DynmapMapProvider.buildArea(entry);
|
|
|
|
markerSetUpdates!.areaUpdates.push(Object.freeze(update));
|
|
|
|
|
|
|
|
} else if (entry.msg.startsWith("circle")) {
|
|
|
|
update.payload = update.removed ? undefined : DynmapMapProvider.buildCircle(entry);
|
|
|
|
markerSetUpdates!.circleUpdates.push(Object.freeze(update));
|
|
|
|
|
|
|
|
} else if (entry.msg.startsWith("line")) {
|
|
|
|
update.payload = update.removed ? undefined : DynmapMapProvider.buildLine(entry);
|
|
|
|
markerSetUpdates!.lineUpdates.push(Object.freeze(update));
|
|
|
|
}
|
|
|
|
|
|
|
|
accepted++;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 'chat':
|
|
|
|
if (!entry.message || !entry.timestamp) {
|
|
|
|
dropped.incomplete++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.timestamp < lastUpdate) {
|
|
|
|
dropped.stale++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.source !== 'player' && entry.source !== 'web') {
|
|
|
|
dropped.notImplemented++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
updates.chat.push({
|
|
|
|
type: 'chat',
|
|
|
|
source: entry.source || undefined,
|
|
|
|
playerAccount: entry.account || undefined,
|
|
|
|
playerName: entry.playerName || undefined,
|
|
|
|
message: entry.message || "",
|
|
|
|
timestamp: entry.timestamp,
|
|
|
|
channel: entry.channel || undefined,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'playerjoin':
|
|
|
|
if (!entry.account || !entry.timestamp) {
|
|
|
|
dropped.incomplete++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.timestamp < lastUpdate) {
|
|
|
|
dropped.stale++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
updates.chat.push({
|
|
|
|
type: 'playerjoin',
|
|
|
|
playerAccount: entry.account,
|
|
|
|
playerName: entry.playerName || "",
|
|
|
|
timestamp: entry.timestamp || undefined,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'playerquit':
|
|
|
|
if (!entry.account || !entry.timestamp) {
|
|
|
|
dropped.incomplete++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entry.timestamp < lastUpdate) {
|
|
|
|
dropped.stale++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
updates.chat.push({
|
|
|
|
type: 'playerleave',
|
|
|
|
playerAccount: entry.account,
|
|
|
|
playerName: entry.playerName || "",
|
|
|
|
timestamp: entry.timestamp || undefined,
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'tile':
|
|
|
|
if (!entry.name || !entry.timestamp) {
|
|
|
|
dropped.incomplete++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastUpdate && entry.timestamp < lastUpdate) {
|
|
|
|
dropped.stale++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
updates.tiles.push({
|
|
|
|
name: entry.name,
|
|
|
|
timestamp: entry.timestamp,
|
|
|
|
});
|
|
|
|
|
|
|
|
accepted++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
dropped.unknownType++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Sort chat by newest first
|
|
|
|
updates.chat = updates.chat.sort((one, two) => {
|
|
|
|
return two.timestamp - one.timestamp;
|
|
|
|
});
|
|
|
|
|
|
|
|
console.debug(`Updates: ${accepted} accepted. Rejected: `, dropped);
|
|
|
|
|
|
|
|
return updates;
|
|
|
|
}
|
|
|
|
|
2021-07-25 00:57:59 +00:00
|
|
|
private async getMarkerSets(world: LiveAtlasWorldDefinition): Promise<Map<string, LiveAtlasMarkerSet>> {
|
|
|
|
const url = `${this.config.dynmap!.markers}_markers_/marker_${world.name}.json`;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
if(this.markersAbort) {
|
|
|
|
this.markersAbort.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.markersAbort = new AbortController();
|
|
|
|
|
2021-08-30 21:17:52 +00:00
|
|
|
const response = await DynmapMapProvider.getJSON(url, this.markersAbort.signal);
|
2021-07-24 03:06:19 +00:00
|
|
|
const sets: Map<string, LiveAtlasMarkerSet> = new Map();
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
response.sets = response.sets || {};
|
|
|
|
|
|
|
|
for (const key in response.sets) {
|
|
|
|
if (!Object.prototype.hasOwnProperty.call(response.sets, key)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const set = response.sets[key],
|
|
|
|
markers = DynmapMapProvider.buildMarkers(set.markers || {}),
|
|
|
|
circles = DynmapMapProvider.buildCircles(set.circles || {}),
|
|
|
|
areas = DynmapMapProvider.buildAreas(set.areas || {}),
|
|
|
|
lines = DynmapMapProvider.buildLines(set.lines || {});
|
|
|
|
|
|
|
|
sets.set(key, {
|
|
|
|
...DynmapMapProvider.buildMarkerSet(key, set),
|
|
|
|
markers,
|
|
|
|
circles,
|
|
|
|
areas,
|
|
|
|
lines,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return sets;
|
|
|
|
}
|
|
|
|
|
|
|
|
async loadServerConfiguration(): Promise<void> {
|
|
|
|
if(this.configurationAbort) {
|
|
|
|
this.configurationAbort.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.configurationAbort = new AbortController();
|
|
|
|
|
2021-08-30 21:17:52 +00:00
|
|
|
const response = await DynmapMapProvider.getJSON(this.config.dynmap!.configuration, this.configurationAbort.signal);
|
2021-07-24 00:15:52 +00:00
|
|
|
|
2021-08-30 21:27:41 +00:00
|
|
|
if(response.error === 'login-required') {
|
2021-09-07 22:10:57 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGIN_REQUIRED, true);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (response.error) {
|
2021-07-24 00:15:52 +00:00
|
|
|
throw new Error(response.error);
|
|
|
|
}
|
|
|
|
|
2021-07-24 03:03:36 +00:00
|
|
|
const config = DynmapMapProvider.buildServerConfig(response);
|
2021-07-24 00:15:52 +00:00
|
|
|
|
2021-07-24 01:13:03 +00:00
|
|
|
this.updateInterval = response.updaterate || 3000;
|
2021-07-24 00:15:52 +00:00
|
|
|
|
2021-07-24 03:03:36 +00:00
|
|
|
this.store.commit(MutationTypes.SET_SERVER_CONFIGURATION, config);
|
|
|
|
this.store.commit(MutationTypes.SET_SERVER_CONFIGURATION_HASH, response.confighash || 0);
|
2021-07-28 22:50:59 +00:00
|
|
|
this.store.commit(MutationTypes.SET_MAX_PLAYERS, response.maxcount || 0);
|
2021-07-24 03:03:36 +00:00
|
|
|
this.store.commit(MutationTypes.SET_SERVER_MESSAGES, DynmapMapProvider.buildMessagesConfig(response));
|
|
|
|
this.store.commit(MutationTypes.SET_WORLDS, this.buildWorlds(response));
|
|
|
|
this.store.commit(MutationTypes.SET_COMPONENTS, this.buildComponents(response));
|
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, response.loggedin || false);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 00:57:59 +00:00
|
|
|
async populateWorld(world: LiveAtlasWorldDefinition): Promise<void> {
|
|
|
|
const markerSets = await this.getMarkerSets(world);
|
2021-07-24 00:15:52 +00:00
|
|
|
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_MARKER_SETS, markerSets);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-24 03:04:43 +00:00
|
|
|
private async getUpdate(): Promise<void> {
|
2021-07-25 00:57:59 +00:00
|
|
|
let url = this.config.dynmap!.update;
|
2021-07-24 00:15:52 +00:00
|
|
|
url = url.replace('{world}', this.store.state.currentWorld!.name);
|
|
|
|
url = url.replace('{timestamp}', this.updateTimestamp.getTime().toString());
|
|
|
|
|
|
|
|
if(this.updateAbort) {
|
|
|
|
this.updateAbort.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateAbort = new AbortController();
|
|
|
|
|
2021-08-30 21:17:52 +00:00
|
|
|
const response = await DynmapMapProvider.getJSON(url, this.updateAbort.signal);
|
2021-07-24 03:04:43 +00:00
|
|
|
const players: Set<LiveAtlasPlayer> = new Set(),
|
|
|
|
updates = this.buildUpdates(response.updates || []),
|
|
|
|
worldState = {
|
|
|
|
timeOfDay: response.servertime || 0,
|
|
|
|
thundering: response.isThundering || false,
|
|
|
|
raining: response.hasStorm || false,
|
|
|
|
};
|
2021-07-24 00:15:52 +00:00
|
|
|
|
|
|
|
(response.players || []).forEach((player: any) => {
|
|
|
|
const world = player.world && player.world !== '-some-other-bogus-world-' ? player.world : undefined;
|
|
|
|
|
|
|
|
players.add({
|
2021-07-24 01:27:25 +00:00
|
|
|
name: player.account || "",
|
|
|
|
displayName: player.name || "",
|
2021-07-24 00:15:52 +00:00
|
|
|
health: player.health || 0,
|
|
|
|
armor: player.armor || 0,
|
|
|
|
sort: player.sort || 0,
|
|
|
|
hidden: !world,
|
|
|
|
location: {
|
|
|
|
//Add 0.5 to position in the middle of a block
|
|
|
|
x: !isNaN(player.x) ? player.x + 0.5 : 0,
|
|
|
|
y: !isNaN(player.y) ? player.y : 0,
|
|
|
|
z: !isNaN(player.z) ? player.z + 0.5 : 0,
|
|
|
|
world: world,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
//Extra fake players for testing
|
|
|
|
// for(let i = 0; i < 450; i++) {
|
|
|
|
// players.add({
|
|
|
|
// account: "VIDEO GAMES " + i,
|
|
|
|
// health: Math.round(Math.random() * 10),
|
|
|
|
// armor: Math.round(Math.random() * 10),
|
|
|
|
// name: "VIDEO GAMES " + i,
|
|
|
|
// sort: Math.round(Math.random() * 10),
|
|
|
|
// hidden: false,
|
|
|
|
// location: {
|
|
|
|
// x: Math.round(Math.random() * 1000) - 500,
|
|
|
|
// y: 64,
|
|
|
|
// z: Math.round(Math.random() * 1000) - 500,
|
|
|
|
// world: "world",
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
|
2021-07-24 03:04:43 +00:00
|
|
|
this.updateTimestamp = new Date(response.timestamp || 0);
|
|
|
|
|
|
|
|
this.store.commit(MutationTypes.SET_WORLD_STATE, worldState);
|
|
|
|
this.store.commit(MutationTypes.ADD_MARKER_SET_UPDATES, updates.markerSets);
|
|
|
|
this.store.commit(MutationTypes.ADD_TILE_UPDATES, updates.tiles);
|
|
|
|
this.store.commit(MutationTypes.ADD_CHAT, updates.chat);
|
2021-08-03 01:26:43 +00:00
|
|
|
|
|
|
|
if(response.configHash) {
|
|
|
|
this.store.commit(MutationTypes.SET_SERVER_CONFIGURATION_HASH, response.confighash || 0);
|
|
|
|
}
|
2021-07-24 03:04:43 +00:00
|
|
|
|
|
|
|
await this.store.dispatch(ActionTypes.SET_PLAYERS, players);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sendChatMessage(message: string) {
|
2021-09-08 14:21:27 +00:00
|
|
|
if (!this.store.state.components.chatSending) {
|
|
|
|
return Promise.reject(this.store.state.messages.chatErrorDisabled);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 00:57:59 +00:00
|
|
|
return fetch(this.config.dynmap!.sendmessage, {
|
2021-07-24 00:15:52 +00:00
|
|
|
method: 'POST',
|
2021-08-30 21:17:52 +00:00
|
|
|
credentials: 'include',
|
2021-07-24 00:15:52 +00:00
|
|
|
body: JSON.stringify({
|
|
|
|
name: null,
|
|
|
|
message: message,
|
|
|
|
})
|
|
|
|
}).then((response) => {
|
|
|
|
if (response.status === 403) { //Rate limited
|
2021-09-08 14:21:27 +00:00
|
|
|
throw new ChatError(this.store.state.messages.chatErrorCooldown
|
|
|
|
.replace('%interval%', this.store.state.components.chatSending!.cooldown.toString()));
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error('Network request failed');
|
|
|
|
}
|
|
|
|
|
|
|
|
return response.json();
|
|
|
|
}).then(response => {
|
|
|
|
if (response.error !== 'none') {
|
2021-09-08 14:21:27 +00:00
|
|
|
throw new ChatError(this.store.state.messages.chatErrorNotAllowed);
|
2021-07-24 00:15:52 +00:00
|
|
|
}
|
|
|
|
}).catch(e => {
|
|
|
|
if (!(e instanceof ChatError)) {
|
2021-09-08 14:21:27 +00:00
|
|
|
console.error(this.store.state.messages.chatErrorUnknown);
|
2021-07-24 00:15:52 +00:00
|
|
|
console.trace(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
throw e;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
startUpdates() {
|
|
|
|
this.updatesEnabled = true;
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
private async update() {
|
|
|
|
try {
|
2021-07-24 03:04:43 +00:00
|
|
|
await this.getUpdate();
|
2021-07-24 00:15:52 +00:00
|
|
|
} finally {
|
|
|
|
if(this.updatesEnabled) {
|
|
|
|
if(this.updateTimeout) {
|
|
|
|
clearTimeout(this.updateTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateTimeout = setTimeout(() => this.update(), this.updateInterval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stopUpdates() {
|
|
|
|
this.updatesEnabled = false;
|
|
|
|
|
|
|
|
if (this.updateTimeout) {
|
|
|
|
clearTimeout(this.updateTimeout);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateTimeout = 0;
|
|
|
|
}
|
|
|
|
|
2021-07-25 00:57:59 +00:00
|
|
|
getTilesUrl(): string {
|
|
|
|
return this.config.dynmap!.tiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
getPlayerHeadUrl(head: HeadQueueEntry): string {
|
2021-07-29 18:05:33 +00:00
|
|
|
const icon = (head.size === 'body') ? `faces/body/${head.name}` :`faces/${head.size}x${head.size}/${head.name}`
|
2021-07-25 00:57:59 +00:00
|
|
|
|
2021-08-02 16:12:29 +00:00
|
|
|
return `${this.config.dynmap!.markers}${icon}.png`;
|
2021-07-25 00:57:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
getMarkerIconUrl(icon: string): string {
|
|
|
|
return `${this.config.dynmap!.markers}_markers_/${icon}.png`;
|
|
|
|
}
|
|
|
|
|
2021-08-30 21:27:41 +00:00
|
|
|
async login(data: any) {
|
2021-09-08 14:21:27 +00:00
|
|
|
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
|
|
|
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
2021-08-30 21:27:41 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const body = new URLSearchParams();
|
|
|
|
|
|
|
|
body.append('j_username', data.username || '');
|
|
|
|
body.append('j_password', data.password || '');
|
|
|
|
|
|
|
|
|
|
|
|
const response = await DynmapMapProvider.fetchJSON(this.config.dynmap!.login, {
|
|
|
|
method: 'POST',
|
|
|
|
body,
|
|
|
|
});
|
|
|
|
|
|
|
|
switch(response.result) {
|
|
|
|
case 'success':
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, true);
|
2021-08-30 21:27:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case 'loginfailed':
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.loginErrorIncorrect);
|
2021-08-30 21:27:41 +00:00
|
|
|
|
|
|
|
default:
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.loginErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
} catch(e) {
|
2021-09-08 14:21:27 +00:00
|
|
|
console.error(this.store.state.messages.loginErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
console.trace(e);
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.loginErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async logout() {
|
2021-09-08 14:21:27 +00:00
|
|
|
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
|
|
|
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await DynmapMapProvider.fetchJSON(this.config.dynmap!.login, {
|
|
|
|
method: 'POST',
|
|
|
|
});
|
|
|
|
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
2021-08-30 21:27:41 +00:00
|
|
|
} catch(e) {
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.logoutErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async register(data: any) {
|
2021-09-08 14:21:27 +00:00
|
|
|
if (!this.store.state.components.login && !this.store.state.loginRequired) {
|
|
|
|
return Promise.reject(this.store.state.messages.loginErrorDisabled);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, false);
|
2021-08-30 21:27:41 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
const body = new URLSearchParams();
|
|
|
|
|
|
|
|
body.append('j_username', data.username || '');
|
|
|
|
body.append('j_password', data.password || '');
|
|
|
|
body.append('j_verify_password', data.password || '');
|
|
|
|
body.append('j_passcode', data.code || '');
|
|
|
|
|
|
|
|
const response = await DynmapMapProvider.fetchJSON(this.config.dynmap!.register, {
|
|
|
|
method: 'POST',
|
|
|
|
body,
|
|
|
|
});
|
|
|
|
|
|
|
|
switch(response.result) {
|
|
|
|
case 'success':
|
2021-09-08 14:21:27 +00:00
|
|
|
this.store.commit(MutationTypes.SET_LOGGED_IN, true);
|
2021-08-30 21:27:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
case 'verifyfailed':
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.registerErrorVerifyFailed);
|
2021-08-30 21:27:41 +00:00
|
|
|
|
|
|
|
case 'registerfailed':
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.registerErrorIncorrect);
|
2021-08-30 21:27:41 +00:00
|
|
|
|
|
|
|
default:
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.registerErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
} catch(e) {
|
2021-09-08 14:21:27 +00:00
|
|
|
console.error(this.store.state.messages.registerErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
console.trace(e);
|
2021-09-08 14:21:27 +00:00
|
|
|
return Promise.reject(this.store.state.messages.registerErrorUnknown);
|
2021-08-30 21:27:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-24 00:15:52 +00:00
|
|
|
destroy() {
|
2021-07-25 00:57:59 +00:00
|
|
|
super.destroy();
|
|
|
|
|
2021-07-24 00:15:52 +00:00
|
|
|
if(this.configurationAbort) {
|
|
|
|
this.configurationAbort.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.updateAbort) {
|
|
|
|
this.updateAbort.abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(this.markersAbort) {
|
|
|
|
this.markersAbort.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|