Add world dimension property

This commit is contained in:
James Lyne 2021-07-21 17:27:24 +01:00
parent ea181f3a0b
commit 2f107b2126
3 changed files with 31 additions and 11 deletions

View File

@ -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<LiveAtlasWorld> {
//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,

View File

@ -79,15 +79,22 @@ export default defineComponent({
let worldType: string,
mapType: string;
if (/(^|_)nether(_|$)/i.test(this.world.name) || (this.world.name == 'DIM-1')) {
switch(this.world.dimension) {
case 'nether':
worldType = 'nether';
mapType = ['surface', 'nether'].includes(map.name) ? 'surface' : 'flat';
} else if (/(^|_)end(_|$)/i.test(this.world.name) || (this.world.name == 'DIM1')) {
break;
case 'end':
worldType = 'the_end';
mapType = ['surface', 'the_end'].includes(map.name) ? 'surface' : 'flat';
} else {
break;
case 'overworld':
default:
worldType = 'world';
mapType = ['surface', 'flat', 'biome', 'cave'].includes(map.name) ? map.name : 'flat';
break;
}
return `block_${worldType}_${mapType}`;

2
src/index.d.ts vendored
View File

@ -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<DynmapPlayer> {
dirty?: boolean;
@ -113,6 +114,7 @@ interface LiveAtlasSortedPlayers extends Array<DynmapPlayer> {
interface LiveAtlasWorld {
seaLevel: number;
name: string;
dimension: LiveAtlasDimension;
protected: boolean;
title: string;
height: number;