Skip to content

Commit ca733e3

Browse files
committed
Port to fabric (huge commit sowwy)
1 parent 0f77441 commit ca733e3

File tree

46 files changed

+1061
-528
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1061
-528
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+

.github/workflows/build.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Automatically build the project and run any configured tests for every push
2+
# and submitted pull request. This can help catch issues that only occur on
3+
# certain platforms or Java versions, and provides a first line of defence
4+
# against bad commits.
5+
6+
name: build
7+
on: [pull_request, push]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
# Use these Java versions
14+
java: [
15+
21, # Current Java LTS
16+
]
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- name: checkout repository
20+
uses: actions/checkout@v4
21+
- name: validate gradle wrapper
22+
uses: gradle/wrapper-validation-action@v2
23+
- name: setup jdk ${{ matrix.java }}
24+
uses: actions/setup-java@v4
25+
with:
26+
java-version: ${{ matrix.java }}
27+
distribution: 'microsoft'
28+
- name: make gradle wrapper executable
29+
run: chmod +x ./gradlew
30+
- name: build
31+
run: ./gradlew build
32+
- name: capture build artifacts
33+
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: Artifacts
37+
path: build/libs/

.gitignore

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
.gradle
2-
.idea
3-
build
4-
debug
1+
# gradle
2+
3+
.gradle/
4+
build/
5+
out/
6+
classes/
7+
8+
# eclipse
9+
10+
*.launch
11+
12+
# idea
13+
14+
.idea/
15+
*.iml
16+
*.ipr
17+
*.iws
18+
19+
# vscode
20+
21+
.settings/
22+
.vscode/
23+
bin/
24+
.classpath
25+
.project
26+
27+
# macos
28+
29+
*.DS_Store
30+
31+
# fabric
32+
33+
run/
34+
35+
# java
36+
37+
hs_err_*.log
38+
replay_*.log
39+
*.hprof
40+
*.jfr

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 RedPolygon
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.

README.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

build.gradle

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
3+
plugins {
4+
id "org.jetbrains.kotlin.jvm" version "2.0.0" apply false
5+
id "org.jetbrains.kotlin.plugin.serialization" version "2.0.0" apply false
6+
id "kr.entree.spigradle" version "2.4.3" apply false
7+
id "fabric-loom" version "1.7-SNAPSHOT" apply false
8+
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
9+
}
10+
11+
repositories {
12+
mavenCentral()
13+
}
14+
15+
allprojects {
16+
version = project.version
17+
group = project.group
18+
}
19+
20+
subprojects {
21+
apply plugin: "java"
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
tasks.withType(JavaCompile).configureEach {
28+
it.options.release = 21
29+
}
30+
31+
tasks.withType(KotlinCompile).configureEach {
32+
kotlinOptions {
33+
jvmTarget = 21
34+
}
35+
}
36+
37+
jar {
38+
from("LICENSE") {
39+
rename { "${it}_${project.base.archivesName.get()}"}
40+
}
41+
}
42+
}

build.gradle.kts

Lines changed: 0 additions & 72 deletions
This file was deleted.

dynmapexport-common/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
plugins {
2+
id "org.jetbrains.kotlin.jvm"
3+
id "org.jetbrains.kotlin.plugin.serialization"
4+
id "com.github.johnrengelman.shadow"
5+
}
6+
7+
repositories {}
8+
9+
dependencies {
10+
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1"
11+
implementation "org.slf4j:slf4j-api:2.0.13"
12+
implementation "com.charleskorn.kaml:kaml:${project.kaml_version}"
13+
14+
testImplementation(platform "org.junit:junit-bom:5.10.3")
15+
testImplementation "org.junit.jupiter:junit-jupiter"
16+
testRuntimeOnly "org.junit.platform:junit-platform-launcher"
17+
}
18+
19+
test {
20+
useJUnitPlatform()
21+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package nl.dantevg.dynmapexport
2+
3+
import com.charleskorn.kaml.YamlComment
4+
import kotlinx.serialization.SerialName
5+
import kotlinx.serialization.Serializable
6+
import nl.dantevg.dynmapexport.location.TileCoords
7+
import nl.dantevg.dynmapexport.location.WorldCoords
8+
import kotlin.math.max
9+
import kotlin.math.min
10+
11+
@Serializable
12+
data class Config(
13+
@SerialName("dynmap-host")
14+
@YamlComment(
15+
"The hostname/ip and port of Dynmap.",
16+
"(use localhost for Dynmap running on the same server)"
17+
)
18+
val dynmapHost: String = "localhost:8123",
19+
20+
@SerialName("auto-combine")
21+
@YamlComment(
22+
"Whether to automatically combine the tiles into a single image.",
23+
"Disabling this can reduce server lag if you encounter it (for large images),",
24+
"but you'll need to combine the tiles yourself.",
25+
)
26+
val autoCombine: Boolean = true,
27+
28+
@YamlComment(
29+
"A list of export configurations. Example:",
30+
" exports:",
31+
" - world: world",
32+
" map: surface",
33+
" zoom: 0",
34+
" change-threshold: 0.2",
35+
" from:",
36+
" x: -100",
37+
" z: -100",
38+
" to:",
39+
" x: 100",
40+
" z: 100",
41+
)
42+
val exports: List<ExportConfig> = emptyList(),
43+
)
44+
45+
@Serializable
46+
data class ExportConfig(
47+
val world: String,
48+
val map: String,
49+
val zoom: Int = 0,
50+
@SerialName("change-threshold")
51+
val changeThreshold: Double = 0.2,
52+
val from: WorldCoords,
53+
val to: WorldCoords,
54+
) {
55+
constructor(
56+
world: DynmapWebAPI.World,
57+
map: DynmapWebAPI.Map,
58+
zoom: Int,
59+
changeThreshold: Double,
60+
from: WorldCoords,
61+
to: WorldCoords = from,
62+
) : this(world.name, map.name, zoom, changeThreshold, from, to)
63+
64+
/**
65+
* Get all tile locations from this export config.
66+
*
67+
* @return a list of tiles that are within the range from the config
68+
*/
69+
fun toTileLocations(map: DynmapWebAPI.Map): List<TileCoords> {
70+
val tiles: MutableList<TileCoords> = ArrayList()
71+
val (fromTile, toTile) = toMinMaxTileCoords(map)
72+
73+
for (x in fromTile.x..toTile.x step (1 shl zoom)) {
74+
for (y in fromTile.y..toTile.y step (1 shl zoom)) {
75+
tiles += TileCoords(x, y)
76+
}
77+
}
78+
79+
return tiles
80+
}
81+
82+
fun toMinMaxTileCoords(map: DynmapWebAPI.Map): Pair<TileCoords, TileCoords> {
83+
val fromTile = from.toTileCoords(map, zoom)
84+
val toTile = to.toTileCoords(map, zoom)
85+
return Pair(
86+
TileCoords(min(fromTile.x, toTile.x), min(fromTile.y, toTile.y)).floorToZoom(zoom),
87+
TileCoords(max(fromTile.x, toTile.x), max(fromTile.y, toTile.y)).ceilToZoom(zoom)
88+
)
89+
}
90+
}

0 commit comments

Comments
 (0)