Skip to content

Commit

Permalink
Merge branch 'v3' into feat/add-unpause-command
Browse files Browse the repository at this point in the history
  • Loading branch information
granny committed Mar 30, 2024
2 parents 24c7e56 + 6d011ee commit 280f05b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 17 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/net/pl3x/map/core/configuration/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ public final class Lang extends AbstractConfig {
public static String UI_BLOCKINFO_LABEL = "BlockInfo";
@Key("ui.blockinfo.value")
public static String UI_BLOCKINFO_VALUE = "<block><br /><biome>";
@Key("ui.blockinfo.unknown.block")
public static String UI_BLOCKINFO_UNKNOWN_BLOCK = "Unknown block";
@Key("ui.blockinfo.unknown.biome")
public static String UI_BLOCKINFO_UNKNOWN_BIOME = "Unknown biome";
@Key("ui.coords.label")
public static String UI_COORDS_LABEL = "Coordinates";
@Key("ui.coords.value")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ private void parseSettings() {
Map<String, Object> lang = new LinkedHashMap<>();
lang.put("title", Lang.UI_TITLE);
lang.put("langFile", Lang.UI_BLOCK_AND_BIOME_LANG_FILE);
lang.put("blockInfo", Map.of("label", Lang.UI_BLOCKINFO_LABEL, "value", Lang.UI_BLOCKINFO_VALUE));
lang.put("blockInfo", Map.of(
"label", Lang.UI_BLOCKINFO_LABEL,
"value", Lang.UI_BLOCKINFO_VALUE,
"unknown", Map.of("block", Lang.UI_BLOCKINFO_UNKNOWN_BLOCK, "biome", Lang.UI_BLOCKINFO_UNKNOWN_BIOME))
);
lang.put("coords", Map.of("label", Lang.UI_COORDS_LABEL, "value", Lang.UI_COORDS_VALUE));
lang.put("layers", Map.of("label", Lang.UI_LAYERS_LABEL, "value", Lang.UI_LAYERS_VALUE));
lang.put("link", Map.of("label", Lang.UI_LINK_LABEL, "value", Lang.UI_LINK_VALUE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ ui:
spawn: Spawn
worldborder: Granica świata
title: Pl3xMap
block-and-biome-lang-file: en_us.json # IDK?
block-and-biome-lang-file: pl_pl.json # webmap/public/lang/
blockinfo:
label: Informacje o bloku # Or keep it BlockInfo?
label: BlockInfo
value: <block><br /><biome>
unknown:
block: Nieznany blok
biome: Nieznany biom
coords:
label: Współrzędne
value: <x>, <y>, <z>
Expand Down
24 changes: 14 additions & 10 deletions webmap/src/control/BlockInfoControl.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as L from "leaflet";
import {Pl3xMap} from "../Pl3xMap";
import {Block} from "../palette/Block";
import {ControlBox} from "./ControlBox";
import {getJSON, getLangName} from "../util/Util";
import { Pl3xMap } from "../Pl3xMap";
import { Block } from "../palette/Block";
import { ControlBox } from "./ControlBox";
import { getJSON, getLangName } from "../util/Util";
import Pl3xMapLeafletMap from "../map/Pl3xMapLeafletMap";
import {CoordsControl} from "./CoordsControl";
import {BlockInfo} from "../palette/BlockInfo";
import { CoordsControl } from "./CoordsControl";
import { BlockInfo } from "../palette/BlockInfo";

export class BlockInfoControl extends ControlBox {
private _dom: HTMLDivElement = L.DomUtil.create('div');
Expand Down Expand Up @@ -44,16 +44,20 @@ export class BlockInfoControl extends ControlBox {
const tileX: number = (x / step) & 511;
const tileZ: number = (z / step) & 511;

let blockName: string = 'unknown';
let biomeName: string = 'unknown';
let blockName: string = this._pl3xmap.settings!.lang.blockInfo.unknown.block ?? 'Unknown block';
let biomeName: string = this._pl3xmap.settings!.lang.blockInfo.unknown.biome ?? 'Unknown biome';
let y: number | undefined;

const blockInfo: BlockInfo | undefined = this._pl3xmap.worldManager.currentWorld?.getBlockInfo(zoom, fileX, fileZ);
if (blockInfo !== undefined) {
const block: Block = blockInfo.getBlock(tileZ * 512 + tileX);
if (block != null) {
blockName = block.block == 0 ? 'unknown' : this._blockPalette.get(block.block) ?? 'unknown';
biomeName = block.biome == 0 ? 'unknown' : this._pl3xmap.worldManager.currentWorld?.biomePalette.get(block.biome) ?? 'unknown';
if (block.block != 0) {
blockName = this._blockPalette.get(block.block) ?? blockName;
}
if (block.biome != 0) {
biomeName = this._pl3xmap.worldManager.currentWorld?.biomePalette.get(block.biome) ?? biomeName;
}

if (block.block != 0) {
y = block.yPos + 1;
Expand Down
48 changes: 44 additions & 4 deletions webmap/src/settings/Lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ export class Lang {
private readonly _title: string;
private readonly _langFile: string;
private readonly _coords: Label;
private readonly _blockInfo: Label;
private readonly _blockInfo: BlockInfo;
private readonly _layers: Label;
private readonly _link: Label;
private readonly _markers: Label;
private readonly _players: Label;
private readonly _worlds: Label;

constructor(title: string, langFile: string, coords: Label, blockInfo: Label, layers: Label, link: Label, markers: Label, players: Label, worlds: Label) {
constructor(title: string, langFile: string, coords: Label, blockInfo: BlockInfo, layers: Label, link: Label, markers: Label, players: Label, worlds: Label) {
this._title = title;
this._langFile = langFile;
this._coords = coords;
Expand All @@ -36,7 +36,7 @@ export class Lang {
return this._coords;
}

get blockInfo(): Label {
get blockInfo(): BlockInfo {
return this._blockInfo;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ export class Lang {
* Represents a label and value.
*/
export class Label {
private readonly _label: string
private readonly _label: string;
private readonly _value: string;

constructor(label: string, value: string) {
Expand All @@ -81,3 +81,43 @@ export class Label {
return this._value;
}
}

/**
* Represents 'unknown' values for BlockInfo.
*/
export class BlockInfoUnknown {
private readonly _block: string;
private readonly _biome: string;


constructor(block: string, biome: string) {
this._block = block;
this._biome = biome;
}

get block(): string {
return this._block;
}

get biome(): string {
return this._biome;
}
}


/**
* Represents a label and a value, with 'unknown' values.
*/
export class BlockInfo extends Label {
private readonly _unknown: BlockInfoUnknown;


constructor(label: string, value: string, unknown: BlockInfoUnknown) {
super(label, value);
this._unknown = unknown;
}

get unknown(): BlockInfoUnknown {
return this._unknown;
}
}

0 comments on commit 280f05b

Please sign in to comment.