Respect dynmap append_to_world setting (Fixes #28)
This commit is contained in:
parent
c65da2ad03
commit
a623179039
49
src/api.ts
49
src/api.ts
@ -104,14 +104,37 @@ function buildMessagesConfig(response: any): LiveAtlasMessageConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buildWorlds(response: any): Array<DynmapWorld> {
|
function buildWorlds(response: any): Array<DynmapWorld> {
|
||||||
const worlds: Array<DynmapWorld> = [];
|
const worlds: Map<string, DynmapWorld> = new Map<string, DynmapWorld>();
|
||||||
|
|
||||||
|
//Get all the worlds first so we can handle append_to_world properly
|
||||||
|
(response.worlds || []).forEach((world: any) => {
|
||||||
|
worlds.set(world.name, {
|
||||||
|
seaLevel: world.sealevel || 64,
|
||||||
|
name: world.name,
|
||||||
|
protected: world.protected || false,
|
||||||
|
title: world.title || '',
|
||||||
|
height: world.height || 256,
|
||||||
|
center: {
|
||||||
|
x: world.center.x || 0,
|
||||||
|
y: world.center.y || 0,
|
||||||
|
z: world.center.z || 0
|
||||||
|
},
|
||||||
|
maps: new Map(),
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
(response.worlds || []).forEach((world: any) => {
|
(response.worlds || []).forEach((world: any) => {
|
||||||
const maps: Map<string, DynmapWorldMap> = new Map();
|
|
||||||
|
|
||||||
(world.maps || []).forEach((map: any) => {
|
(world.maps || []).forEach((map: any) => {
|
||||||
maps.set(map.name, {
|
const worldName = map.append_to_world || world.name,
|
||||||
world: world,
|
w = worlds.get(worldName);
|
||||||
|
|
||||||
|
if(!w) {
|
||||||
|
console.warn(`Ignoring map '${map.name}' associated with non-existent world '${worldName}'`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
w.maps.set(map.name, {
|
||||||
|
world: world, //Ignore append_to_world here otherwise things break
|
||||||
background: map.background || '#000000',
|
background: map.background || '#000000',
|
||||||
backgroundDay: map.backgroundday || '#000000',
|
backgroundDay: map.backgroundday || '#000000',
|
||||||
backgroundNight: map.backgroundnight || '#000000',
|
backgroundNight: map.backgroundnight || '#000000',
|
||||||
@ -128,23 +151,9 @@ function buildWorlds(response: any): Array<DynmapWorld> {
|
|||||||
extraZoomLevels: map.mapzoomin || 0,
|
extraZoomLevels: map.mapzoomin || 0,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
worlds.push({
|
|
||||||
seaLevel: world.sealevel || 64,
|
|
||||||
name: world.name || '(Unnamed world)',
|
|
||||||
protected: world.protected || false,
|
|
||||||
title: world.title || '',
|
|
||||||
height: world.height || 256,
|
|
||||||
center: {
|
|
||||||
x: world.center.x || 0,
|
|
||||||
y: world.center.y || 0,
|
|
||||||
z: world.center.z || 0
|
|
||||||
},
|
|
||||||
maps,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return worlds;
|
return Array.from(worlds.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildComponents(response: any): DynmapComponentConfig {
|
function buildComponents(response: any): DynmapComponentConfig {
|
||||||
|
@ -66,7 +66,7 @@ export default defineComponent({
|
|||||||
currentMap: {
|
currentMap: {
|
||||||
get() {
|
get() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
return store.state.currentMap ? [store.state.currentMap.world.name, store.state.currentMap.name] : undefined;
|
return store.state.currentMap ? [store.state.currentWorld.name, store.state.currentMap.name] : undefined;
|
||||||
},
|
},
|
||||||
set(value: string[]) {
|
set(value: string[]) {
|
||||||
useStore().commit(MutationTypes.SET_CURRENT_MAP, {worldName: value[0], mapName: value[1]});
|
useStore().commit(MutationTypes.SET_CURRENT_MAP, {worldName: value[0], mapName: value[1]});
|
||||||
|
Loading…
Reference in New Issue
Block a user