diff --git a/src/api.ts b/src/api.ts index a3d2aea..62bb3e6 100644 --- a/src/api.ts +++ b/src/api.ts @@ -33,9 +33,11 @@ import { } from "@/dynmap"; import {useStore} from "@/store"; import ChatError from "@/errors/ChatError"; -import {LiveAtlasServerMessageConfig, LiveAtlasWorld} from "@/index"; +import {LiveAtlasDimension, LiveAtlasServerMessageConfig, LiveAtlasWorld} from "@/index"; -const titleColours = /§[0-9a-f]/ig; +const titleColours = /§[0-9a-f]/ig, + netherWorldName = /(^|_)nether(_|$)/i, + endWorldName = /(^|_)end(_|$)/i; function buildServerConfig(response: any): DynmapServerConfig { return { @@ -75,9 +77,18 @@ function buildWorlds(response: any): Array { //Get all the worlds first so we can handle append_to_world properly (response.worlds || []).forEach((world: any) => { + let worldType: LiveAtlasDimension = 'overworld'; + + if (netherWorldName.test(world.name) || (world.name == 'DIM-1')) { + worldType = 'nether'; + } else if (endWorldName.test(world.name) || (world.name == 'DIM1')) { + worldType = 'end'; + } + worlds.set(world.name, { seaLevel: world.sealevel || 64, name: world.name, + dimension: worldType, protected: world.protected || false, title: world.title || '', height: world.height || 256, diff --git a/src/components/sidebar/WorldListItem.vue b/src/components/sidebar/WorldListItem.vue index eb6ae14..bdb09be 100644 --- a/src/components/sidebar/WorldListItem.vue +++ b/src/components/sidebar/WorldListItem.vue @@ -79,15 +79,22 @@ export default defineComponent({ let worldType: string, mapType: string; - if (/(^|_)nether(_|$)/i.test(this.world.name) || (this.world.name == 'DIM-1')) { - worldType = 'nether'; - mapType = ['surface', 'nether'].includes(map.name) ? 'surface' : 'flat'; - } else if (/(^|_)end(_|$)/i.test(this.world.name) || (this.world.name == 'DIM1')) { - worldType = 'the_end'; - mapType = ['surface', 'the_end'].includes(map.name) ? 'surface' : 'flat'; - } else { - worldType = 'world'; - mapType = ['surface', 'flat', 'biome', 'cave'].includes(map.name) ? map.name : 'flat'; + switch(this.world.dimension) { + case 'nether': + worldType = 'nether'; + mapType = ['surface', 'nether'].includes(map.name) ? 'surface' : 'flat'; + break; + + case 'end': + worldType = 'the_end'; + mapType = ['surface', 'the_end'].includes(map.name) ? 'surface' : 'flat'; + break; + + case 'overworld': + default: + worldType = 'world'; + mapType = ['surface', 'flat', 'biome', 'cave'].includes(map.name) ? map.name : 'flat'; + break; } return `block_${worldType}_${mapType}`; diff --git a/src/index.d.ts b/src/index.d.ts index 2488964..457af61 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -105,6 +105,7 @@ interface LiveAtlasUIConfig { export type LiveAtlasUIElement = 'layers' | 'chat' | 'players' | 'maps' | 'settings'; export type LiveAtlasSidebarSection = 'servers' | 'players' | 'maps'; +export type LiveAtlasDimension = 'overworld' | 'nether' | 'end'; interface LiveAtlasSortedPlayers extends Array { dirty?: boolean; @@ -113,6 +114,7 @@ interface LiveAtlasSortedPlayers extends Array { interface LiveAtlasWorld { seaLevel: number; name: string; + dimension: LiveAtlasDimension; protected: boolean; title: string; height: number;