Skip to content

Commit

Permalink
implement buildMapLink on Squaremap
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen3H committed Jun 21, 2024
1 parent 1bbbf1f commit e23331e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/api/squaremap/Squaremap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SquaremapMapResponse, ValidMapName } from "src/types.js"
import { Point2D, SquaremapMapResponse, ValidMapName } from "../..//types.js"
import DataHandler from "../../helpers/DataHandler.js"

import Towns from '../squaremap/Towns.js'
Expand Down Expand Up @@ -34,6 +34,16 @@ class Squaremap extends DataHandler {
const res = await this.mapData<SquaremapMapResponse>()
return res.find(x => x.id == "towny")
}

buildMapLink = (zoom?: number, location?: Point2D): URL => {
const url = new URL(`https://map.earthmc.net/?mapname=flat`)
if (zoom) url.searchParams.append("zoom", zoom.toString())

if (location?.x) url.searchParams.append("x", location.x.toString())
if (location?.z) url.searchParams.append("z", location.z.toString())

return url
}
}

export {
Expand Down

0 comments on commit e23331e

Please sign in to comment.