diff --git a/src/providers/DynmapMapProvider.ts b/src/providers/DynmapMapProvider.ts index f0beb1f..2ade58a 100644 --- a/src/providers/DynmapMapProvider.ts +++ b/src/providers/DynmapMapProvider.ts @@ -582,40 +582,6 @@ export default class DynmapMapProvider extends MapProvider { return updates; } - private static async fetchJSON(url: string, signal: AbortSignal) { - let response, json; - - try { - response = await fetch(url, {signal}); - } catch(e) { - if(e instanceof DOMException && e.name === 'AbortError') { - console.warn(`Request aborted (${url}`); - throw e; - } else { - console.error(e); - } - - throw new Error(`Network request failed`); - } - - if (!response.ok) { - throw new Error(`Network request failed (${response.statusText || 'Unknown'})`); - } - - try { - json = await response.json(); - } catch(e) { - if(e instanceof DOMException && e.name === 'AbortError') { - console.warn(`Request aborted (${url}`); - throw e; - } else { - throw new Error('Request returned invalid json'); - } - } - - return json; - } - private async getMarkerSets(world: string): Promise> { const url = `${useStore().getters.serverConfig.dynmap.markers}_markers_/marker_${world}.json`; diff --git a/src/providers/MapProvider.ts b/src/providers/MapProvider.ts index 8644e52..8e09b9e 100644 --- a/src/providers/MapProvider.ts +++ b/src/providers/MapProvider.ts @@ -16,10 +16,44 @@ export default abstract class MapProvider implements LiveAtlasMapProvider { }); } - abstract destroy(): void; abstract loadServerConfiguration(): Promise; abstract loadWorldConfiguration(world: LiveAtlasWorldDefinition): Promise; abstract sendChatMessage(message: string): void; abstract startUpdates(): void; abstract stopUpdates(): void; + abstract destroy(): void; + + protected static async fetchJSON(url: string, signal: AbortSignal) { + let response, json; + + try { + response = await fetch(url, {signal}); + } catch(e) { + if(e instanceof DOMException && e.name === 'AbortError') { + console.warn(`Request aborted (${url}`); + throw e; + } else { + console.error(e); + } + + throw new Error(`Network request failed`); + } + + if (!response.ok) { + throw new Error(`Network request failed (${response.statusText || 'Unknown'})`); + } + + try { + json = await response.json(); + } catch(e) { + if(e instanceof DOMException && e.name === 'AbortError') { + console.warn(`Request aborted (${url}`); + throw e; + } else { + throw new Error('Request returned invalid json'); + } + } + + return json; + } }