├── .editorconfig ├── .github ├── FUNDING.yml └── workflows │ ├── build.yml │ ├── build_pr.yml │ ├── pr_comment.yml │ └── pullrequest.yml ├── .gitignore ├── .tokeignore ├── LICENSE ├── README.md ├── TODO.md ├── build.gradle.kts ├── buildSrc └── settings.gradle.kts ├── bukkit ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── pl3x │ │ └── map │ │ └── bukkit │ │ ├── BukkitNetwork.java │ │ ├── BukkitPlayer.java │ │ ├── BukkitWorld.java │ │ ├── Pl3xMapBukkit.java │ │ ├── Pl3xMapImpl.java │ │ ├── command │ │ ├── BukkitCommandManager.java │ │ ├── BukkitParsers.java │ │ └── BukkitSender.java │ │ ├── network │ │ ├── ClientboundMapPayload.java │ │ ├── ClientboundServerPayload.java │ │ ├── ServerboundMapPayload.java │ │ └── ServerboundServerPayload.java │ │ └── util │ │ └── SchedulerUtil.java │ └── resources │ └── plugin.yml ├── core ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── pl3x │ │ └── map │ │ └── core │ │ ├── Keyed.java │ │ ├── Pl3xMap.java │ │ ├── command │ │ ├── CommandHandler.java │ │ ├── Pl3xMapCommand.java │ │ ├── Sender.java │ │ ├── commands │ │ │ ├── ConfirmCommand.java │ │ │ ├── FullRenderCommand.java │ │ │ ├── HelpCommand.java │ │ │ ├── HideCommand.java │ │ │ ├── PauseCommand.java │ │ │ ├── RadiusRenderCommand.java │ │ │ ├── ReloadCommand.java │ │ │ ├── ResetMapCommand.java │ │ │ ├── ResumeCommand.java │ │ │ ├── ShowCommand.java │ │ │ ├── StatusCommand.java │ │ │ ├── StitchCommand.java │ │ │ └── VersionCommand.java │ │ ├── exception │ │ │ ├── ArgumentParseException.java │ │ │ ├── PlayerParseException.java │ │ │ ├── PointParseException.java │ │ │ ├── RendererParseException.java │ │ │ ├── WorldParseException.java │ │ │ └── ZoomParseException.java │ │ └── parser │ │ │ ├── PlatformParsers.java │ │ │ ├── RendererParser.java │ │ │ ├── WorldParser.java │ │ │ └── ZoomParser.java │ │ ├── configuration │ │ ├── AbstractConfig.java │ │ ├── ColorsConfig.java │ │ ├── Config.java │ │ ├── Lang.java │ │ ├── PlayersLayerConfig.java │ │ ├── SpawnLayerConfig.java │ │ ├── WorldBorderLayerConfig.java │ │ └── WorldConfig.java │ │ ├── event │ │ ├── Event.java │ │ ├── EventHandler.java │ │ ├── EventListener.java │ │ ├── EventRegistry.java │ │ ├── RegisteredHandler.java │ │ ├── server │ │ │ ├── Pl3xMapDisabledEvent.java │ │ │ ├── Pl3xMapEnabledEvent.java │ │ │ └── ServerLoadedEvent.java │ │ └── world │ │ │ ├── WorldEvent.java │ │ │ ├── WorldLoadedEvent.java │ │ │ └── WorldUnloadedEvent.java │ │ ├── httpd │ │ ├── HttpdServer.java │ │ └── LiveDataHandler.java │ │ ├── image │ │ ├── IconImage.java │ │ ├── TileImage.java │ │ └── io │ │ │ ├── Bmp.java │ │ │ ├── Gif.java │ │ │ ├── IO.java │ │ │ ├── Jpg.java │ │ │ └── Png.java │ │ ├── log │ │ ├── LogFilter.java │ │ └── Logger.java │ │ ├── markers │ │ ├── JsonObjectWrapper.java │ │ ├── JsonSerializable.java │ │ ├── Point.java │ │ ├── Vector.java │ │ ├── area │ │ │ ├── Area.java │ │ │ ├── Border.java │ │ │ ├── Circle.java │ │ │ └── Rectangle.java │ │ ├── layer │ │ │ ├── CustomLayer.java │ │ │ ├── Layer.java │ │ │ ├── PlayersLayer.java │ │ │ ├── SimpleLayer.java │ │ │ ├── SpawnLayer.java │ │ │ ├── WorldBorderLayer.java │ │ │ └── WorldLayer.java │ │ ├── marker │ │ │ ├── Circle.java │ │ │ ├── Ellipse.java │ │ │ ├── Icon.java │ │ │ ├── Marker.java │ │ │ ├── MultiPolygon.java │ │ │ ├── MultiPolyline.java │ │ │ ├── Polygon.java │ │ │ ├── Polyline.java │ │ │ └── Rectangle.java │ │ └── option │ │ │ ├── Fill.java │ │ │ ├── Option.java │ │ │ ├── Options.java │ │ │ ├── Popup.java │ │ │ ├── Stroke.java │ │ │ └── Tooltip.java │ │ ├── metrics │ │ └── Metrics.java │ │ ├── network │ │ ├── Constants.java │ │ └── Network.java │ │ ├── player │ │ ├── Player.java │ │ ├── PlayerListener.java │ │ ├── PlayerRegistry.java │ │ └── PlayerTexture.java │ │ ├── registry │ │ ├── BiomeRegistry.java │ │ ├── BlockRegistry.java │ │ ├── IconRegistry.java │ │ ├── Registry.java │ │ ├── RendererRegistry.java │ │ └── WorldRegistry.java │ │ ├── renderer │ │ ├── BasicRenderer.java │ │ ├── BiomeRenderer.java │ │ ├── BlockInfoRenderer.java │ │ ├── FlowerMapRenderer.java │ │ ├── InhabitedRenderer.java │ │ ├── NetherRoofRenderer.java │ │ ├── NightRenderer.java │ │ ├── Renderer.java │ │ ├── VanillaRenderer.java │ │ ├── VintageStoryRenderer.java │ │ ├── heightmap │ │ │ ├── EvenOddHeightmap.java │ │ │ ├── EvenOddHighContrastHeightmap.java │ │ │ ├── EvenOddLowContrastHeightmap.java │ │ │ ├── EvenOddModernHeightmap.java │ │ │ ├── EvenOddOldSchoolHeightmap.java │ │ │ ├── EvenOddVanillaHeightmap.java │ │ │ ├── Heightmap.java │ │ │ ├── HeightmapRegistry.java │ │ │ ├── HighContrastHeightmap.java │ │ │ ├── LowContrastHeightmap.java │ │ │ ├── ModernHeightmap.java │ │ │ ├── NoneHeightmap.java │ │ │ ├── OldSchoolHeightmap.java │ │ │ └── VanillaHeightmap.java │ │ ├── progress │ │ │ ├── CPSTracker.java │ │ │ └── Progress.java │ │ └── task │ │ │ ├── AbstractDataTask.java │ │ │ ├── RegionDoubleChecker.java │ │ │ ├── RegionFileWatcher.java │ │ │ ├── RegionProcessor.java │ │ │ ├── RegionScanTask.java │ │ │ ├── UpdateLiveData.java │ │ │ ├── UpdateMarkerData.java │ │ │ └── UpdateSettingsData.java │ │ ├── scheduler │ │ ├── Scheduler.java │ │ └── Task.java │ │ ├── util │ │ ├── BlurTool.java │ │ ├── ByteUtil.java │ │ ├── Colors.java │ │ ├── FileUtil.java │ │ ├── MCAMath.java │ │ ├── Mathf.java │ │ ├── PackedIntArrayAccess.java │ │ ├── Preconditions.java │ │ ├── SpiralIterator.java │ │ ├── StringUtils.java │ │ └── TickUtil.java │ │ └── world │ │ ├── Biome.java │ │ ├── BiomeManager.java │ │ ├── Block.java │ │ ├── BlockState.java │ │ ├── Blocks.java │ │ ├── Chunk.java │ │ ├── ChunkAnvil113.java │ │ ├── ChunkAnvil115.java │ │ ├── ChunkAnvil116.java │ │ ├── ChunkAnvil118.java │ │ ├── EmptyChunk.java │ │ ├── LegacyBiomes.java │ │ ├── Region.java │ │ ├── RegionModifiedState.java │ │ └── World.java │ └── resources │ ├── config.yml │ └── locale │ ├── lang-ja.yml │ ├── lang-pl.yml │ └── lang-zh.yml ├── fabric ├── build.gradle.kts └── src │ └── main │ ├── java │ └── net │ │ └── pl3x │ │ └── map │ │ └── fabric │ │ ├── client │ │ ├── Pl3xMapFabricClient.java │ │ ├── duck │ │ │ └── MapInstance.java │ │ ├── manager │ │ │ ├── NetworkManager.java │ │ │ └── TileManager.java │ │ └── mixin │ │ │ └── MapInstanceMixin.java │ │ ├── common │ │ └── network │ │ │ ├── ClientboundMapPayload.java │ │ │ ├── ClientboundServerPayload.java │ │ │ ├── ServerboundMapPayload.java │ │ │ └── ServerboundServerPayload.java │ │ └── server │ │ ├── FabricNetwork.java │ │ ├── FabricPlayer.java │ │ ├── FabricWorld.java │ │ ├── Pl3xMapFabricServer.java │ │ ├── command │ │ ├── FabricCommandManager.java │ │ ├── FabricParsers.java │ │ └── FabricSender.java │ │ ├── duck │ │ └── AccessServerPlayer.java │ │ └── mixin │ │ └── MixinServerPlayer.java │ └── resources │ ├── assets │ └── pl3xmap │ │ └── lang │ │ └── en_us.json │ ├── fabric.mod.json │ ├── pl3xmap.accesswidener │ ├── pl3xmap.client.mixins.json │ └── pl3xmap.server.mixins.json ├── forge ├── build.gradle └── src │ └── main │ ├── java │ ├── cloud │ │ └── commandframework │ │ │ └── forge │ │ │ ├── CloudForgeEntrypoint.java │ │ │ ├── ContextualArgumentTypeProvider.java │ │ │ ├── ForgeClientCommandManager.java │ │ │ ├── ForgeCommandContextKeys.java │ │ │ ├── ForgeCommandManager.java │ │ │ ├── ForgeCommandPreprocessor.java │ │ │ ├── ForgeCommandRegistrationHandler.java │ │ │ ├── ForgeExecutor.java │ │ │ └── ForgeServerCommandManager.java │ └── net │ │ ├── kyori │ │ └── adventure │ │ │ └── platform │ │ │ └── forge │ │ │ └── ForgeServerAudiences.java │ │ └── pl3x │ │ └── map │ │ └── forge │ │ ├── ForgeNetwork.java │ │ ├── ForgePlayer.java │ │ ├── ForgeWorld.java │ │ ├── Pl3xMapForge.java │ │ ├── capability │ │ └── HiddenCapability.java │ │ └── command │ │ ├── ForgeCommandManager.java │ │ └── ForgeSender.java │ └── resources │ ├── META-INF │ ├── accesstransformer.cfg │ └── mods.toml │ ├── pack.mcmeta │ └── pl3xmap.png ├── gradle.properties ├── gradle ├── libs.versions.toml └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── webmap ├── build.gradle.kts ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── images │ ├── armor.png │ ├── clear.png │ ├── dry_foliage.png │ ├── foliage.png │ ├── grass.png │ ├── health.png │ ├── icon │ │ ├── flowermap.png │ │ ├── inhabited.png │ │ ├── marker-icon.png │ │ ├── marker-shadow.png │ │ ├── nether_basic.png │ │ ├── nether_biomes.png │ │ ├── nether_night.png │ │ ├── nether_roof.png │ │ ├── overworld_basic.png │ │ ├── overworld_biomes.png │ │ ├── overworld_night.png │ │ ├── players.png │ │ ├── spawn.png │ │ ├── the_end_basic.png │ │ ├── the_end_biomes.png │ │ ├── the_end_night.png │ │ └── vanilla.png │ ├── og.png │ ├── skins │ │ └── steve.png │ └── sky │ │ ├── nether.png │ │ ├── overworld.png │ │ └── the_end.png ├── index.html ├── lang │ ├── en_pt.json │ ├── en_us.json │ ├── ja_jp.json │ ├── pl_pl.json │ └── zh_cn.json ├── leaflet.css ├── leaflet.js ├── leaflet.js.map └── modern-normalize.css ├── src ├── Pl3xMap.ts ├── control │ ├── BlockInfoControl.ts │ ├── ControlBox.ts │ ├── ControlManager.ts │ ├── CoordsControl.ts │ ├── LinkControl.ts │ └── SidebarControl.ts ├── index.d.ts ├── layergroup │ └── MarkerLayer.ts ├── lib │ ├── L.ellipse.js │ └── L.rotated.js ├── map │ └── Pl3xMapLeafletMap.ts ├── marker │ ├── Circle.ts │ ├── Ellipse.ts │ ├── Icon.ts │ ├── Marker.ts │ ├── MultiPolygon.ts │ ├── MultiPolyline.ts │ ├── Polygon.ts │ ├── Polyline.ts │ ├── Rectangle.ts │ └── options │ │ ├── Fill.ts │ │ ├── MarkerOptions.ts │ │ ├── Popup.ts │ │ ├── Stroke.ts │ │ └── Tooltip.ts ├── palette │ ├── Block.ts │ ├── BlockInfo.ts │ └── Palette.ts ├── player │ ├── Player.ts │ └── PlayerManager.ts ├── scss │ ├── _leaflet.scss │ ├── _mixins.scss │ ├── _placeholders.scss │ ├── _sidebar.scss │ └── styles.scss ├── settings │ ├── Lang.ts │ ├── Settings.ts │ └── WorldSettings.ts ├── sidebar │ ├── BaseTab.ts │ ├── LayersTab.ts │ ├── MarkersTab.ts │ ├── PlayersTab.ts │ └── WorldsTab.ts ├── svg │ ├── layers.svg │ ├── link.svg │ ├── maps.svg │ ├── marker_point.svg │ └── players.svg ├── tilelayer │ ├── DoubleTileLayer.ts │ └── ReversedZoomTileLayer.ts ├── util │ ├── Color.ts │ ├── Point.ts │ ├── Polygon.ts │ ├── Polyline.ts │ └── Util.ts └── world │ ├── World.ts │ └── WorldManager.ts ├── tsconfig.json └── webpack.config.js /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: granny 2 | ko_fi: jlyne 3 | custom: ["https://ko-fi.com/billygalbreath"] 4 | -------------------------------------------------------------------------------- /.github/workflows/pullrequest.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [ pull_request ] 3 | 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | if: "!contains(github.event.commits[0].message, '[ci-skip]')" 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-java@v2 11 | with: 12 | distribution: temurin 13 | java-version: 21 14 | - uses: actions/setup-node@v3 15 | with: 16 | node-version: 16 17 | - name: Build 18 | run: ./gradlew build --stacktrace 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | 11 | # Eclipse 12 | .classpath 13 | .project 14 | .settings/ 15 | common/bin/ 16 | paper/bin/ 17 | 18 | # Compiled class file 19 | *.class 20 | 21 | # Log file 22 | *.log 23 | 24 | # BlueJ files 25 | *.ctxt 26 | 27 | # Package Files # 28 | *.war 29 | *.nar 30 | *.ear 31 | *.zip 32 | *.tar.gz 33 | *.rar 34 | 35 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 36 | hs_err_pid* 37 | 38 | *~ 39 | 40 | # temporary files which can be created if a process still has a handle open of a deleted file 41 | .fuse_hidden* 42 | 43 | # KDE directory preferences 44 | .directory 45 | 46 | # Linux trash folder which might appear on any partition or disk 47 | .Trash-* 48 | 49 | # .nfs files are created when an open file is removed but is still being accessed 50 | .nfs* 51 | 52 | # General 53 | .DS_Store 54 | .AppleDouble 55 | .LSOverride 56 | 57 | # Icon must end with two \r 58 | Icon 59 | 60 | # Thumbnails 61 | ._* 62 | 63 | # Files that might appear in the root of a volume 64 | .DocumentRevisions-V100 65 | .fseventsd 66 | .Spotlight-V100 67 | .TemporaryItems 68 | .Trashes 69 | .VolumeIcon.icns 70 | .com.apple.timemachine.donotpresent 71 | 72 | # Directories potentially created on remote AFP share 73 | .AppleDB 74 | .AppleDesktop 75 | Network Trash Folder 76 | Temporary Items 77 | .apdisk 78 | 79 | # Windows thumbnail cache files 80 | Thumbs.db 81 | Thumbs.db:encryptable 82 | ehthumbs.db 83 | ehthumbs_vista.db 84 | 85 | # Dump file 86 | *.stackdump 87 | 88 | # Folder config file 89 | [Dd]esktop.ini 90 | 91 | # Recycle Bin used on file shares 92 | $RECYCLE.BIN/ 93 | 94 | # Windows Installer files 95 | *.cab 96 | *.msi 97 | *.msix 98 | *.msm 99 | *.msp 100 | 101 | # Windows shortcuts 102 | *.lnk 103 | 104 | target/ 105 | 106 | pom.xml.tag 107 | pom.xml.releaseBackup 108 | pom.xml.versionsBackup 109 | pom.xml.next 110 | 111 | release.properties 112 | dependency-reduced-pom.xml 113 | buildNumber.properties 114 | .mvn/timing.properties 115 | .mvn/wrapper/maven-wrapper.jar 116 | .flattened-pom.xml 117 | 118 | # Common working directory 119 | run/ 120 | bin 121 | build 122 | .gradle 123 | /*.jar 124 | 125 | # webmap crap 126 | /webmap/node_modules/ 127 | /webmap/dist/ 128 | /webmap/public/images/icon/registered 129 | /webmap/public/images/skins/2D 130 | /webmap/public/images/skins/3D 131 | /webmap/public/tiles 132 | /core/src/main/resources/web/ 133 | -------------------------------------------------------------------------------- /.tokeignore: -------------------------------------------------------------------------------- 1 | # do not count these lines 2 | .github/ 3 | .editorconfig 4 | .gitattributes 5 | .gitignore 6 | .tokeignore 7 | LICENSE 8 | gradle/ 9 | *.gradle* 10 | *.json 11 | *.accesswidener 12 | *.yml 13 | *.config.js 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020-2023 William Blake Galbreath 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | 3 | ## General 4 | 5 | - [x] move versions to `gradle/libs.versions.toml` 6 | - [ ] Share logic in [`buildSrc`](https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html#sec:using_buildsrc) 7 | 8 | ## Individual project jars 9 | 10 | - [ ] bukkit: should dev jar include missing core dependency? 11 | - [ ] fabric: devlibs jar is missing core dependency 12 | 13 | ## uber-jar shenanigans 14 | - [x] fix missing `jars/` directory in `META-INF` 15 | - [x] fix incorrect `MANIFEST.MF` 16 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | alias(libs.plugins.minotaur) 4 | } 5 | 6 | val buildNum = System.getenv("NEXT_BUILD_NUMBER") ?: "SNAPSHOT" 7 | project.version = "${libs.versions.minecraft.get()}-$buildNum" 8 | 9 | tasks { 10 | jar { 11 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 12 | 13 | subprojects { 14 | dependsOn(project.tasks.build) 15 | } 16 | 17 | archiveClassifier = "" 18 | 19 | // this is janky, but it works 20 | val manifestFiles = subprojects.filter({ it.name != "webmap" && it.name != "core" }).map { 21 | val regularFile = it.layout.buildDirectory.file("libs/${project.name}-${it.name}-${it.version}.jar") 22 | if (regularFile.isPresent) { 23 | zipTree(regularFile) 24 | } else { 25 | null 26 | } 27 | }.filterNotNull() 28 | 29 | from(manifestFiles) { 30 | exclude("META-INF/MANIFEST.MF") 31 | } 32 | 33 | // this is janky, but it works 34 | doFirst { 35 | manifestFiles.forEach { 36 | it.matching { include("META-INF/MANIFEST.MF") }.files.forEach { 37 | manifest.from(it) 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | modrinth { 45 | autoAddDependsOn = false 46 | token = System.getenv("MODRINTH_TOKEN") 47 | projectId = "pl3xmap" 48 | versionName = "${project.version}" 49 | versionNumber = "${project.version}" 50 | versionType = "beta" 51 | uploadFile = rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}.jar").get() 52 | //additionalFiles.addAll([ 53 | // rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}-javadoc.jar").get(), 54 | // rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}-sources.jar").get() 55 | //]) 56 | gameVersions.addAll(listOf(libs.versions.minecraft.get())) 57 | loaders.addAll(listOf("bukkit", "fabric", /*"forge",*/ "paper", "purpur", "quilt", "spigot", "folia")) 58 | changelog = System.getenv("COMMIT_MESSAGE") 59 | dependencies { 60 | required.project("fabric-api") 61 | //optional.project( 62 | // "pl3xmap-banners", 63 | // "pl3xmap-claims", 64 | // "pl3xmap-mobs", 65 | // "pl3xmap-signs", 66 | // "pl3xmap-warps", 67 | // "deathspots", 68 | //) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /buildSrc/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | versionCatalogs { 3 | create("libs") { 4 | from(files("../gradle/libs.versions.toml")) 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /bukkit/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | alias(libs.plugins.paperweight.userdev) 4 | alias(libs.plugins.shadow) 5 | alias(libs.plugins.run.paper) 6 | } 7 | 8 | val buildNum = System.getenv("NEXT_BUILD_NUMBER") ?: "SNAPSHOT" 9 | project.version = "${libs.versions.minecraft.get()}-$buildNum" 10 | project.group = "net.pl3x.map.bukkit" 11 | 12 | base { 13 | archivesName = "${rootProject.name}-${project.name}" 14 | } 15 | 16 | repositories { 17 | maven("https://oss.sonatype.org/content/repositories/snapshots/") { 18 | name = "oss-sonatype-snapshots" 19 | mavenContent { 20 | snapshotsOnly() 21 | } 22 | } 23 | maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") { 24 | name = "s01-sonatype-snapshots" 25 | mavenContent { 26 | snapshotsOnly() 27 | } 28 | } 29 | mavenCentral() 30 | maven("https://jitpack.io") 31 | } 32 | 33 | dependencies { 34 | implementation(project(":core", configuration = "shadow")) 35 | 36 | implementation(libs.cloudBrigadier) 37 | implementation(libs.cloudPaper) 38 | 39 | implementation(libs.adventurePlatformBukkit) 40 | 41 | paperweight.paperDevBundle(libs.versions.bukkit) 42 | } 43 | 44 | tasks { 45 | reobfJar { 46 | dependsOn(jar) 47 | outputJar.set(jar.get().archiveFile) 48 | } 49 | 50 | // needed for below jank 51 | compileJava { 52 | dependsOn(":core:jar") 53 | } 54 | 55 | shadowJar { 56 | mergeServiceFiles() 57 | 58 | // this is janky, but it works 59 | manifest { 60 | from(project(":core").tasks.named("shadowJar").get().manifest) 61 | } 62 | } 63 | 64 | build { 65 | dependsOn(reobfJar) 66 | } 67 | 68 | runServer { 69 | minecraftVersion(libs.versions.minecraft.get()) 70 | } 71 | 72 | processResources { 73 | inputs.properties(mapOf( 74 | "name" to rootProject.name, 75 | "group" to project.group, 76 | "version" to project.version, 77 | "authors" to project.properties["authors"], 78 | "description" to project.properties["description"], 79 | "website" to project.properties["website"] 80 | )) 81 | 82 | filesMatching("plugin.yml") { 83 | expand(inputs.properties) 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/command/BukkitParsers.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.command; 2 | 3 | import net.minecraft.world.phys.Vec3; 4 | import net.pl3x.map.bukkit.BukkitPlayer; 5 | import net.pl3x.map.core.Pl3xMap; 6 | import net.pl3x.map.core.command.Sender; 7 | import net.pl3x.map.core.command.parser.PlatformParsers; 8 | import net.pl3x.map.core.markers.Point; 9 | import net.pl3x.map.core.player.Player; 10 | import org.incendo.cloud.bukkit.data.SinglePlayerSelector; 11 | import org.incendo.cloud.bukkit.parser.location.Location2D; 12 | import org.incendo.cloud.bukkit.parser.location.Location2DParser; 13 | import org.incendo.cloud.bukkit.parser.selector.SinglePlayerSelectorParser; 14 | import org.incendo.cloud.context.CommandContext; 15 | import org.incendo.cloud.parser.ParserDescriptor; 16 | import org.jspecify.annotations.NullMarked; 17 | import org.jspecify.annotations.Nullable; 18 | 19 | @NullMarked 20 | public class BukkitParsers implements PlatformParsers { 21 | @Override 22 | public ParserDescriptor columnPosParser() { 23 | return Location2DParser.location2DParser(); 24 | } 25 | 26 | @Override 27 | public Point resolvePointFromColumnPos(String name, CommandContext context) { 28 | Location2D location2D = context.getOrDefault(name, null); 29 | if (location2D == null) { 30 | return Point.ZERO; 31 | } 32 | return Point.of(location2D.blockX(), location2D.blockZ()); 33 | } 34 | 35 | @Override 36 | public ParserDescriptor playerSelectorParser() { 37 | return SinglePlayerSelectorParser.singlePlayerSelectorParser(); 38 | } 39 | 40 | @Override 41 | public @Nullable Player resolvePlayerFromPlayerSelector(String name, CommandContext context) { 42 | Sender sender = context.sender(); 43 | SinglePlayerSelector playerSelector = context.getOrDefault(name, null); 44 | if (playerSelector == null) { 45 | if (sender instanceof Sender.Player senderPlayer) { 46 | Player player = Pl3xMap.api().getPlayerRegistry().get(senderPlayer.getUUID()); 47 | if (player != null) { 48 | return player; 49 | } 50 | } 51 | return null; 52 | } 53 | return new BukkitPlayer(playerSelector.single()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/network/ClientboundMapPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ClientboundMapPayload(int protocol, int response, int mapId, byte scale, int centerX, int centerZ, String worldName) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ClientboundMapPayload::write, ClientboundMapPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "client_map_data")); 14 | 15 | public ClientboundMapPayload(int protocol, int response, int mapId) { 16 | this(protocol, response, mapId, (byte) 0, 0, 0, null); 17 | } 18 | 19 | public ClientboundMapPayload(FriendlyByteBuf friendlyByteBuf) { 20 | this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readByte(), friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readUtf()); 21 | } 22 | 23 | private void write(FriendlyByteBuf friendlyByteBuf) { 24 | friendlyByteBuf.writeInt(protocol); 25 | friendlyByteBuf.writeInt(response); 26 | friendlyByteBuf.writeInt(mapId); 27 | friendlyByteBuf.writeByte(scale); 28 | friendlyByteBuf.writeInt(centerX); 29 | friendlyByteBuf.writeInt(centerZ); 30 | friendlyByteBuf.writeUtf(worldName); 31 | } 32 | 33 | @Override 34 | public Type type() { 35 | return TYPE; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/network/ClientboundServerPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ClientboundServerPayload(int protocol, int response, String webAddress) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ClientboundServerPayload::write, ClientboundServerPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "client_server_data")); 14 | 15 | public ClientboundServerPayload(int protocol, int response) { 16 | this(protocol, response, null); 17 | } 18 | 19 | public ClientboundServerPayload(FriendlyByteBuf friendlyByteBuf) { 20 | this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readUtf()); 21 | } 22 | 23 | private void write(FriendlyByteBuf friendlyByteBuf) { 24 | friendlyByteBuf.writeInt(protocol); 25 | friendlyByteBuf.writeInt(response); 26 | friendlyByteBuf.writeUtf(webAddress); 27 | } 28 | 29 | @Override 30 | public Type type() { 31 | return TYPE; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/network/ServerboundMapPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ServerboundMapPayload(int protocol, int mapId) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ServerboundMapPayload::write, ServerboundMapPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "server_map_data")); 14 | 15 | public ServerboundMapPayload(int mapId) { 16 | this(Constants.PROTOCOL, mapId); 17 | } 18 | 19 | public ServerboundMapPayload(FriendlyByteBuf friendlyByteBuf) { 20 | this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt()); 21 | } 22 | 23 | private void write(FriendlyByteBuf friendlyByteBuf) { 24 | friendlyByteBuf.writeInt(protocol); 25 | friendlyByteBuf.writeInt(mapId); 26 | } 27 | 28 | @Override 29 | public Type type() { 30 | return TYPE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/network/ServerboundServerPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ServerboundServerPayload(int protocol) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ServerboundServerPayload::write, ServerboundServerPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "server_server_data")); 14 | 15 | public ServerboundServerPayload(FriendlyByteBuf friendlyByteBuf) { 16 | this(friendlyByteBuf.readInt()); 17 | } 18 | 19 | private void write(FriendlyByteBuf friendlyByteBuf) { 20 | friendlyByteBuf.writeInt(protocol); 21 | } 22 | 23 | @Override 24 | public Type type() { 25 | return TYPE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bukkit/src/main/java/net/pl3x/map/bukkit/util/SchedulerUtil.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.bukkit.util; 2 | 3 | import net.pl3x.map.core.scheduler.Scheduler; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.plugin.Plugin; 6 | import org.bukkit.scheduler.BukkitScheduler; 7 | import org.jspecify.annotations.NullMarked; 8 | 9 | @NullMarked 10 | public class SchedulerUtil { 11 | private static boolean IS_FOLIA = false; 12 | 13 | static { 14 | try { 15 | Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); 16 | IS_FOLIA = true; 17 | } catch (ClassNotFoundException ignored) { 18 | } 19 | } 20 | 21 | public static void runTaskTimer(Plugin plugin, Scheduler scheduler, BukkitScheduler bukkitScheduler) { 22 | if (IS_FOLIA) { 23 | Bukkit.getGlobalRegionScheduler().runAtFixedRate(plugin, timerTask -> 24 | scheduler.tick(), 20, 1); 25 | } else { 26 | bukkitScheduler.runTaskTimer(plugin, () -> 27 | scheduler.tick(), 20, 1); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/Keyed.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core; 25 | 26 | import java.util.Objects; 27 | import net.pl3x.map.core.util.Preconditions; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Represents a key identified object. 33 | */ 34 | @NullMarked 35 | public abstract class Keyed { 36 | private final String key; 37 | 38 | /** 39 | * Create a new key identified object. 40 | * 41 | * @param key key for object 42 | */ 43 | public Keyed(String key) { 44 | this.key = Preconditions.checkNotNull(key, "Key is null"); 45 | } 46 | 47 | /** 48 | * Get the identifying key. 49 | * 50 | * @return the key 51 | */ 52 | public String getKey() { 53 | return this.key; 54 | } 55 | 56 | @Override 57 | public boolean equals(@Nullable Object o) { 58 | if (this == o) { 59 | return true; 60 | } 61 | if (o == null) { 62 | return false; 63 | } 64 | if (this.getClass() != o.getClass()) { 65 | return false; 66 | } 67 | Keyed other = (Keyed) o; 68 | return getKey().equals(other.getKey()); 69 | } 70 | 71 | @Override 72 | public int hashCode() { 73 | return Objects.hash(getKey()); 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return this.key; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/Pl3xMapCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command; 25 | 26 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; 27 | import net.pl3x.map.core.configuration.Lang; 28 | import org.incendo.cloud.minecraft.extras.RichDescription; 29 | import org.jspecify.annotations.NullMarked; 30 | 31 | /** 32 | * Represents a Pl3xMap command. 33 | */ 34 | @NullMarked 35 | public abstract class Pl3xMapCommand { 36 | private final CommandHandler handler; 37 | 38 | protected Pl3xMapCommand(CommandHandler handler) { 39 | this.handler = handler; 40 | } 41 | 42 | /** 43 | * Get the command handler. 44 | * 45 | * @return command handler 46 | */ 47 | public CommandHandler getHandler() { 48 | return this.handler; 49 | } 50 | 51 | /** 52 | * Register subcommand. 53 | */ 54 | public abstract void register(); 55 | 56 | /** 57 | * Create a command description. 58 | * 59 | * @param description description of command 60 | * @param placeholders placeholders 61 | * @return rich description 62 | */ 63 | protected static RichDescription description(String description, TagResolver.Single... placeholders) { 64 | return RichDescription.of(Lang.parse(description, placeholders)); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/commands/ReloadCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.commands; 25 | 26 | import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; 27 | import net.pl3x.map.core.Pl3xMap; 28 | import net.pl3x.map.core.command.CommandHandler; 29 | import net.pl3x.map.core.command.Pl3xMapCommand; 30 | import net.pl3x.map.core.command.Sender; 31 | import net.pl3x.map.core.configuration.Lang; 32 | import org.incendo.cloud.context.CommandContext; 33 | import org.incendo.cloud.minecraft.extras.RichDescription; 34 | import org.jspecify.annotations.NullMarked; 35 | 36 | @NullMarked 37 | public class ReloadCommand extends Pl3xMapCommand { 38 | public ReloadCommand(CommandHandler handler) { 39 | super(handler); 40 | } 41 | 42 | @Override 43 | public void register() { 44 | getHandler().registerSubcommand(builder -> builder.literal("reload") 45 | .commandDescription(RichDescription.of(Lang.parse(Lang.COMMAND_RELOAD_DESCRIPTION))) 46 | .permission("pl3xmap.command.reload") 47 | .handler(this::execute)); 48 | } 49 | 50 | public void execute(CommandContext context) { 51 | Pl3xMap.api().disable(); 52 | 53 | Pl3xMap.api().enable(); 54 | 55 | context.sender().sendMessage(Lang.COMMAND_RELOAD_SUCCESS, 56 | Placeholder.unparsed("version", Pl3xMap.api().getVersion())); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/exception/PlayerParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.exception; 25 | 26 | import net.pl3x.map.core.command.Sender.Player; 27 | import net.pl3x.map.core.configuration.Lang; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Thrown to indicate that a method has been passed an illegal or inappropriate {@link Player} argument. 33 | */ 34 | @NullMarked 35 | public class PlayerParseException extends ArgumentParseException { 36 | public static final Reason MUST_SPECIFY_PLAYER = new Reason(() -> Lang.ERROR_MUST_SPECIFY_PLAYER); 37 | public static final Reason NO_SUCH_PLAYER = new Reason(() -> Lang.ERROR_NO_SUCH_PLAYER); 38 | 39 | /** 40 | * Construct a new PlayerParseException. 41 | * 42 | * @param input Input 43 | * @param reason Failure reason 44 | */ 45 | public PlayerParseException(@Nullable String input, Reason reason) { 46 | super(input, "", reason); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/exception/PointParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.exception; 25 | 26 | import net.pl3x.map.core.configuration.Lang; 27 | import net.pl3x.map.core.markers.Point; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Thrown to indicate that a method has been passed an illegal or inappropriate {@link Point} argument. 33 | */ 34 | @NullMarked 35 | public class PointParseException extends ArgumentParseException { 36 | public static final Reason INVALID_FORMAT = new Reason(() -> Lang.ERROR_POINT_INVALID_FORMAT); 37 | 38 | /** 39 | * Construct a new PointParseException. 40 | * 41 | * @param input Input 42 | * @param reason Failure reason 43 | */ 44 | public PointParseException(@Nullable String input, Reason reason) { 45 | super(input, "", reason); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/exception/RendererParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.exception; 25 | 26 | import net.pl3x.map.core.configuration.Lang; 27 | import net.pl3x.map.core.renderer.Renderer; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Thrown to indicate that a method has been passed an illegal or inappropriate {@link Renderer.Builder} argument. 33 | */ 34 | @NullMarked 35 | public class RendererParseException extends ArgumentParseException { 36 | public static final Reason MUST_SPECIFY_RENDERER = new Reason(() -> Lang.ERROR_MUST_SPECIFY_RENDERER); 37 | public static final Reason NO_SUCH_RENDERER = new Reason(() -> Lang.ERROR_NO_SUCH_RENDERER); 38 | 39 | /** 40 | * Construct a new RendererParseException. 41 | * 42 | * @param input Input 43 | * @param reason Failure reason 44 | */ 45 | public RendererParseException(@Nullable String input, Reason reason) { 46 | super(input, "", reason); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/exception/WorldParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.exception; 25 | 26 | import net.pl3x.map.core.configuration.Lang; 27 | import net.pl3x.map.core.world.World; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Thrown to indicate that a method has been passed an illegal or inappropriate {@link World} argument. 33 | */ 34 | @NullMarked 35 | public class WorldParseException extends ArgumentParseException { 36 | public static final Reason MUST_SPECIFY_WORLD = new Reason(() -> Lang.ERROR_MUST_SPECIFY_WORLD); 37 | public static final Reason NO_SUCH_WORLD = new Reason(() -> Lang.ERROR_NO_SUCH_WORLD); 38 | public static final Reason MAP_NOT_ENABLED = new Reason(() -> Lang.ERROR_WORLD_DISABLED); 39 | 40 | /** 41 | * Construct a new WorldParseException. 42 | * 43 | * @param input Input 44 | * @param reason Failure reason 45 | */ 46 | public WorldParseException(@Nullable String input, Reason reason) { 47 | super(input, "", reason); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/exception/ZoomParseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.command.exception; 25 | 26 | import net.pl3x.map.core.configuration.Lang; 27 | import net.pl3x.map.core.renderer.Renderer; 28 | import org.jspecify.annotations.NullMarked; 29 | import org.jspecify.annotations.Nullable; 30 | 31 | /** 32 | * Thrown to indicate that a method has been passed an illegal or inappropriate {@link Renderer.Builder} argument. 33 | */ 34 | @NullMarked 35 | public class ZoomParseException extends ArgumentParseException { 36 | public static final Reason NOT_VALID_ZOOM_LEVEL = new Reason(() -> Lang.ERROR_NOT_VALID_ZOOM_LEVEL); 37 | 38 | /** 39 | * Construct a new RendererParseException. 40 | * 41 | * @param input Input 42 | * @param reason Failure reason 43 | */ 44 | public ZoomParseException(@Nullable String input, Reason reason) { 45 | super(input, "", reason); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/command/parser/PlatformParsers.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.core.command.parser; 2 | 3 | import net.pl3x.map.core.command.Sender; 4 | import net.pl3x.map.core.markers.Point; 5 | import net.pl3x.map.core.player.Player; 6 | import org.incendo.cloud.context.CommandContext; 7 | import org.incendo.cloud.parser.ParserDescriptor; 8 | import org.jspecify.annotations.NullMarked; 9 | import org.jspecify.annotations.Nullable; 10 | 11 | @NullMarked 12 | public interface PlatformParsers { 13 | ParserDescriptor columnPosParser(); 14 | 15 | Point resolvePointFromColumnPos(String name, CommandContext context); 16 | 17 | ParserDescriptor playerSelectorParser(); 18 | 19 | @Nullable Player resolvePlayerFromPlayerSelector(String name, CommandContext context); 20 | } 21 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/Event.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event; 25 | 26 | import java.util.List; 27 | import net.pl3x.map.core.Pl3xMap; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public abstract class Event { 32 | public void callEvent() { 33 | Pl3xMap.api().getEventRegistry().callEvent(this); 34 | } 35 | 36 | public abstract List getHandlers(); 37 | } 38 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/EventHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event; 25 | 26 | import java.lang.annotation.ElementType; 27 | import java.lang.annotation.Retention; 28 | import java.lang.annotation.RetentionPolicy; 29 | import java.lang.annotation.Target; 30 | 31 | @Target(ElementType.METHOD) 32 | @Retention(RetentionPolicy.RUNTIME) 33 | public @interface EventHandler { 34 | } 35 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/EventListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public interface EventListener { 30 | } 31 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/server/Pl3xMapDisabledEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.server; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import net.pl3x.map.core.event.Event; 29 | import net.pl3x.map.core.event.RegisteredHandler; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public class Pl3xMapDisabledEvent extends Event { 34 | private static final List handlers = new ArrayList<>(); 35 | 36 | @Override 37 | public List getHandlers() { 38 | return handlers; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/server/Pl3xMapEnabledEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.server; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import net.pl3x.map.core.event.Event; 29 | import net.pl3x.map.core.event.RegisteredHandler; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public class Pl3xMapEnabledEvent extends Event { 34 | private static final List handlers = new ArrayList<>(); 35 | 36 | @Override 37 | public List getHandlers() { 38 | return handlers; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/server/ServerLoadedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.server; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import net.pl3x.map.core.event.Event; 29 | import net.pl3x.map.core.event.RegisteredHandler; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public class ServerLoadedEvent extends Event { 34 | private static final List handlers = new ArrayList<>(); 35 | 36 | @Override 37 | public List getHandlers() { 38 | return handlers; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/world/WorldEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.world; 25 | 26 | import net.pl3x.map.core.event.Event; 27 | import net.pl3x.map.core.world.World; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public abstract class WorldEvent extends Event { 32 | private final World world; 33 | 34 | public WorldEvent(World world) { 35 | this.world = world; 36 | } 37 | 38 | public World getWorld() { 39 | return this.world; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/world/WorldLoadedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.world; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import net.pl3x.map.core.event.RegisteredHandler; 29 | import net.pl3x.map.core.world.World; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public class WorldLoadedEvent extends WorldEvent { 34 | private static final List handlers = new ArrayList<>(); 35 | 36 | public WorldLoadedEvent(World world) { 37 | super(world); 38 | } 39 | 40 | public List getHandlers() { 41 | return handlers; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/event/world/WorldUnloadedEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.event.world; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import net.pl3x.map.core.event.RegisteredHandler; 29 | import net.pl3x.map.core.world.World; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public class WorldUnloadedEvent extends WorldEvent { 34 | private static final List handlers = new ArrayList<>(); 35 | 36 | public WorldUnloadedEvent(World world) { 37 | super(world); 38 | } 39 | 40 | public List getHandlers() { 41 | return handlers; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/image/io/Bmp.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.image.io; 25 | 26 | import java.awt.image.BufferedImage; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class Bmp extends IO.Type { 31 | public Bmp() { 32 | super("bmp"); 33 | } 34 | 35 | @Override 36 | public BufferedImage createBuffer() { 37 | return new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB); 38 | } 39 | 40 | @Override 41 | public int color(int argb) { 42 | return argb & 0xFFFFFF; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/image/io/Gif.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.image.io; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public class Gif extends IO.Type { 30 | public Gif() { 31 | super("gif"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/image/io/Jpg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.image.io; 25 | 26 | import java.awt.image.BufferedImage; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class Jpg extends IO.Type { 31 | public Jpg() { 32 | super("jpg"); 33 | } 34 | 35 | @Override 36 | public BufferedImage createBuffer() { 37 | return new BufferedImage(512, 512, BufferedImage.TYPE_INT_RGB); 38 | } 39 | 40 | @Override 41 | public int color(int argb) { 42 | return argb & 0xFFFFFF; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/image/io/Png.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.image.io; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public class Png extends IO.Type { 30 | public Png() { 31 | super("png"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/JsonSerializable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers; 25 | 26 | import com.google.gson.JsonElement; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | /** 30 | * Represents an object that can be serialized into a json element. 31 | */ 32 | @NullMarked 33 | public interface JsonSerializable { 34 | /** 35 | * Jsonify this object. 36 | * 37 | * @return object as json element 38 | */ 39 | JsonElement toJson(); 40 | } 41 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/Point.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers; 25 | 26 | import com.google.gson.JsonObject; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public record Point(int x, int z) implements JsonSerializable { 31 | public static final Point ZERO = new Point(0, 0); 32 | 33 | public static Point of(int x, int z) { 34 | return new Point(x, z); 35 | } 36 | 37 | public static Point of(double x, double z) { 38 | return of((int) Math.floor(x), (int) Math.floor(z)); 39 | } 40 | 41 | @Override 42 | public JsonObject toJson() { 43 | JsonObjectWrapper wrapper = new JsonObjectWrapper(); 44 | wrapper.addProperty("x", x()); 45 | wrapper.addProperty("z", z()); 46 | return wrapper.getJsonObject(); 47 | } 48 | 49 | public static Point fromJson( JsonObject obj) { 50 | return Point.of(obj.get("x").getAsInt(), obj.get("z").getAsInt()); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/Vector.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers; 25 | 26 | import com.google.gson.JsonObject; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public record Vector(double x, double z) implements JsonSerializable { 31 | public static Vector of(int x, int z) { 32 | return new Vector(x, z); 33 | } 34 | 35 | public static Vector of(double x, double z) { 36 | return new Vector(x, z); 37 | } 38 | 39 | @Override 40 | public JsonObject toJson() { 41 | JsonObjectWrapper wrapper = new JsonObjectWrapper(); 42 | wrapper.addProperty("x", x()); 43 | wrapper.addProperty("z", z()); 44 | return wrapper.getJsonObject(); 45 | } 46 | 47 | public static Vector fromJson(JsonObject obj) { 48 | return Vector.of(obj.get("x").getAsDouble(), obj.get("z").getAsDouble()); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/area/Area.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers.area; 25 | 26 | import java.util.Map; 27 | import net.pl3x.map.core.world.World; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public interface Area { 32 | boolean containsBlock(int blockX, int blockZ); 33 | 34 | boolean containsChunk(int chunkX, int chunkZ); 35 | 36 | boolean containsRegion(int regionX, int regionZ); 37 | 38 | Map serialize(); 39 | 40 | static Area deserialize(World world, Map map) { 41 | return switch (String.valueOf(map.get("type"))) { 42 | case "circle" -> Circle.deserialize(map); 43 | case "rectangle" -> Rectangle.deserialize(map); 44 | case "world-border" -> Border.deserialize(world, map); 45 | default -> throw new IllegalArgumentException("Unknown area type"); 46 | }; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/layer/WorldLayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers.layer; 25 | 26 | import java.util.function.Supplier; 27 | import net.pl3x.map.core.markers.option.Options; 28 | import net.pl3x.map.core.world.World; 29 | import org.jspecify.annotations.NullMarked; 30 | import org.jspecify.annotations.Nullable; 31 | 32 | /** 33 | * Represents a layer for worlds. 34 | */ 35 | @SuppressWarnings("UnusedReturnValue") 36 | @NullMarked 37 | public abstract class WorldLayer extends SimpleLayer { 38 | private final World world; 39 | 40 | private Options options; 41 | 42 | /** 43 | * Create a new spawn layer. 44 | * 45 | * @param key key for layer 46 | * @param world world 47 | * @param labelSupplier label 48 | */ 49 | public WorldLayer(String key, World world, Supplier labelSupplier) { 50 | super(key, labelSupplier); 51 | this.world = world; 52 | } 53 | 54 | public World getWorld() { 55 | return this.world; 56 | } 57 | 58 | public @Nullable Options getOptions() { 59 | return this.options; 60 | } 61 | 62 | public WorldLayer setOptions(@Nullable Options options) { 63 | this.options = options; 64 | return this; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/markers/option/Option.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.markers.option; 25 | 26 | import net.pl3x.map.core.markers.JsonSerializable; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | /** 30 | * Represents marker option properties 31 | */ 32 | @SuppressWarnings("unused") 33 | @NullMarked 34 | public abstract class Option> implements JsonSerializable { 35 | /** 36 | * Check whether all options are defaults (all are null) 37 | * 38 | * @return true if all options are null 39 | */ 40 | public abstract boolean isDefault(); 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/network/Constants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.network; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public class Constants { 30 | public static final String MODID = "pl3xmap"; 31 | 32 | public static final int PROTOCOL = 3; 33 | 34 | public static final int SERVER_DATA = 0; 35 | public static final int MAP_DATA = 1; 36 | 37 | public static final int RESPONSE_SUCCESS = 200; 38 | 39 | public static final int ERROR_NO_SUCH_MAP = -1; 40 | public static final int ERROR_NO_SUCH_WORLD = -2; 41 | public static final int ERROR_NOT_VANILLA_MAP = -3; 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/network/Network.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.network; 25 | 26 | import com.google.common.io.ByteArrayDataInput; 27 | import com.google.common.io.ByteArrayDataOutput; 28 | import com.google.common.io.ByteStreams; 29 | import net.pl3x.map.core.configuration.Config; 30 | import org.jspecify.annotations.NullMarked; 31 | 32 | @NullMarked 33 | public abstract class Network { 34 | public static final String CHANNEL = Constants.MODID + ":" + Constants.MODID; 35 | 36 | public abstract void register(); 37 | 38 | public abstract void unregister(); 39 | 40 | protected abstract void sendServerData(T player); 41 | 42 | protected abstract void sendMapData(T player, int id); 43 | 44 | protected abstract void send(T player, ByteArrayDataOutput out); 45 | 46 | @SuppressWarnings("UnstableApiUsage") 47 | protected ByteArrayDataOutput out() { 48 | return ByteStreams.newDataOutput(); 49 | } 50 | 51 | @SuppressWarnings("UnstableApiUsage") 52 | protected ByteArrayDataInput in(byte[] bytes) { 53 | return ByteStreams.newDataInput(bytes); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/player/PlayerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.player; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | /** 29 | * Player event listener. 30 | */ 31 | @NullMarked 32 | public class PlayerListener { 33 | /** 34 | * Fired when a player joins the server. 35 | * 36 | * @param player player that joined 37 | */ 38 | public void onJoin(Player player) { 39 | if (player.isHidden()) { 40 | player.setHidden(true, false); 41 | } 42 | new PlayerTexture(player).start(); 43 | } 44 | 45 | /** 46 | * Fired when a player leaves the server. 47 | * 48 | * @param player player that left 49 | */ 50 | public void onQuit(Player player) { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/registry/WorldRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.registry; 25 | 26 | import java.util.function.Supplier; 27 | import net.pl3x.map.core.Pl3xMap; 28 | import net.pl3x.map.core.event.world.WorldUnloadedEvent; 29 | import net.pl3x.map.core.world.World; 30 | import org.jspecify.annotations.NullMarked; 31 | import org.jspecify.annotations.Nullable; 32 | 33 | @NullMarked 34 | public class WorldRegistry extends Registry { 35 | public World getOrDefault(String id, Supplier supplier) { 36 | World world = get(id); 37 | if (world == null) { 38 | world = supplier.get(); 39 | register(world.getName(), world); 40 | } 41 | return world; 42 | } 43 | 44 | @Override 45 | public @Nullable World unregister(String id) { 46 | World world = this.entries.remove(id); 47 | if (world != null) { 48 | Pl3xMap.api().getEventRegistry().callEvent(new WorldUnloadedEvent(world)); 49 | world.getMarkerTask().cancel(); 50 | world.getLiveDataTask().cancel(); 51 | //world.getRegionFileWatcher().stop(); 52 | world.cleanup(); 53 | } 54 | return world; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/BasicRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer; 25 | 26 | import net.pl3x.map.core.renderer.task.RegionScanTask; 27 | import net.pl3x.map.core.world.Chunk; 28 | import net.pl3x.map.core.world.Region; 29 | import org.jspecify.annotations.NullMarked; 30 | 31 | @NullMarked 32 | public final class BasicRenderer extends Renderer { 33 | public BasicRenderer(RegionScanTask task, Builder builder) { 34 | super(task, builder); 35 | } 36 | 37 | @Override 38 | public void scanBlock(Region region, Chunk chunk, Chunk.BlockData data, int blockX, int blockZ) { 39 | int pixelColor = basicPixelColor(region, data, blockX, blockZ); 40 | getTileImage().setPixel(blockX, blockZ, pixelColor); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/BiomeRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer; 25 | 26 | import net.pl3x.map.core.configuration.ColorsConfig; 27 | import net.pl3x.map.core.renderer.task.RegionScanTask; 28 | import net.pl3x.map.core.util.Colors; 29 | import net.pl3x.map.core.world.Biome; 30 | import net.pl3x.map.core.world.Chunk; 31 | import net.pl3x.map.core.world.Region; 32 | import org.jspecify.annotations.NullMarked; 33 | 34 | @NullMarked 35 | public final class BiomeRenderer extends Renderer { 36 | public BiomeRenderer(RegionScanTask task, Builder builder) { 37 | super(task, builder); 38 | } 39 | 40 | @Override 41 | public void scanBlock(Region region, Chunk chunk, Chunk.BlockData data, int blockX, int blockZ) { 42 | int pixelColor = 0; 43 | 44 | if (data.getBlockState().getBlock().color() > 0) { 45 | // determine the biome 46 | Biome biome = data.getBiome(region, blockX, blockZ); 47 | int color = ColorsConfig.BIOME_COLORS.getOrDefault(biome.getKey(), 0); 48 | pixelColor = Colors.setAlpha(0xFF, color); 49 | 50 | // work out the heightmap 51 | if (data.getFluidState() == null) { 52 | pixelColor = Colors.blend(getHeightmap().getColor(region, blockX, blockZ), pixelColor); 53 | } 54 | } 55 | 56 | getTileImage().setPixel(blockX, blockZ, pixelColor); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/EvenOddHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class EvenOddHeightmap extends Heightmap { 32 | public EvenOddHeightmap() { 33 | super("even_odd"); 34 | } 35 | 36 | @Override 37 | public int getColor(Region region, int blockX, int blockZ) { 38 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 39 | int heightColor = 0x22; 40 | if (origin != null && origin.getBlockY() % 2 == 1) { 41 | heightColor = 0x33; 42 | } 43 | return heightColor << 24; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/EvenOddOldSchoolHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class EvenOddOldSchoolHeightmap extends Heightmap { 32 | public EvenOddOldSchoolHeightmap() { 33 | super("even_odd_old_school"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData west = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 41 | int heightColor = 0x22; 42 | if (origin != null) { 43 | int y = origin.getBlockY(); 44 | if (west != null) { 45 | heightColor = getColor(y, west.getBlockY(), heightColor, 0x22); 46 | } 47 | if (y % 2 == 1) { 48 | heightColor += 0x11; 49 | } 50 | } 51 | return heightColor << 24; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/EvenOddVanillaHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class EvenOddVanillaHeightmap extends Heightmap { 32 | public EvenOddVanillaHeightmap() { 33 | super("even_odd_vanilla"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData north = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 41 | int heightColor = 0x22; 42 | if (origin != null) { 43 | int y = origin.getBlockY(); 44 | if (north != null) { 45 | heightColor = getColor(y, north.getBlockY(), heightColor, 0x22); 46 | } 47 | if (y % 2 == 1) { 48 | heightColor += 0x11; 49 | } 50 | } 51 | return heightColor << 24; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/HeightmapRegistry.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.registry.Registry; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class HeightmapRegistry extends Registry { 31 | public void register() { 32 | register(new EvenOddHeightmap()); 33 | register(new EvenOddHighContrastHeightmap()); 34 | register(new EvenOddLowContrastHeightmap()); 35 | register(new EvenOddModernHeightmap()); 36 | register(new EvenOddOldSchoolHeightmap()); 37 | register(new EvenOddVanillaHeightmap()); 38 | register(new HighContrastHeightmap()); 39 | register(new LowContrastHeightmap()); 40 | register(new ModernHeightmap()); 41 | register(new NoneHeightmap()); 42 | register(new OldSchoolHeightmap()); 43 | register(new VanillaHeightmap()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/HighContrastHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class HighContrastHeightmap extends Heightmap { 32 | public HighContrastHeightmap() { 33 | super("high_contrast"); 34 | } 35 | 36 | public int getMax() { 37 | return 0x66; 38 | } 39 | 40 | @Override 41 | @SuppressWarnings("DuplicatedCode") 42 | public int getColor(Region region, int blockX, int blockZ) { 43 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 44 | Chunk.BlockData west = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 45 | Chunk.BlockData north = region.getWorld().getChunk(region, blockX >> 4, (blockZ - 1) >> 4).getData(blockX, blockZ - 1); 46 | int heightColor = 0x33; 47 | if (origin != null) { 48 | int y = origin.getBlockY(); 49 | if (west != null) { 50 | heightColor = getColor(y, west.getBlockY(), heightColor, 0x44); 51 | } 52 | if (north != null) { 53 | heightColor = getColor(y, north.getBlockY(), heightColor, 0x44); 54 | } 55 | } 56 | return heightColor << 24; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/LowContrastHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class LowContrastHeightmap extends Heightmap { 32 | public LowContrastHeightmap() { 33 | super("low_contrast"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData west = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 41 | Chunk.BlockData north = region.getWorld().getChunk(region, blockX >> 4, (blockZ - 1) >> 4).getData(blockX, blockZ - 1); 42 | int heightColor = 0x22; 43 | if (origin != null) { 44 | int y = origin.getBlockY(); 45 | if (west != null) { 46 | heightColor = getColor(y, west.getBlockY(), heightColor, 0x11); 47 | } 48 | if (north != null) { 49 | heightColor = getColor(y, north.getBlockY(), heightColor, 0x11); 50 | } 51 | } 52 | return heightColor << 24; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/ModernHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class ModernHeightmap extends Heightmap { 32 | public ModernHeightmap() { 33 | super("modern"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData west = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 41 | Chunk.BlockData north = region.getWorld().getChunk(region, blockX >> 4, (blockZ - 1) >> 4).getData(blockX, blockZ - 1); 42 | int heightColor = 0x22; 43 | if (origin != null) { 44 | int y = origin.getBlockY(); 45 | if (west != null) { 46 | heightColor = getColor(y, west.getBlockY(), heightColor, 0x22); 47 | } 48 | if (north != null) { 49 | heightColor = getColor(y, north.getBlockY(), heightColor, 0x22); 50 | } 51 | } 52 | return heightColor << 24; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/NoneHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Region; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class NoneHeightmap extends Heightmap { 31 | public NoneHeightmap() { 32 | super("none"); 33 | } 34 | 35 | @Override 36 | public int getColor(Region region, int blockX, int blockZ) { 37 | return 0x22 << 24; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/OldSchoolHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class OldSchoolHeightmap extends Heightmap { 32 | public OldSchoolHeightmap() { 33 | super("old_school"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData west = region.getWorld().getChunk(region, (blockX - 1) >> 4, blockZ >> 4).getData(blockX - 1, blockZ); 41 | int heightColor = 0x22; 42 | if (origin != null && west != null) { 43 | heightColor = getColor(origin.getBlockY(), west.getBlockY(), heightColor, 0x22); 44 | } 45 | return heightColor << 24; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/heightmap/VanillaHeightmap.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.heightmap; 25 | 26 | import net.pl3x.map.core.world.Chunk; 27 | import net.pl3x.map.core.world.Region; 28 | import org.jspecify.annotations.NullMarked; 29 | 30 | @NullMarked 31 | public class VanillaHeightmap extends Heightmap { 32 | public VanillaHeightmap() { 33 | super("vanilla"); 34 | } 35 | 36 | @Override 37 | @SuppressWarnings("DuplicatedCode") 38 | public int getColor(Region region, int blockX, int blockZ) { 39 | Chunk.BlockData origin = region.getWorld().getChunk(region, blockX >> 4, blockZ >> 4).getData(blockX, blockZ); 40 | Chunk.BlockData north = region.getWorld().getChunk(region, blockX >> 4, (blockZ - 1) >> 4).getData(blockX, blockZ - 1); 41 | int heightColor = 0x22; 42 | if (origin != null && north != null) { 43 | heightColor = getColor(origin.getBlockY(), north.getBlockY(), heightColor, 0x22); 44 | } 45 | return heightColor << 24; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/renderer/progress/CPSTracker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.renderer.progress; 25 | 26 | import java.util.Arrays; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class CPSTracker { 31 | private static final int SAMPLE_SIZE = 10; 32 | 33 | private final long[] avg = new long[SAMPLE_SIZE]; 34 | private int index = -1; 35 | 36 | public void add(long val) { 37 | this.index = (this.index + 1) % SAMPLE_SIZE; 38 | this.avg[this.index] = val; 39 | } 40 | 41 | public double average() { 42 | return Arrays.stream(this.avg).filter(i -> i != 0).average().orElse(0.0D); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/scheduler/Task.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.scheduler; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public abstract class Task implements Runnable { 30 | final int delay; 31 | final boolean repeat; 32 | 33 | boolean cancelled = false; 34 | int tick; 35 | 36 | /** 37 | * Creates a new schedulable task. 38 | * 39 | * @param delay Delay (in ticks) before task starts 40 | */ 41 | public Task(int delay) { 42 | this(delay, false); 43 | } 44 | 45 | /** 46 | * Creates a new schedulable task. 47 | * 48 | * @param delay Delay (in ticks) before task starts 49 | * @param repeat Whether this task should repeat 50 | */ 51 | public Task(int delay, boolean repeat) { 52 | this.delay = delay; 53 | this.repeat = repeat; 54 | } 55 | 56 | /** 57 | * Mark task as cancelled. 58 | */ 59 | public void cancel() { 60 | this.cancelled = true; 61 | } 62 | 63 | /** 64 | * Check if task is marked as cancelled. 65 | * 66 | * @return True if cancelled 67 | */ 68 | public boolean cancelled() { 69 | return this.cancelled; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/util/ByteUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.util; 25 | 26 | import java.nio.ByteBuffer; 27 | import org.jspecify.annotations.NullMarked; 28 | 29 | @NullMarked 30 | public class ByteUtil { 31 | private ByteUtil() { 32 | } 33 | 34 | public static byte[] toBytes(int packed) { 35 | byte[] bytes = new byte[Integer.BYTES]; 36 | for (int i = 0; i < Integer.BYTES; i++) { 37 | bytes[i] = (byte) (packed >>> (Byte.SIZE * (Integer.BYTES - 1 - i))); 38 | } 39 | return bytes; 40 | } 41 | 42 | public static int getInt(ByteBuffer buffer, int index) { 43 | int value = 0; 44 | for (int i = 0; i < Integer.BYTES; i++) { 45 | value |= (buffer.get(index + i) & 0xFF) << (Byte.SIZE * (Integer.BYTES - 1 - i)); 46 | } 47 | return value; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/util/Preconditions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007 The Guava Authors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except 5 | * in compliance with the License. You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software distributed under the License 10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | * or implied. See the License for the specific language governing permissions and limitations under 12 | * the License. 13 | */ 14 | package net.pl3x.map.core.util; 15 | 16 | import org.jspecify.annotations.NullMarked; 17 | import org.jspecify.annotations.Nullable; 18 | 19 | @NullMarked 20 | public class Preconditions { 21 | public static void checkArgument(boolean condition, @Nullable Object error) { 22 | if (!condition) { 23 | throw new IllegalArgumentException(String.valueOf(error)); 24 | } 25 | } 26 | 27 | public static T checkNotNull(@Nullable T value, @Nullable Object error) { 28 | if (value == null) { 29 | throw new NullPointerException(String.valueOf(error)); 30 | } 31 | return value; 32 | } 33 | 34 | public static void checkState(boolean condition, @Nullable Object error) { 35 | if (!condition) { 36 | throw new IllegalStateException(String.valueOf(error)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/util/TickUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.util; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public class TickUtil { 30 | public static double toSeconds(int ticks) { 31 | return ticks * (1.0 / 20); 32 | } 33 | 34 | public static int toTicks(int seconds) { 35 | return seconds * 20; 36 | } 37 | 38 | public static int toMilliseconds(int ticks) { 39 | return ticks * 50; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/world/BiomeManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Borrowed from Mojang in good faith with much love <3 3 | */ 4 | package net.pl3x.map.core.world; 5 | 6 | import org.jspecify.annotations.NullMarked; 7 | 8 | @NullMarked 9 | public class BiomeManager { 10 | private final long hashedSeed; 11 | 12 | public BiomeManager(long hashedSeed) { 13 | this.hashedSeed = hashedSeed; 14 | } 15 | 16 | public Biome getBiome(Region region, int x, int y, int z) { 17 | int i = x - 2; 18 | int j = y - 2; 19 | int k = z - 2; 20 | int l = i >> 2; 21 | int m = j >> 2; 22 | int n = k >> 2; 23 | double d = (double) (i & 3) / 4.0D; 24 | double e = (double) (j & 3) / 4.0D; 25 | double f = (double) (k & 3) / 4.0D; 26 | int o = 0; 27 | double g = Double.POSITIVE_INFINITY; 28 | for (int p = 0; p < 8; ++p) { 29 | boolean bl = (p & 4) == 0; 30 | boolean bl2 = (p & 2) == 0; 31 | boolean bl3 = (p & 1) == 0; 32 | int q = bl ? l : l + 1; 33 | int r = bl2 ? m : m + 1; 34 | int s = bl3 ? n : n + 1; 35 | double h = bl ? d : d - 1.0D; 36 | double t = bl2 ? e : e - 1.0D; 37 | double u = bl3 ? f : f - 1.0D; 38 | double v = getFiddledDistance(this.hashedSeed, q, r, s, h, t, u); 39 | if (g > v) { 40 | o = p; 41 | g = v; 42 | } 43 | } 44 | x = ((o & 4) == 0 ? l : l + 1) << 2; 45 | y = ((o & 2) == 0 ? m : m + 1) << 2; 46 | z = ((o & 1) == 0 ? n : n + 1) << 2; 47 | return region.getWorld().getChunk(region, x >> 4, z >> 4).getBiome(x, y, z); 48 | } 49 | 50 | private double getFiddledDistance(long seed, int i, int j, int k, double d, double e, double f) { 51 | long m = salt(seed, i); 52 | m = salt(m, j); 53 | m = salt(m, k); 54 | m = salt(m, i); 55 | m = salt(m, j); 56 | m = salt(m, k); 57 | double g = fiddle(m); 58 | m = salt(m, seed); 59 | double h = fiddle(m); 60 | m = salt(m, seed); 61 | double n = fiddle(m); 62 | return square(f + n) + square(e + h) + square(d + g); 63 | } 64 | 65 | private double fiddle(long l) { 66 | double d = (double) Math.floorMod(l >> 24, 1024) / 1024.0D; 67 | return (d - 0.5D) * 0.9D; 68 | } 69 | 70 | private long salt(long seed, long salt) { 71 | return seed * (seed * 6364136223846793005L + 1442695040888963407L) + salt; 72 | } 73 | 74 | private double square(double n) { 75 | return n * n; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /core/src/main/java/net/pl3x/map/core/world/EmptyChunk.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.core.world; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public class EmptyChunk extends Chunk { 30 | protected EmptyChunk(World world, Region region) { 31 | super(world, region); 32 | } 33 | 34 | @Override 35 | public boolean isFull() { 36 | return true; 37 | } 38 | 39 | @Override 40 | public BlockState getBlockState(int x, int y, int z) { 41 | return Blocks.AIR.getDefaultState(); 42 | } 43 | 44 | @Override 45 | public int getLight(int x, int y, int z) { 46 | return getWorld().getSkylight(); 47 | } 48 | 49 | @Override 50 | public Biome getBiome(int x, int y, int z) { 51 | return Biome.DEFAULT; 52 | } 53 | 54 | @Override 55 | public boolean noHeightmap() { 56 | return false; 57 | } 58 | 59 | @Override 60 | public int getWorldSurfaceY(int x, int z) { 61 | return 0; 62 | } 63 | 64 | @Override 65 | public Chunk populate() { 66 | return this; 67 | } 68 | 69 | @Override 70 | public String toString() { 71 | return "EmptyChunk{" 72 | + "world=" + getWorld() 73 | + ",xPos=" + getX() 74 | + ",yPos=" + getY() 75 | + ",zPos=" + getZ() 76 | + "}"; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /core/src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | settings: 2 | debug-mode: false 3 | world-settings: 4 | default: 5 | enabled: true 6 | render: 7 | renderers: 8 | vintage_story: overworld_basic 9 | skylight: 15 10 | world: 11 | enabled: true 12 | render: 13 | renderers: 14 | vintage_story: overworld_basic 15 | ui: 16 | display-name: Overworld 17 | order: 0 18 | world_nether: 19 | render: 20 | renderers: 21 | basic: nether_basic 22 | skylight: 0 23 | ui: 24 | display-name: The Nether 25 | order: 1 26 | world_the_end: 27 | render: 28 | renderers: 29 | basic: the_end_basic 30 | skylight: 0 31 | ui: 32 | display-name: The End 33 | order: 2 34 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/client/duck/MapInstance.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.fabric.client.duck; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public interface MapInstance { 30 | void pl3xMap$skip(); 31 | 32 | void pl3xMap$setData(byte scale, int centerX, int centerZ, String world); 33 | 34 | void pl3xMap$updateImage(); 35 | } 36 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/client/manager/NetworkManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.fabric.client.manager; 25 | 26 | import com.google.common.io.ByteArrayDataInput; 27 | import com.google.common.io.ByteArrayDataOutput; 28 | import com.google.common.io.ByteStreams; 29 | import io.netty.buffer.Unpooled; 30 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 31 | import net.minecraft.client.Minecraft; 32 | import net.minecraft.network.FriendlyByteBuf; 33 | import net.minecraft.resources.ResourceLocation; 34 | import net.pl3x.map.core.network.Constants; 35 | import net.pl3x.map.fabric.client.Pl3xMapFabricClient; 36 | import org.jspecify.annotations.NullMarked; 37 | 38 | @NullMarked 39 | public class NetworkManager { 40 | private final ResourceLocation channel = ResourceLocation.fromNamespaceAndPath(Constants.MODID, Constants.MODID); 41 | private final Pl3xMapFabricClient mod; 42 | 43 | public NetworkManager(Pl3xMapFabricClient mod) { 44 | this.mod = mod; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/common/network/ClientboundServerPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.fabric.common.network; 2 | 3 | import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking; 4 | import net.minecraft.network.FriendlyByteBuf; 5 | import net.minecraft.network.codec.StreamCodec; 6 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 7 | import net.minecraft.resources.ResourceLocation; 8 | import net.pl3x.map.core.network.Constants; 9 | import net.pl3x.map.fabric.client.Pl3xMapFabricClient; 10 | import org.jspecify.annotations.NullMarked; 11 | 12 | @NullMarked 13 | public record ClientboundServerPayload(int protocol, int response, String webAddress) implements CustomPacketPayload { 14 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ClientboundServerPayload::write, ClientboundServerPayload::new); 15 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "client_server_data")); 16 | 17 | public ClientboundServerPayload(int protocol, int response) { 18 | this(protocol, response, null); 19 | } 20 | 21 | public ClientboundServerPayload(FriendlyByteBuf friendlyByteBuf) { 22 | this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt(), friendlyByteBuf.readUtf()); 23 | } 24 | 25 | private void write(FriendlyByteBuf friendlyByteBuf) { 26 | friendlyByteBuf.writeInt(protocol); 27 | friendlyByteBuf.writeInt(response); 28 | friendlyByteBuf.writeUtf(webAddress); 29 | } 30 | 31 | @Override 32 | public Type type() { 33 | return TYPE; 34 | } 35 | 36 | public static void handle(ClientboundServerPayload payload, ClientPlayNetworking.Context context) { 37 | Pl3xMapFabricClient instance = Pl3xMapFabricClient.getInstance(); 38 | if (payload.protocol != Constants.PROTOCOL || payload.response != Constants.RESPONSE_SUCCESS) { 39 | instance.setEnabled(false); 40 | return; 41 | } 42 | 43 | instance.getTileManager().initialize(); 44 | instance.setServerUrl(payload.webAddress); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/common/network/ServerboundMapPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.fabric.common.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ServerboundMapPayload(int protocol, int mapId) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ServerboundMapPayload::write, ServerboundMapPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "server_map_data")); 14 | 15 | public ServerboundMapPayload(int mapId) { 16 | this(Constants.PROTOCOL, mapId); 17 | } 18 | 19 | public ServerboundMapPayload(FriendlyByteBuf friendlyByteBuf) { 20 | this(friendlyByteBuf.readInt(), friendlyByteBuf.readInt()); 21 | } 22 | 23 | private void write(FriendlyByteBuf friendlyByteBuf) { 24 | friendlyByteBuf.writeInt(protocol); 25 | friendlyByteBuf.writeInt(mapId); 26 | } 27 | 28 | @Override 29 | public Type type() { 30 | return TYPE; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/common/network/ServerboundServerPayload.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.fabric.common.network; 2 | 3 | import net.minecraft.network.FriendlyByteBuf; 4 | import net.minecraft.network.codec.StreamCodec; 5 | import net.minecraft.network.protocol.common.custom.CustomPacketPayload; 6 | import net.minecraft.resources.ResourceLocation; 7 | import net.pl3x.map.core.network.Constants; 8 | import org.jspecify.annotations.NullMarked; 9 | 10 | @NullMarked 11 | public record ServerboundServerPayload(int protocol) implements CustomPacketPayload { 12 | public static final StreamCodec STREAM_CODEC = CustomPacketPayload.codec(ServerboundServerPayload::write, ServerboundServerPayload::new); 13 | public static final Type TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath(Constants.MODID, "server_server_data")); 14 | 15 | public ServerboundServerPayload(FriendlyByteBuf friendlyByteBuf) { 16 | this(friendlyByteBuf.readInt()); 17 | } 18 | 19 | private void write(FriendlyByteBuf friendlyByteBuf) { 20 | friendlyByteBuf.writeInt(protocol); 21 | } 22 | 23 | @Override 24 | public Type type() { 25 | return TYPE; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/server/command/FabricParsers.java: -------------------------------------------------------------------------------- 1 | package net.pl3x.map.fabric.server.command; 2 | 3 | import net.minecraft.world.phys.Vec3; 4 | import net.pl3x.map.core.Pl3xMap; 5 | import net.pl3x.map.core.command.Sender; 6 | import net.pl3x.map.core.command.parser.PlatformParsers; 7 | import net.pl3x.map.core.markers.Point; 8 | import net.pl3x.map.core.player.Player; 9 | import net.pl3x.map.fabric.server.FabricPlayer; 10 | import org.incendo.cloud.context.CommandContext; 11 | import org.incendo.cloud.minecraft.modded.data.Coordinates; 12 | import org.incendo.cloud.minecraft.modded.data.SinglePlayerSelector; 13 | import org.incendo.cloud.minecraft.modded.parser.VanillaArgumentParsers; 14 | import org.incendo.cloud.parser.ParserDescriptor; 15 | import org.jspecify.annotations.NullMarked; 16 | import org.jspecify.annotations.Nullable; 17 | 18 | @NullMarked 19 | public class FabricParsers implements PlatformParsers { 20 | @Override 21 | public ParserDescriptor columnPosParser() { 22 | return VanillaArgumentParsers.columnPosParser(); 23 | } 24 | 25 | @Override 26 | public Point resolvePointFromColumnPos(String name, CommandContext context) { 27 | Coordinates.ColumnCoordinates columnCoordinates = context.getOrDefault(name, null); 28 | if (columnCoordinates == null) { 29 | return Point.ZERO; 30 | } 31 | Vec3 position = columnCoordinates.position(); 32 | return Point.of(position.x, position.z); 33 | } 34 | 35 | @Override 36 | public ParserDescriptor playerSelectorParser() { 37 | return VanillaArgumentParsers.singlePlayerSelectorParser(); 38 | } 39 | 40 | @Override 41 | public @Nullable Player resolvePlayerFromPlayerSelector(String name, CommandContext context) { 42 | Sender sender = context.sender(); 43 | SinglePlayerSelector playerSelector = context.getOrDefault(name, null); 44 | if (playerSelector == null) { 45 | if (sender instanceof Sender.Player senderPlayer) { 46 | Player player = Pl3xMap.api().getPlayerRegistry().get(senderPlayer.getUUID()); 47 | if (player != null) { 48 | return player; 49 | } 50 | } 51 | return null; 52 | } 53 | return new FabricPlayer(playerSelector.single()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /fabric/src/main/java/net/pl3x/map/fabric/server/duck/AccessServerPlayer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2020-2023 William Blake Galbreath 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package net.pl3x.map.fabric.server.duck; 25 | 26 | import org.jspecify.annotations.NullMarked; 27 | 28 | @NullMarked 29 | public interface AccessServerPlayer { 30 | boolean pl3xMap$isHidden(); 31 | 32 | void pl3xMap$setHidden(boolean hidden); 33 | } 34 | -------------------------------------------------------------------------------- /fabric/src/main/resources/assets/pl3xmap/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "pl3xmap.title": "Pl3xMap", 3 | "pl3xmap.keymap.toggle": "Toggle On/Off", 4 | "pl3xmap.toggled.response": "Pl3xMap toggled %s.", 5 | "pl3xmap.toggled.on": "on", 6 | "pl3xmap.toggled.off": "off", 7 | "modrinth.download.link": "Download on Modrinth" 8 | } 9 | -------------------------------------------------------------------------------- /fabric/src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "pl3xmap", 4 | "version": "${version}", 5 | "name": "${name}", 6 | "description": "${description}", 7 | "authors": [], 8 | "contact": { 9 | "homepage": "${website}", 10 | "sources": "${sources}", 11 | "issues": "${issues}" 12 | }, 13 | "license": "MIT", 14 | "icon": "pl3xmap.png", 15 | "environment": "*", 16 | "entrypoints": { 17 | "client": [ 18 | "${group}.client.Pl3xMapFabricClient" 19 | ], 20 | "server": [ 21 | "${group}.server.Pl3xMapFabricServer" 22 | ] 23 | }, 24 | "mixins": [ 25 | { 26 | "config": "pl3xmap.client.mixins.json", 27 | "environment": "client" 28 | }, 29 | { 30 | "config": "pl3xmap.server.mixins.json", 31 | "environment": "server" 32 | } 33 | ], 34 | "accessWidener": "pl3xmap.accesswidener", 35 | "depends": { 36 | "fabricloader": ">=${fabricLoaderVersion}", 37 | "fabric": ">=${fabricApiVersion}", 38 | "minecraft": "~${minecraftVersion}", 39 | "java": ">=21", 40 | "cloud": "*", 41 | "adventure-platform-fabric": "*" 42 | }, 43 | "recommends": { 44 | "better-fabric-console": "*" 45 | }, 46 | "custom": { 47 | "modmenu": { 48 | "links": { 49 | "modmenu.discord": "https://granny.dev/discord", 50 | "modrinth.download.link": "https://modrinth.com/mod/pl3xmap/" 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /fabric/src/main/resources/pl3xmap.accesswidener: -------------------------------------------------------------------------------- 1 | accessWidener v2 named 2 | 3 | # client 4 | accessible class net/minecraft/client/resources/MapTextureManager$MapInstance 5 | accessible method net/minecraft/client/resources/MapTextureManager$MapInstance updateTextureIfNeeded ()V 6 | accessible field net/minecraft/client/resources/MapTextureManager maps Lit/unimi/dsi/fastutil/ints/Int2ObjectMap; 7 | 8 | # server 9 | accessible class net/minecraft/world/level/biome/Biome$ClimateSettings 10 | accessible field net/minecraft/world/level/biome/Biome climateSettings Lnet/minecraft/world/level/biome/Biome$ClimateSettings; 11 | accessible field net/minecraft/world/level/storage/DimensionDataStorage dataFolder Ljava/nio/file/Path; 12 | accessible field net/minecraft/commands/CommandSourceStack source Lnet/minecraft/commands/CommandSource; 13 | -------------------------------------------------------------------------------- /fabric/src/main/resources/pl3xmap.client.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.pl3x.map.fabric.client.mixin", 4 | "compatibilityLevel": "JAVA_21", 5 | "refmap": "pl3xmap.refmap.json", 6 | "injectors": { 7 | "defaultRequire": 1 8 | }, 9 | "client": [ 10 | "MapInstanceMixin" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /fabric/src/main/resources/pl3xmap.server.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "package": "net.pl3x.map.fabric.server.mixin", 4 | "compatibilityLevel": "JAVA_21", 5 | "refmap": "pl3xmap.refmap.json", 6 | "injectors": { 7 | "defaultRequire": 1 8 | }, 9 | "server": [ 10 | "MixinServerPlayer" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /forge/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.minecraftforge.gradle' version "$forgeGradleVersion" 3 | } 4 | 5 | group = "${rootProject.group}.forge" 6 | version = rootProject.version 7 | 8 | minecraft { 9 | mappings channel: 'official', version: minecraftVersion 10 | accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') 11 | } 12 | 13 | sourceSets.main.resources { srcDir 'src/generated/resources' } 14 | 15 | dependencies { 16 | compileOnly project(':core') 17 | 18 | minecraft "net.minecraftforge:forge:$forgeVersion" 19 | } 20 | 21 | base { 22 | archivesName = "${rootProject.name}-${project.name}" 23 | } 24 | 25 | jar { 26 | finalizedBy 'reobfJar' 27 | } 28 | 29 | processResources { 30 | filesMatching('META-INF/mods.toml') { 31 | expand( 32 | 'name': rootProject.name, 33 | 'version': project.version, 34 | 'authors': authors, 35 | 'description': project.properties['description'], 36 | 'website': website, 37 | 'issues': issues, 38 | 'forgeLoaderVersion': forgeLoaderVersion, 39 | 'minecraftVersion': minecraftVersion, 40 | ) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /forge/src/main/java/cloud/commandframework/forge/ForgeCommandContextKeys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2023 Cloud Contributors 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package cloud.commandframework.forge; 25 | 26 | import cloud.commandframework.keys.CloudKey; 27 | import cloud.commandframework.keys.SimpleCloudKey; 28 | import io.leangen.geantyref.TypeToken; 29 | import net.minecraft.commands.CommandSourceStack; 30 | 31 | public final class ForgeCommandContextKeys { 32 | 33 | private ForgeCommandContextKeys() { 34 | } 35 | 36 | public static final CloudKey NATIVE_COMMAND_SOURCE = SimpleCloudKey.of( 37 | "cloud:forge_command_source", 38 | TypeToken.get(CommandSourceStack.class) 39 | ); 40 | } 41 | -------------------------------------------------------------------------------- /forge/src/main/java/cloud/commandframework/forge/ForgeCommandPreprocessor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2023 Cloud Contributors 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package cloud.commandframework.forge; 25 | 26 | import cloud.commandframework.execution.preprocessor.CommandPreprocessingContext; 27 | import cloud.commandframework.execution.preprocessor.CommandPreprocessor; 28 | import org.checkerframework.checker.nullness.qual.NonNull; 29 | import org.checkerframework.framework.qual.DefaultQualifier; 30 | 31 | @DefaultQualifier(NonNull.class) 32 | final class ForgeCommandPreprocessor implements CommandPreprocessor { 33 | 34 | private final ForgeCommandManager manager; 35 | 36 | ForgeCommandPreprocessor(final ForgeCommandManager manager) { 37 | this.manager = manager; 38 | } 39 | 40 | @Override 41 | public void accept(final CommandPreprocessingContext context) { 42 | context.getCommandContext().store( 43 | ForgeCommandContextKeys.NATIVE_COMMAND_SOURCE, 44 | this.manager.backwardsCommandSourceMapper().apply(context.getCommandContext().getSender()) 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /forge/src/main/resources/META-INF/accesstransformer.cfg: -------------------------------------------------------------------------------- 1 | public net.minecraft.commands.Commands$CommandSelection f_82144_ 2 | public net.minecraft.commands.Commands$CommandSelection f_82145_ 3 | public net.minecraft.world.level.biome.Biome$ClimateSettings 4 | #public net.minecraft.world.level.biome.Biome f_47437_ #climateSettings #this throws errors at startup for some reason.. used reflection instead 5 | public net.minecraft.world.level.storage.DimensionDataStorage f_78146_ #dataFolder 6 | -------------------------------------------------------------------------------- /forge/src/main/resources/META-INF/mods.toml: -------------------------------------------------------------------------------- 1 | modLoader = "javafml" 2 | loaderVersion = "${forgeLoaderVersion}" 3 | license = "MIT" 4 | showAsResourcePack = false 5 | properties = {} 6 | issueTrackerURL = "${issues}" 7 | [[mods]] 8 | modId = "pl3xmap" 9 | version = "${version}" 10 | displayName = "${name}" 11 | description = "${description}" 12 | logoFile = "pl3xmap.png" 13 | logoBlur = false 14 | #updateJSONURL = "" 15 | modproperties = {} 16 | #credits = "" 17 | authors = ${authors} 18 | displayURL = "${website}" 19 | displayTest = "IGNORE_SERVER_VERSION" 20 | [[dependencies.pl3xmap]] 21 | modId = "forge" 22 | mandatory = true 23 | versionRange = "${forgeLoaderVersion}" 24 | ordering = "AFTER" 25 | side = "SERVER" 26 | [[dependencies.pl3xmap]] 27 | modId = "minecraft" 28 | mandatory = true 29 | versionRange = "[${minecraftVersion}]" 30 | ordering = "AFTER" 31 | side = "SERVER" 32 | -------------------------------------------------------------------------------- /forge/src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": { 4 | "text": "Pl3xMap resources" 5 | }, 6 | "pack_format": 15 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /forge/src/main/resources/pl3xmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/forge/src/main/resources/pl3xmap.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx3G 2 | org.gradle.daemon=false 3 | org.gradle.parallel=false 4 | 5 | systemProp.net.minecraftforge.gradle.check.gradle=false 6 | 7 | authors=["granny", "BillyGalbreath", "JLyne"] 8 | description=Minimalistic and lightweight world map viewer for Minecraft servers 9 | website=https://modrinth.com/plugin/pl3xmap 10 | sources=https://github.com/granny/Pl3xMap 11 | issues=https://github.com/granny/Pl3xMap/issues 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven("https://maven.fabricmc.net/") 5 | //maven("https://maven.minecraftforge.net/") 6 | } 7 | } 8 | 9 | rootProject.name = "Pl3xMap" 10 | 11 | include("core") 12 | include("bukkit") 13 | include("fabric") 14 | //include ("forge") 15 | include("webmap") 16 | -------------------------------------------------------------------------------- /webmap/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.gradle.node.npm.task.NpxTask 2 | 3 | plugins { 4 | id("java") 5 | id("com.github.node-gradle.node") version("7.0.2") 6 | } 7 | 8 | tasks { 9 | clean { 10 | delete("$projectDir/dist") 11 | } 12 | 13 | val buildWebmap = register("buildWebmap") { 14 | dependsOn(npmInstall) 15 | command = "webpack" 16 | 17 | inputs.files( 18 | listOf( 19 | "package.json", 20 | "package-lock.json", 21 | "tsconfig.json", 22 | "webpack.config.js", 23 | ) 24 | ) 25 | inputs.dir("src") 26 | inputs.dir("public") 27 | // inputs.dir(fileTree("node_modules").exclude(".cache")) 28 | outputs.dir("dist") 29 | } 30 | 31 | processResources { 32 | dependsOn(buildWebmap) 33 | 34 | doLast { 35 | val destinationDir = outputs.files.singleFile.resolve("web") 36 | outputs.files.singleFile.resolve("dist").renameTo(destinationDir) 37 | } 38 | } 39 | } 40 | 41 | sourceSets { 42 | main { 43 | java { 44 | resources { 45 | srcDir("$projectDir") 46 | include("dist/**") 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /webmap/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pl3xmap", 3 | "version": "2.0-SNAPSHOT", 4 | "description": "Minimalistic and lightweight world map viewer for Paper servers using the vanilla Minecraft rendering style", 5 | "main": "pl3xmap.js", 6 | "scripts": { 7 | "build": "webpack", 8 | "server": "webpack-dev-server" 9 | }, 10 | "author": "BillyGalbreath", 11 | "license": "MIT", 12 | "devDependencies": { 13 | "@types/leaflet": "^1.9.3", 14 | "compression-webpack-plugin": "^10.0.0", 15 | "copy-webpack-plugin": "^12.0.2", 16 | "css-loader": "^6.7.1", 17 | "leaflet": "^1.9.4", 18 | "mini-css-extract-plugin": "^2.6.1", 19 | "postcss": "^8.4.16", 20 | "sass": "^1.54.8", 21 | "sass-loader": "^13.0.2", 22 | "style-loader": "^3.3.1", 23 | "svg-sprite-loader": "^6.0.11", 24 | "ts-loader": "^9.3.1", 25 | "typescript": "^4.7.4", 26 | "webpack": "^5.76.0", 27 | "webpack-cli": "^4.10.0", 28 | "webpack-dev-server": "^4.9.3" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /webmap/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/favicon.ico -------------------------------------------------------------------------------- /webmap/public/images/armor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/armor.png -------------------------------------------------------------------------------- /webmap/public/images/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/clear.png -------------------------------------------------------------------------------- /webmap/public/images/dry_foliage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/dry_foliage.png -------------------------------------------------------------------------------- /webmap/public/images/foliage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/foliage.png -------------------------------------------------------------------------------- /webmap/public/images/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/grass.png -------------------------------------------------------------------------------- /webmap/public/images/health.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/health.png -------------------------------------------------------------------------------- /webmap/public/images/icon/flowermap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/flowermap.png -------------------------------------------------------------------------------- /webmap/public/images/icon/inhabited.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/inhabited.png -------------------------------------------------------------------------------- /webmap/public/images/icon/marker-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/marker-icon.png -------------------------------------------------------------------------------- /webmap/public/images/icon/marker-shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/marker-shadow.png -------------------------------------------------------------------------------- /webmap/public/images/icon/nether_basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/nether_basic.png -------------------------------------------------------------------------------- /webmap/public/images/icon/nether_biomes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/nether_biomes.png -------------------------------------------------------------------------------- /webmap/public/images/icon/nether_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/nether_night.png -------------------------------------------------------------------------------- /webmap/public/images/icon/nether_roof.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/nether_roof.png -------------------------------------------------------------------------------- /webmap/public/images/icon/overworld_basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/overworld_basic.png -------------------------------------------------------------------------------- /webmap/public/images/icon/overworld_biomes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/overworld_biomes.png -------------------------------------------------------------------------------- /webmap/public/images/icon/overworld_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/overworld_night.png -------------------------------------------------------------------------------- /webmap/public/images/icon/players.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/players.png -------------------------------------------------------------------------------- /webmap/public/images/icon/spawn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/spawn.png -------------------------------------------------------------------------------- /webmap/public/images/icon/the_end_basic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/the_end_basic.png -------------------------------------------------------------------------------- /webmap/public/images/icon/the_end_biomes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/the_end_biomes.png -------------------------------------------------------------------------------- /webmap/public/images/icon/the_end_night.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/the_end_night.png -------------------------------------------------------------------------------- /webmap/public/images/icon/vanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/icon/vanilla.png -------------------------------------------------------------------------------- /webmap/public/images/og.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/og.png -------------------------------------------------------------------------------- /webmap/public/images/skins/steve.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/skins/steve.png -------------------------------------------------------------------------------- /webmap/public/images/sky/nether.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/sky/nether.png -------------------------------------------------------------------------------- /webmap/public/images/sky/overworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/sky/overworld.png -------------------------------------------------------------------------------- /webmap/public/images/sky/the_end.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BillyGalbreath/Pl3xMap/8daeaa37ed73bdd297f30f9e8a32332800569e41/webmap/public/images/sky/the_end.png -------------------------------------------------------------------------------- /webmap/public/modern-normalize.css: -------------------------------------------------------------------------------- 1 | /* modern-normalize 1.1.0 | MIT License | https://github.com/sindresorhus/modern-normalize */progress,sub,sup{vertical-align:baseline}*,::after,::before{box-sizing:border-box}html{-moz-tab-size:4;tab-size:4;line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0;font-family:system-ui,-apple-system,'Segoe UI',Roboto,Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji'}hr{height:0;color:inherit}abbr[title]{text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Consolas,'Liberation Mono',Menlo,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}::-moz-focus-inner{border-style:none;padding:0}:-moz-focusring{outline:ButtonText dotted 1px}:-moz-ui-invalid{box-shadow:none}legend{padding:0}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item} 2 | -------------------------------------------------------------------------------- /webmap/src/control/ControlBox.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Pl3xMap} from "../Pl3xMap"; 3 | 4 | interface ExtendedControlOptions extends L.ControlOptions { 5 | position?: L.ControlPosition & Position | undefined; 6 | } 7 | 8 | type Position = 'topcenter' | 'bottomcenter'; 9 | 10 | export abstract class ControlBox extends L.Control { 11 | protected readonly _pl3xmap: Pl3xMap; 12 | 13 | protected constructor(pl3xmap: Pl3xMap, position: string) { 14 | super(); 15 | this._pl3xmap = pl3xmap; 16 | super.options = { 17 | position: position 18 | } as unknown as ExtendedControlOptions; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /webmap/src/control/ControlManager.ts: -------------------------------------------------------------------------------- 1 | import {Pl3xMap} from "../Pl3xMap"; 2 | import {BlockInfoControl} from "./BlockInfoControl"; 3 | import {CoordsControl} from "./CoordsControl"; 4 | import {LinkControl} from "./LinkControl"; 5 | import SidebarControl from "./SidebarControl"; 6 | 7 | export class ControlManager { 8 | private readonly _pl3xmap: Pl3xMap; 9 | 10 | private _sidebarControl?: SidebarControl 11 | private _blockInfoControl?: BlockInfoControl; 12 | private _coordsControl?: CoordsControl; 13 | private _linkControl?: LinkControl; 14 | 15 | constructor(pl3xmap: Pl3xMap) { 16 | this._pl3xmap = pl3xmap; 17 | } 18 | 19 | get sidebarControl(): SidebarControl | undefined { 20 | return this._sidebarControl; 21 | } 22 | 23 | set sidebarControl(control: SidebarControl | undefined) { 24 | this._sidebarControl?.remove(); 25 | this._sidebarControl = control; 26 | this._sidebarControl?.addTo(this._pl3xmap.map); 27 | } 28 | 29 | get blockInfoControl(): BlockInfoControl | undefined { 30 | return this._blockInfoControl; 31 | } 32 | 33 | set blockInfoControl(control: BlockInfoControl | undefined) { 34 | this._blockInfoControl?.remove(); 35 | this._blockInfoControl = control; 36 | this._blockInfoControl?.addTo(this._pl3xmap.map); 37 | } 38 | 39 | get coordsControl(): CoordsControl | undefined { 40 | return this._coordsControl; 41 | } 42 | 43 | set coordsControl(control: CoordsControl | undefined) { 44 | this._coordsControl?.remove(); 45 | this._coordsControl = control; 46 | this._coordsControl?.addTo(this._pl3xmap.map); 47 | } 48 | 49 | get linkControl(): LinkControl | undefined { 50 | return this._linkControl; 51 | } 52 | 53 | set linkControl(control: LinkControl | undefined) { 54 | this._linkControl?.remove(); 55 | this._linkControl = control; 56 | this._linkControl?.addTo(this._pl3xmap.map); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /webmap/src/control/CoordsControl.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Pl3xMap} from "../Pl3xMap"; 3 | import {ControlBox} from "./ControlBox"; 4 | import {toPoint} from "../util/Util"; 5 | import Pl3xMapLeafletMap from "../map/Pl3xMapLeafletMap"; 6 | 7 | export class CoordsControl extends ControlBox { 8 | declare _map: Pl3xMapLeafletMap; 9 | private _dom: HTMLDivElement = L.DomUtil.create('div'); 10 | private _x: number = 0; 11 | private _y?: number; 12 | private _z: number = 0; 13 | 14 | private onEvent = (event: L.LeafletMouseEvent) => { 15 | return this.update(this._map, toPoint(event.latlng)); 16 | } 17 | 18 | constructor(pl3xmap: Pl3xMap, position: string) { 19 | super(pl3xmap, position); 20 | } 21 | 22 | onAdd(map: Pl3xMapLeafletMap): HTMLDivElement { 23 | this._dom = L.DomUtil.create('div', 'leaflet-control leaflet-control-panel leaflet-control-coordinates'); 24 | this._dom.dataset.label = this._pl3xmap.settings!.lang.coords.label; 25 | map.addEventListener('mousemove', this.onEvent); 26 | this.update(map, [0, 0]); 27 | return this._dom; 28 | } 29 | 30 | onRemove(map: Pl3xMapLeafletMap): void { 31 | map.removeEventListener('mousemove', this.onEvent); 32 | } 33 | 34 | private update(map: Pl3xMapLeafletMap, point: L.PointTuple): void { 35 | this.x = Math.round(point[0]) - 1; 36 | this.z = Math.round(point[1]) - 1; 37 | this._pl3xmap.controlManager.blockInfoControl?.update(map); 38 | this._dom.innerHTML = this._pl3xmap.settings!.lang.coords.value 39 | .replace(//g, this.x.toString().padStart(6, ' ')) 40 | .replace(//g, (this.y?.toString() ?? '???').padStart(2, ' ').padEnd(3, ' ')) 41 | .replace(//g, this.z.toString().padEnd(6, ' ')); 42 | } 43 | 44 | get x(): number { 45 | return this._x; 46 | } 47 | 48 | set x(x: number) { 49 | this._x = x; 50 | } 51 | 52 | get y(): number | undefined { 53 | return this._y; 54 | } 55 | 56 | set y(y: number | undefined) { 57 | this._y = y; 58 | } 59 | 60 | get z(): number { 61 | return this._z; 62 | } 63 | 64 | set z(z: number) { 65 | this._z = z; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /webmap/src/control/LinkControl.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Pl3xMap} from "../Pl3xMap"; 3 | import {ControlBox} from "./ControlBox"; 4 | import {createSVGIcon, toPoint} from "../util/Util"; 5 | import Pl3xMapLeafletMap from "../map/Pl3xMapLeafletMap"; 6 | import '../svg/link.svg'; 7 | import {World} from "../world/World"; 8 | import {Player} from "../player/Player"; 9 | 10 | export class LinkControl extends ControlBox { 11 | private readonly _dom: HTMLAnchorElement; 12 | private _disabled: boolean; 13 | 14 | private onEvent = (): void => { 15 | if (this._disabled) { 16 | return; 17 | } 18 | this.update(); 19 | } 20 | 21 | constructor(pl3xmap: Pl3xMap, position: string) { 22 | super(pl3xmap, position); 23 | this._dom = L.DomUtil.create('a', 'leaflet-control leaflet-control-button leaflet-control-link'); 24 | this._dom.appendChild(createSVGIcon('link')); 25 | this._disabled = false; 26 | addEventListener('followplayer', (e: CustomEvent): void => { 27 | this._disabled = !(e.detail == undefined); // e.detail returns "null" even though it's being set to "undefined" 28 | }); 29 | } 30 | 31 | onAdd(map: Pl3xMapLeafletMap): HTMLAnchorElement { 32 | map.addEventListener('moveend', this.onEvent); 33 | map.addEventListener('zoomend', this.onEvent); 34 | this.update(); 35 | return this._dom; 36 | } 37 | 38 | onRemove(map: Pl3xMapLeafletMap): void { 39 | map.removeEventListener('moveend', this.onEvent); 40 | map.removeEventListener('zoomend', this.onEvent); 41 | } 42 | 43 | public update(): void { 44 | const url: string = this.getUrlFromView(this._pl3xmap.worldManager.currentWorld); 45 | this._dom.href = url; 46 | this._dom.title = this._pl3xmap.settings?.lang.link.label ?? ''; 47 | window.history.replaceState(null, this._pl3xmap.settings!.lang.title, url); 48 | } 49 | 50 | public getUrlFromView(world?: World): string { 51 | const center: L.PointTuple = toPoint(this._pl3xmap.map.getCenter()); 52 | const zoom: number = this._pl3xmap.map.getCurrentZoom(); 53 | const x: number = Math.floor(center[0]); 54 | const z: number = Math.floor(center[1]); 55 | let url: string = `?`; 56 | if (world !== undefined) { 57 | url += `world=${world.name}&renderer=${world.currentRenderer?.label ?? 'basic'}`; 58 | } 59 | return `${url}&zoom=${zoom}&x=${x}&z=${z}`; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /webmap/src/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {MarkerLayer} from "./layergroup/MarkerLayer"; 3 | import {Marker} from "./marker/Marker"; 4 | import {Player} from "./player/Player"; 5 | import {World} from "./world/World"; 6 | import {Pl3xMap} from "./Pl3xMap"; 7 | 8 | declare global { 9 | interface Window { 10 | pl3xmap: Pl3xMap 11 | } 12 | 13 | interface WindowEventMap { 14 | markeradded: CustomEvent; 15 | markerremoved: CustomEvent; 16 | overlayadded: CustomEvent; 17 | overlayremoved: CustomEvent; 18 | playeradded: CustomEvent; 19 | playerremoved: CustomEvent; 20 | rendererselected: CustomEvent; 21 | worldadded: CustomEvent; 22 | worldremoved: CustomEvent; 23 | worldselected: CustomEvent; 24 | followplayer: CustomEvent; 25 | } 26 | } 27 | 28 | module "leaflet" { 29 | export function ellipse(latLng: L.LatLngExpression, radii: L.PointTuple, tilt: number, options: L.PathOptions): Ellipse; 30 | 31 | interface Ellipse extends L.Path { 32 | setRadius(radii: L.PointTuple): this; 33 | 34 | getRadius(): L.Point; 35 | 36 | setTilt(tilt: number): this; 37 | 38 | getBounds(): L.LatLngBounds; 39 | 40 | getLatLng(): L.LatLng; 41 | 42 | setLatLng(latLng: L.LatLngExpression): this; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /webmap/src/marker/Circle.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Point} from "../util/Point"; 4 | import {getOrCreatePane, isset, pixelsToMeters, toCenteredLatLng} from "../util/Util"; 5 | 6 | interface CircleOptions extends L.PolylineOptions { 7 | key: string; 8 | center: Point; 9 | radius: number; 10 | pane: string; 11 | } 12 | 13 | export class Circle extends Marker { 14 | constructor(type: Type) { 15 | const data: CircleOptions = type.data as unknown as CircleOptions; 16 | 17 | let options = { 18 | ...type.options?.properties, 19 | radius: pixelsToMeters(data.radius), 20 | bubblingMouseEvents: true, 21 | interactive: true, 22 | attribution: undefined 23 | }; 24 | 25 | if (isset(data.pane)) { 26 | const dom: HTMLElement = getOrCreatePane(data.pane); 27 | options = { 28 | ...options, 29 | pane: dom.className.split("-")[1] 30 | }; 31 | } 32 | 33 | super(data.key, L.circle(toCenteredLatLng(data.center), options)); 34 | } 35 | 36 | public update(raw: unknown[]): void { 37 | const data: CircleOptions = raw as unknown as CircleOptions; 38 | const circle: L.Circle = this.marker as L.Circle; 39 | circle.setLatLng(toCenteredLatLng(data.center)); 40 | circle.setRadius(pixelsToMeters(data.radius)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /webmap/src/marker/Ellipse.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Point} from "../util/Point"; 4 | import {getOrCreatePane, isset, pixelsToMeters, toCenteredLatLng} from "../util/Util"; 5 | import "../lib/L.ellipse"; 6 | 7 | interface EllipseOptions extends L.PolylineOptions { 8 | key: string; 9 | center: Point; 10 | radius: Point; 11 | tilt?: number; 12 | pane: string; 13 | } 14 | 15 | export class Ellipse extends Marker { 16 | constructor(type: Type) { 17 | const data: EllipseOptions = type.data as unknown as EllipseOptions; 18 | 19 | let options = { 20 | ...type.options?.properties, 21 | bubblingMouseEvents: true, 22 | interactive: true, 23 | attribution: undefined 24 | }; 25 | 26 | if (isset(data.pane)) { 27 | const dom: HTMLElement = getOrCreatePane(data.pane); 28 | options = { 29 | ...options, 30 | pane: dom.className.split("-")[1] 31 | }; 32 | } 33 | 34 | super(data.key, L.ellipse( 35 | toCenteredLatLng(data.center), 36 | [ 37 | pixelsToMeters(data.radius.x), 38 | pixelsToMeters(data.radius.z) 39 | ], 40 | isset(data.tilt) ? data.tilt! : 0, 41 | options) 42 | ); 43 | } 44 | 45 | public update(raw: unknown[]): void { 46 | const data: EllipseOptions = raw as unknown as EllipseOptions; 47 | const ellipse: L.Ellipse = this.marker as L.Ellipse; 48 | ellipse.setLatLng(toCenteredLatLng(data.center)); 49 | ellipse.setRadius([ 50 | pixelsToMeters(data.radius.x), 51 | pixelsToMeters(data.radius.z) 52 | ]); 53 | if (isset(data.tilt)) { 54 | ellipse.setTilt(data.tilt!); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /webmap/src/marker/Marker.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {MarkerOptions} from "./options/MarkerOptions"; 3 | 4 | export abstract class Marker { 5 | private readonly _key: string; 6 | private readonly _marker: L.Layer; 7 | 8 | protected constructor(key: string, marker: L.Layer) { 9 | this._key = key; 10 | this._marker = marker; 11 | } 12 | 13 | get key(): string { 14 | return this._key; 15 | } 16 | 17 | get marker(): L.Layer { 18 | return this._marker; 19 | } 20 | 21 | abstract update(data: unknown[], options?: MarkerOptions): void; 22 | } 23 | 24 | export class Type { 25 | data: unknown[]; 26 | options?: MarkerOptions; 27 | 28 | constructor(data: unknown[], options?: MarkerOptions) { 29 | this.data = data; 30 | this.options = options; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /webmap/src/marker/MultiPolygon.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Polygon} from "../util/Polygon"; 4 | import {getOrCreatePane, isset, toCenteredLatLng} from "../util/Util"; 5 | import {Polyline} from "../util/Polyline"; 6 | import {Point} from "../util/Point"; 7 | 8 | interface MultiPolygonOptions extends L.PolylineOptions { 9 | key: string; 10 | polygons: Polygon[]; 11 | pane: string; 12 | } 13 | 14 | export class MultiPolygon extends Marker { 15 | constructor(type: Type) { 16 | const data: MultiPolygonOptions = type.data as unknown as MultiPolygonOptions; 17 | 18 | let options = { 19 | ...type.options?.properties, 20 | smoothFactor: 1.0, 21 | noClip: false, 22 | bubblingMouseEvents: true, 23 | interactive: true, 24 | attribution: undefined 25 | }; 26 | 27 | if (isset(data.pane)) { 28 | const dom: HTMLElement = getOrCreatePane(data.pane); 29 | options = { 30 | ...options, 31 | pane: dom.className.split("-")[1] 32 | }; 33 | } 34 | 35 | super(data.key, L.polygon(MultiPolygon.createPolys(data), options)); 36 | } 37 | 38 | public update(raw: unknown[]): void { 39 | const data: MultiPolygonOptions = raw as unknown as MultiPolygonOptions; 40 | const polygon: L.Polygon = this.marker as L.Polygon; 41 | polygon.setLatLngs(MultiPolygon.createPolys(data)); 42 | } 43 | 44 | private static createPolys(data: MultiPolygonOptions): L.LatLng[][][] { 45 | const polys: any[] = []; 46 | data.polygons.forEach((polygon: Polygon): void => { 47 | const poly: any[] = []; 48 | polygon.polylines.forEach((polyline: Polyline): void => { 49 | const line: any[] = []; 50 | polyline.points.forEach((point: Point): void => { 51 | line.push(toCenteredLatLng(point)) 52 | }); 53 | poly.push(line); 54 | }); 55 | polys.push(poly); 56 | }); 57 | return polys; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /webmap/src/marker/MultiPolyline.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Polyline} from "../util/Polyline"; 4 | import {getOrCreatePane, isset, toCenteredLatLng} from "../util/Util"; 5 | import {Point} from "../util/Point"; 6 | 7 | interface MultiPolylineOptions extends L.PolylineOptions { 8 | key: string; 9 | polylines: Polyline[]; 10 | pane: string; 11 | } 12 | 13 | export class MultiPolyline extends Marker { 14 | constructor(type: Type) { 15 | const data: MultiPolylineOptions = type.data as unknown as MultiPolylineOptions; 16 | 17 | let options = { 18 | ...type.options?.properties, 19 | smoothFactor: 1.0, 20 | noClip: false, 21 | bubblingMouseEvents: true, 22 | interactive: true, 23 | attribution: undefined 24 | }; 25 | 26 | if (isset(data.pane)) { 27 | const dom: HTMLElement = getOrCreatePane(data.pane); 28 | options = { 29 | ...options, 30 | pane: dom.className.split("-")[1] 31 | }; 32 | } 33 | 34 | super(data.key, L.polyline(MultiPolyline.createLines(data), options)); 35 | } 36 | 37 | public update(raw: unknown[]): void { 38 | const data: MultiPolylineOptions = raw as unknown as MultiPolylineOptions; 39 | const polyline: L.Polyline = this.marker as L.Polyline; 40 | polyline.setLatLngs(MultiPolyline.createLines(data)); 41 | } 42 | 43 | private static createLines(data: MultiPolylineOptions): L.LatLng[][] { 44 | const lines: any[] = []; 45 | data.polylines.forEach((polylines: Polyline): void => { 46 | const line: any[] = []; 47 | polylines.points.forEach((point: Point): void => { 48 | line.push(toCenteredLatLng(point)) 49 | }); 50 | lines.push(line); 51 | }); 52 | return lines; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /webmap/src/marker/Polygon.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Polyline} from "../util/Polyline"; 4 | import {getOrCreatePane, isset, toCenteredLatLng} from "../util/Util"; 5 | import {Point} from "../util/Point"; 6 | 7 | interface PolygonOptions extends L.PolylineOptions { 8 | key: string; 9 | polylines: Polyline[]; 10 | pane: string; 11 | } 12 | 13 | export class Polygon extends Marker { 14 | constructor(type: Type) { 15 | const data: PolygonOptions = type.data as unknown as PolygonOptions; 16 | 17 | let options = { 18 | ...type.options?.properties, 19 | smoothFactor: 1.0, 20 | noClip: false, 21 | bubblingMouseEvents: true, 22 | interactive: true, 23 | attribution: undefined 24 | }; 25 | 26 | if (isset(data.pane)) { 27 | const dom: HTMLElement = getOrCreatePane(data.pane); 28 | options = { 29 | ...options, 30 | pane: dom.className.split("-")[1] 31 | }; 32 | } 33 | 34 | super(data.key, L.polygon(Polygon.createPoly(data), options)); 35 | } 36 | 37 | public update(raw: unknown[]): void { 38 | const data: PolygonOptions = raw as unknown as PolygonOptions; 39 | const polygon: L.Polygon = this.marker as L.Polygon; 40 | polygon.setLatLngs(Polygon.createPoly(data)); 41 | } 42 | 43 | private static createPoly(data: PolygonOptions): L.LatLng[][] { 44 | const poly: any[] = []; 45 | data.polylines.forEach((polyline: Polyline): void => { 46 | const line: any[] = []; 47 | polyline.points.forEach((point: Point): void => { 48 | line.push(toCenteredLatLng(point)); 49 | }); 50 | poly.push(line); 51 | }); 52 | return poly; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /webmap/src/marker/Polyline.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Point} from "../util/Point"; 4 | import {getOrCreatePane, isset, toCenteredLatLng} from "../util/Util"; 5 | 6 | interface PolylineOptions extends L.PolylineOptions { 7 | key: string; 8 | points: Point[]; 9 | pane: string; 10 | } 11 | 12 | export class Polyline extends Marker { 13 | constructor(type: Type) { 14 | const data: PolylineOptions = type.data as unknown as PolylineOptions; 15 | 16 | let options = { 17 | ...type.options?.properties, 18 | smoothFactor: 1.0, 19 | noClip: false, 20 | bubblingMouseEvents: true, 21 | interactive: true, 22 | attribution: undefined 23 | }; 24 | 25 | if (isset(data.pane)) { 26 | const dom: HTMLElement = getOrCreatePane(data.pane); 27 | options = { 28 | ...options, 29 | pane: dom.className.split("-")[1] 30 | }; 31 | } 32 | 33 | super(data.key, L.polyline(Polyline.createLine(data), options)); 34 | } 35 | 36 | public update(raw: unknown[]): void { 37 | const data: PolylineOptions = raw as unknown as PolylineOptions; 38 | const polyline: L.Polyline = this.marker as L.Polyline; 39 | polyline.setLatLngs(Polyline.createLine(data)); 40 | } 41 | 42 | private static createLine(data: PolylineOptions): L.LatLng[] { 43 | const line: any[] = []; 44 | data.points.forEach((point: Point): void => { 45 | line.push(toCenteredLatLng(point)) 46 | }); 47 | return line; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /webmap/src/marker/Rectangle.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Marker, Type} from "./Marker"; 3 | import {Point} from "../util/Point"; 4 | import {getOrCreatePane, isset, toLatLngBounds} from "../util/Util"; 5 | 6 | interface RectangleOptions extends L.PolylineOptions { 7 | key: string; 8 | point1: Point; 9 | point2: Point; 10 | pane: string; 11 | } 12 | 13 | export class Rectangle extends Marker { 14 | constructor(type: Type) { 15 | const data: RectangleOptions = type.data as unknown as RectangleOptions; 16 | 17 | let options = { 18 | ...type.options?.properties, 19 | smoothFactor: 1.0, 20 | noClip: false, 21 | bubblingMouseEvents: true, 22 | interactive: true, 23 | attribution: undefined 24 | }; 25 | 26 | if (isset(data.pane)) { 27 | const dom: HTMLElement = getOrCreatePane(data.pane); 28 | options = { 29 | ...options, 30 | pane: dom.className.split("-")[1] 31 | }; 32 | } 33 | 34 | super(data.key, L.rectangle(toLatLngBounds(data.point1, data.point2), options)); 35 | } 36 | 37 | public update(raw: unknown[]): void { 38 | const data: RectangleOptions = raw as unknown as RectangleOptions; 39 | const rectangle: L.Rectangle = this.marker as L.Rectangle; 40 | rectangle.setBounds(toLatLngBounds(data.point1, data.point2)); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /webmap/src/marker/options/Fill.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Color} from "../../util/Color"; 3 | import {isset} from "../../util/Util"; 4 | 5 | export interface FillOptions { 6 | enabled?: boolean; 7 | type?: number; 8 | color?: number; 9 | } 10 | 11 | export class Fill { 12 | private readonly _properties: L.PathOptions; 13 | 14 | constructor(data: FillOptions) { 15 | let props: object = {}; 16 | 17 | if (isset(data.enabled)) props = {...props, fill: data.enabled}; 18 | if (isset(data.type)) props = {...props, fillRule: Type[data.type!]}; 19 | if (isset(data.color)) { 20 | const color: Color = new Color(data.color!); 21 | props = {...props, fillColor: color.hex, fillOpacity: color.opacity}; 22 | } 23 | 24 | this._properties = props; 25 | } 26 | 27 | get properties(): L.PathOptions { 28 | return this._properties; 29 | } 30 | } 31 | 32 | export enum Type { 33 | nonzero = 0, 34 | evenodd = 1 35 | } 36 | -------------------------------------------------------------------------------- /webmap/src/marker/options/MarkerOptions.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Stroke, StrokeOptions} from "./Stroke"; 3 | import {Fill, FillOptions} from "./Fill"; 4 | import {Tooltip, TooltipOptions} from "./Tooltip"; 5 | import {Popup, PopupOptions} from "./Popup"; 6 | import {isset} from "../../util/Util"; 7 | 8 | export interface Options { 9 | stroke: StrokeOptions; 10 | fill: FillOptions; 11 | tooltip: TooltipOptions; 12 | popup: PopupOptions; 13 | } 14 | 15 | export class MarkerOptions { 16 | private readonly _stroke?: Stroke; 17 | private readonly _fill?: Fill; 18 | private readonly _tooltip?: Tooltip; 19 | private readonly _popup?: Popup; 20 | 21 | constructor(data: Options) { 22 | this._stroke = isset(data.stroke) ? new Stroke(data.stroke!) : undefined; 23 | this._fill = isset(data.fill) ? new Fill(data.fill!) : undefined; 24 | this._tooltip = isset(data.tooltip) ? new Tooltip(data.tooltip!) : undefined; 25 | this._popup = isset(data.popup) ? new Popup(data.popup!) : undefined; 26 | } 27 | 28 | get properties(): L.PathOptions { 29 | return {...this._stroke?.properties, ...this._fill?.properties}; 30 | } 31 | 32 | get tooltip(): Tooltip | undefined { 33 | return this._tooltip; 34 | } 35 | 36 | get popup(): Popup | undefined { 37 | return this._popup; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /webmap/src/marker/options/Stroke.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Color} from "../../util/Color"; 3 | import {isset} from "../../util/Util"; 4 | 5 | export interface StrokeOptions { 6 | enabled?: boolean; 7 | weight?: number; 8 | color?: number; 9 | lineCap?: number; 10 | lineJoin?: number; 11 | dashArray?: string; 12 | dashOffset?: string; 13 | } 14 | 15 | export class Stroke { 16 | private readonly _properties: L.PathOptions; 17 | 18 | constructor(data: StrokeOptions) { 19 | let props: object = {}; 20 | 21 | if (isset(data.enabled)) props = {...props, stroke: data.enabled}; 22 | if (isset(data.weight)) props = {...props, weight: data.weight}; 23 | if (isset(data.color)) { 24 | const color: Color = new Color(data.color!); 25 | props = {...props, color: color.hex, opacity: color.opacity}; 26 | } 27 | if (isset(data.lineCap)) props = {...props, lineCap: LineCap[data.lineCap!]}; 28 | if (isset(data.lineJoin)) props = {...props, lineJoin: LineJoin[data.lineJoin!]}; 29 | if (isset(data.dashArray)) props = {...props, dashArray: data.dashArray}; 30 | if (isset(data.dashOffset)) props = {...props, dashOffset: data.dashOffset}; 31 | 32 | this._properties = props; 33 | } 34 | 35 | get properties(): L.PathOptions { 36 | return this._properties; 37 | } 38 | } 39 | 40 | export enum LineCap { 41 | butt = 0, 42 | round = 1, 43 | square = 2 44 | } 45 | 46 | export enum LineJoin { 47 | miter = 0, 48 | round = 1, 49 | bevel = 2 50 | } 51 | -------------------------------------------------------------------------------- /webmap/src/marker/options/Tooltip.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {Point} from "../../util/Point"; 3 | import {getOrCreatePane, isset} from "../../util/Util"; 4 | 5 | export interface TooltipOptions { 6 | content?: string; 7 | pane?: string; 8 | offset?: Point; 9 | direction?: number; 10 | permanent?: boolean; 11 | sticky?: boolean; 12 | opacity?: number; 13 | } 14 | 15 | export class Tooltip { 16 | private readonly _content: string; 17 | private readonly _properties: L.TooltipOptions; 18 | 19 | constructor(data: TooltipOptions) { 20 | this._content = isset(data.content) ? data.content! : ""; 21 | 22 | let props: object = {}; 23 | if (isset(data.offset)) props = {...props, offset: [data.offset!.x, data.offset!.z]}; 24 | if (isset(data.direction)) props = {...props, direction: Direction[data.direction!]}; 25 | if (isset(data.permanent)) props = {...props, permanent: data.permanent}; 26 | if (isset(data.sticky)) props = {...props, sticky: data.sticky}; 27 | if (isset(data.opacity)) props = {...props, opacity: data.opacity}; 28 | 29 | if (isset(data.pane)) { 30 | const dom: HTMLElement = getOrCreatePane(data.pane!); 31 | props = { 32 | ...props, 33 | pane: dom.className.split(" ")[1].split("-")[1] 34 | }; 35 | } 36 | 37 | this._properties = props; 38 | } 39 | 40 | get content(): string { 41 | return this._content; 42 | } 43 | 44 | get properties(): L.TooltipOptions { 45 | return this._properties; 46 | } 47 | } 48 | 49 | export enum Direction { 50 | right = 0, 51 | left = 1, 52 | top = 2, 53 | bottom = 3, 54 | center = 4, 55 | auto = 5 56 | } 57 | -------------------------------------------------------------------------------- /webmap/src/palette/Block.ts: -------------------------------------------------------------------------------- 1 | export class Block { 2 | private readonly _block: number; 3 | private readonly _biome: number; 4 | private readonly _yPos: number; 5 | private readonly _minY: number; 6 | 7 | constructor(packed: number, minY: number) { 8 | // 11111111111111111111111111111111 - 32 bits - (4294967295) 9 | // 11111111111 - 11 bits - block (2047) 10 | // 111111111 - 9 bits - biome (511) 11 | // 111111111111 - 12 bits - yPos (4095) 12 | this._block = packed >>> 21; 13 | this._biome = (packed & 0b00000000000_111111111_000000000000) >>> 12; 14 | this._yPos = packed & 0b00000000000_000000000_111111111111; 15 | this._minY = minY; 16 | } 17 | 18 | get block(): number { 19 | return this._block; 20 | } 21 | 22 | get biome(): number { 23 | return this._biome; 24 | } 25 | 26 | get yPos(): number { 27 | return this._yPos + this._minY; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /webmap/src/palette/BlockInfo.ts: -------------------------------------------------------------------------------- 1 | import {Block} from "./Block"; 2 | 3 | export class BlockInfo { 4 | public readonly BYTE_SIZE: number = 8; 5 | public readonly INTEGER_BYTES: number = 4; 6 | 7 | private readonly _data: Uint8Array; 8 | 9 | constructor(data: Uint8Array) { 10 | this._data = data; 11 | } 12 | 13 | get minY(): number { 14 | return this.getInt(8); 15 | } 16 | 17 | getBlock(index: number): Block { 18 | return new Block(this.getInt(12 + index * 4), this.minY); 19 | } 20 | 21 | private getInt(position: number): number { 22 | let val: number = 0; 23 | for (let i: number = 0; i < this.INTEGER_BYTES; i++) { 24 | val |= (this._data[position + i] & 0xFF) << (this.BYTE_SIZE * ((this.INTEGER_BYTES - 1) - i)); 25 | } 26 | return val; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /webmap/src/palette/Palette.ts: -------------------------------------------------------------------------------- 1 | export class Palette { 2 | private readonly _index: string; 3 | private readonly _value: string; 4 | 5 | constructor(index: string, value: string) { 6 | this._index = index; 7 | this._value = value; 8 | } 9 | 10 | get index(): string { 11 | return this._index 12 | } 13 | 14 | get value(): string { 15 | return this._value 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /webmap/src/player/Player.ts: -------------------------------------------------------------------------------- 1 | import {Point} from "../util/Point"; 2 | 3 | export class Player { 4 | private readonly _name: string; 5 | private readonly _uuid: string; 6 | 7 | private _displayName: string; 8 | private _world?: string; 9 | private _position?: Point; 10 | 11 | constructor(name: string, uuid: string, displayName: string, world?: string, position?: Point) { 12 | this._name = name; 13 | this._uuid = uuid; 14 | this._displayName = displayName; 15 | this._world = world; 16 | this._position = position; 17 | } 18 | 19 | get name(): string { 20 | return this._name; 21 | } 22 | 23 | get uuid(): string { 24 | return this._uuid; 25 | } 26 | 27 | get displayName(): string { 28 | return this._displayName; 29 | } 30 | 31 | set displayName(displayName: string) { 32 | this._displayName = displayName; 33 | } 34 | 35 | get world(): string | undefined { 36 | return this._world; 37 | } 38 | 39 | set world(world: string | undefined) { 40 | this._world = world; 41 | } 42 | 43 | get position(): Point | undefined { 44 | return this._position; 45 | } 46 | 47 | set position(position: Point | undefined) { 48 | this._position = position; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /webmap/src/scss/_mixins.scss: -------------------------------------------------------------------------------- 1 | @mixin button { 2 | display: inline-block; 3 | appearance: none; 4 | box-shadow: var(--ui-box-shadow); 5 | white-space: nowrap; 6 | background-color: var(--ui-background); 7 | color: var(--ui-text); 8 | border-radius: var(--ui-border-radius); 9 | border: var(--ui-border); 10 | background-clip: padding-box; 11 | position: relative; 12 | padding: 0.5rem; 13 | line-height: 2rem; 14 | cursor: pointer; 15 | transition: 0.2s all ease-in; 16 | 17 | > a:only-child { 18 | display: block; 19 | width: 100%; 20 | height: 100%; 21 | } 22 | 23 | > img:only-child, 24 | > svg:only-child { 25 | position: absolute; 26 | top: 0; 27 | left: 0; 28 | right: 0; 29 | bottom: 0; 30 | margin: auto; 31 | width: calc(100% - 1.6rem); 32 | height: calc(100% - 1.6rem); 33 | pointer-events: none; 34 | } 35 | 36 | &:visited, &:link { 37 | color: var(--ui-text); 38 | } 39 | } 40 | 41 | 42 | @mixin button-hovered { 43 | background-color: var(--ui-background-hover); 44 | color: var(--ui-text-hover); 45 | } 46 | 47 | @mixin button-pressed { 48 | background-color: var(--ui-background-selected); 49 | color: var(--ui-text-selected); 50 | font-weight: bold; 51 | } 52 | 53 | @mixin button-focused { 54 | outline: var(--ui-outline); 55 | } 56 | 57 | @mixin button-active { 58 | background-color: var(--ui-background-active); 59 | color: var(--ui-text-active); 60 | } 61 | 62 | @mixin button-disabled { 63 | background-color: var(--ui-background-disabled); 64 | color: var(--ui-text-disabled); 65 | cursor: not-allowed; 66 | 67 | &:hover, &:active, &:focus { 68 | background-color: var(--ui-background-disabled); 69 | color: var(--ui-text-disabled); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /webmap/src/scss/_placeholders.scss: -------------------------------------------------------------------------------- 1 | %button { 2 | @include button; 3 | 4 | &:hover { 5 | @include button-hovered; 6 | } 7 | 8 | &:focus { 9 | @include button-focused; 10 | } 11 | 12 | &:focus:not(:focus-visible) { 13 | outline-style: none; 14 | } 15 | 16 | &:active { 17 | @include button-active; 18 | } 19 | 20 | &[disabled], &.leaflet-disabled { 21 | @include button-disabled; 22 | } 23 | 24 | &[aria-pressed=true], &[aria-expanded=true] { 25 | @include button-pressed; 26 | } 27 | } 28 | 29 | %square-button { 30 | @extend %button; 31 | height: var(--ui-button-size); 32 | width: var(--ui-button-size); 33 | line-height: calc(var(--ui-button-size) - 1.2rem); 34 | } 35 | 36 | %panel { 37 | background-color: var(--ui-background); 38 | color: var(--ui-text); 39 | border-radius: var(--ui-border-radius); 40 | border: var(--ui-border); 41 | padding: 0.2rem 0.5rem; 42 | } 43 | -------------------------------------------------------------------------------- /webmap/src/scss/_sidebar.scss: -------------------------------------------------------------------------------- 1 | #sidebar { 2 | position: relative; 3 | transition: 0.2s transform ease-in; 4 | transform: none; 5 | 6 | &.sidebar--expanded { 7 | --transform: calc(-1 * var(--ui-sidebar-width)); 8 | transform: translateX(var(--transform)); 9 | } 10 | 11 | #sidebar__buttons { 12 | display: grid; 13 | grid-gap: var(--ui-element-spacing); 14 | 15 | button { 16 | @extend %square-button; 17 | } 18 | } 19 | 20 | #sidebar__content { 21 | @extend %panel; 22 | padding: 1rem 1.5rem; 23 | border-radius: 0; 24 | position: absolute; 25 | top: calc(-1 * var(--ui-element-spacing)); 26 | left: calc(var(--ui-button-size) + var(--ui-element-spacing)); 27 | height: 100vh; 28 | width: var(--ui-sidebar-width); 29 | transition: 0.5s transform ease-in; 30 | overflow-y: auto; 31 | 32 | h2 { 33 | margin-top: 0; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /webmap/src/settings/Settings.ts: -------------------------------------------------------------------------------- 1 | import {Lang} from "./Lang"; 2 | import {Player} from "../player/Player"; 3 | import {WorldSettings} from "./WorldSettings"; 4 | 5 | /** 6 | * Represents global settings. 7 | */ 8 | export class Settings { 9 | private readonly _format: string; 10 | private readonly _maxPlayers: number; 11 | private readonly _lang: Lang; 12 | private readonly _zoom: Zoom; 13 | private readonly _players: Player[]; 14 | private readonly _worldSettings: WorldSettings[]; 15 | 16 | constructor(format: string, maxPlayers: number, lang: Lang, zoom: Zoom, players: Player[], worldSettings: WorldSettings[]) { 17 | this._format = format; 18 | this._maxPlayers = maxPlayers; 19 | this._lang = lang; 20 | this._zoom = zoom; 21 | this._players = players; 22 | this._worldSettings = worldSettings; 23 | } 24 | 25 | get format(): string { 26 | return this._format; 27 | } 28 | 29 | get maxPlayers(): number { 30 | return this._maxPlayers; 31 | } 32 | 33 | get lang(): Lang { 34 | return this._lang; 35 | } 36 | 37 | get zoom(): Zoom { 38 | return this._zoom; 39 | } 40 | 41 | get players(): Player[] { 42 | return this._players; 43 | } 44 | 45 | get worldSettings(): WorldSettings[] { 46 | return this._worldSettings; 47 | } 48 | } 49 | 50 | export class Zoom { 51 | private readonly _snap: number; 52 | private readonly _delta: number; 53 | private readonly _wheel: number; 54 | 55 | constructor(snap: number, delta: number, wheel: number) { 56 | this._snap = snap; 57 | this._delta = delta; 58 | this._wheel = wheel; 59 | } 60 | 61 | get snap(): number { 62 | return this._snap; 63 | } 64 | 65 | get delta(): number { 66 | return this._delta; 67 | } 68 | 69 | get wheel(): number { 70 | return this._wheel; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /webmap/src/sidebar/BaseTab.ts: -------------------------------------------------------------------------------- 1 | import * as L from "leaflet"; 2 | import {SidebarTab} from "../control/SidebarControl"; 3 | import {Pl3xMap} from "../Pl3xMap"; 4 | 5 | export default class BaseTab implements SidebarTab { 6 | protected readonly _pl3xmap: Pl3xMap; 7 | protected readonly _button: HTMLButtonElement = L.DomUtil.create('button'); 8 | protected readonly _content: HTMLDivElement = L.DomUtil.create('div'); 9 | protected readonly _id: string; 10 | 11 | constructor(pl3xmap: Pl3xMap, id: string) { 12 | this._pl3xmap = pl3xmap; 13 | this._id = id; 14 | 15 | this._button.type = 'button'; 16 | this._button.setAttribute('aria-expanded', 'false'); 17 | this._button.setAttribute('aria-controls', `sidebar__${this._id}`); 18 | 19 | this._content.hidden = true; 20 | this._content.id = `sidebar__${this._id}`; 21 | this._content.setAttribute('aria-hidden', 'true'); 22 | } 23 | 24 | get button(): HTMLElement { 25 | return this._button; 26 | } 27 | 28 | get content(): HTMLElement { 29 | return this._content; 30 | } 31 | 32 | get id(): string { 33 | return this._id; 34 | } 35 | 36 | onActivate(): void { 37 | if (this._content.children.length) { 38 | const focusTarget: HTMLElement = (this._content.firstElementChild as HTMLElement); 39 | focusTarget.tabIndex = -1; 40 | focusTarget.focus(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /webmap/src/sidebar/MarkersTab.ts: -------------------------------------------------------------------------------- 1 | import {Pl3xMap} from "../Pl3xMap"; 2 | import {createSVGIcon} from "../util/Util"; 3 | import BaseTab from "./BaseTab"; 4 | import '../svg/marker_point.svg'; 5 | import {Lang} from "../settings/Lang"; 6 | 7 | export default class MarkersTab extends BaseTab { 8 | constructor(pl3xmap: Pl3xMap) { 9 | super(pl3xmap, 'markers'); 10 | 11 | const lang: Lang = pl3xmap.settings!.lang; 12 | 13 | this._button.appendChild(createSVGIcon('marker_point')); 14 | this._button.title = lang.markers.label; 15 | 16 | this._content.innerHTML = `

${lang.markers.label}

// TODO`; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /webmap/src/svg/layers.svg: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /webmap/src/svg/link.svg: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /webmap/src/svg/maps.svg: -------------------------------------------------------------------------------- 1 | 22 | 23 | -------------------------------------------------------------------------------- /webmap/src/svg/marker_point.svg: -------------------------------------------------------------------------------- 1 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /webmap/src/tilelayer/DoubleTileLayer.ts: -------------------------------------------------------------------------------- 1 | import {Pl3xMap} from "../Pl3xMap"; 2 | import {Renderer, World} from "../world/World"; 3 | import {ReversedZoomTileLayer} from "./ReversedZoomTileLayer"; 4 | import Pl3xMapLeafletMap from "../map/Pl3xMapLeafletMap"; 5 | 6 | export class DoubleTileLayer { 7 | private readonly _tileLayer1: ReversedZoomTileLayer; 8 | private readonly _tileLayer2: ReversedZoomTileLayer; 9 | 10 | // start with 0. from here will switch to 1 then 2 then 1 then 2 etc. 11 | private _currentLayer: number = 0; 12 | 13 | constructor(pl3xmap: Pl3xMap, world: World, renderer: Renderer) { 14 | // we need 2 tile layers to swap between for seamless refreshing 15 | this._tileLayer1 = this.createTileLayer(pl3xmap, world, renderer); 16 | this._tileLayer2 = this.createTileLayer(pl3xmap, world, renderer); 17 | } 18 | 19 | private createTileLayer(pl3xmap: Pl3xMap, world: World, renderer: Renderer): ReversedZoomTileLayer { 20 | return new ReversedZoomTileLayer(pl3xmap, world, renderer) 21 | .addEventListener("load", (): void => { 22 | // when all tiles in this layer are loaded, switch to this layer 23 | this.switchTileLayer(); 24 | }); 25 | } 26 | 27 | private switchTileLayer(): void { 28 | // swap current tile layer 29 | if (this._currentLayer == 1) { 30 | this._tileLayer1.setZIndex(0); 31 | this._tileLayer2.setZIndex(1); 32 | this._currentLayer = 2; 33 | } else { 34 | this._tileLayer1.setZIndex(1); 35 | this._tileLayer2.setZIndex(0); 36 | this._currentLayer = 1; 37 | } 38 | } 39 | 40 | public updateTileLayer(): void { 41 | // redraw opposite tile layer 42 | // it will switch to it when all tiles load 43 | if (this._currentLayer == 1) { 44 | this._tileLayer2.redraw(); 45 | } else { 46 | this._tileLayer1.redraw(); 47 | } 48 | } 49 | 50 | public addTo(map: Pl3xMapLeafletMap): void { 51 | this._tileLayer1.addTo(map); 52 | this._tileLayer2.addTo(map); 53 | } 54 | 55 | public remove(): void { 56 | this._tileLayer1.remove(); 57 | this._tileLayer2.remove(); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /webmap/src/util/Color.ts: -------------------------------------------------------------------------------- 1 | export class Color { 2 | private readonly _rgb: number; 3 | private readonly _hex: string; 4 | private readonly _opacity: number; 5 | 6 | constructor(color: number) { 7 | this._rgb = color; 8 | this._hex = "#" + (color & 0xFFFFFF).toString(16).padStart(6, '0'); 9 | this._opacity = (color >> 24 & 0xFF) / 0xFF; 10 | } 11 | 12 | get rgb(): number { 13 | return this._rgb; 14 | } 15 | 16 | get hex(): string { 17 | return this._hex; 18 | } 19 | 20 | get opacity(): number { 21 | return this._opacity; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /webmap/src/util/Point.ts: -------------------------------------------------------------------------------- 1 | export class Point { 2 | private readonly _x: number; 3 | private readonly _z: number; 4 | 5 | constructor(x: number, z: number) { 6 | this._x = x; 7 | this._z = z; 8 | } 9 | 10 | get x(): number { 11 | return this._x; 12 | } 13 | 14 | get z(): number { 15 | return this._z; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /webmap/src/util/Polygon.ts: -------------------------------------------------------------------------------- 1 | import {Polyline} from "./Polyline"; 2 | 3 | export class Polygon { 4 | private readonly _key: string; 5 | private readonly _polylines: Polyline[]; 6 | 7 | constructor(key: string, polylines: Polyline[]) { 8 | this._key = key; 9 | this._polylines = polylines; 10 | } 11 | 12 | get key(): string { 13 | return this._key; 14 | } 15 | 16 | get polylines(): Polyline[] { 17 | return this._polylines; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /webmap/src/util/Polyline.ts: -------------------------------------------------------------------------------- 1 | import {Point} from "./Point"; 2 | 3 | export class Polyline { 4 | private readonly _key: string; 5 | private readonly _points: Point[]; 6 | 7 | constructor(key: string, points: Point[]) { 8 | this._key = key; 9 | this._points = points; 10 | } 11 | 12 | get key(): string { 13 | return this._key; 14 | } 15 | 16 | get points(): Point[] { 17 | return this._points; 18 | } 19 | } 20 | --------------------------------------------------------------------------------