-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7570baa
commit 61bda72
Showing
15 changed files
with
285 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/config/ClientConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
data class ClientConfig( | ||
val HudInfoLevel: Int = 3, | ||
val HudPosition: HudSide = HudSide.LEFT, | ||
val displayWithChatOpen: Boolean = true, | ||
val xOffset: Int = 7, | ||
val yOffset: Int = 16, | ||
val overlayLineOffset: Int = 1, | ||
val closedEnough: Double = 0.3 | ||
) |
24 changes: 24 additions & 0 deletions
24
...main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/config/CommonConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
data class CommonConfig( | ||
val filterMode: FilterMode = FilterMode.BLACKLIST, | ||
val filterList: MutableList<String> = mutableListOf(), | ||
val maxDistance: Double = 5000.0, | ||
val radius: Int = 64, | ||
) |
39 changes: 39 additions & 0 deletions
39
...in/kotlin/io/github/samarium150/minecraft/mod/structures_compass/config/ConfigComments.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
data class ConfigComments( | ||
val _filterMode: String = "The mode of the filter, either blacklist or whitelist, default is blacklist", | ||
val _filter: String = "A list of structures that the compass will not search in blacklist mode " + | ||
"or will only search in whitelist mode, specified by resource location, supporting regex", | ||
val _maxDistance: String = "The pseudo maximum searching radius. " + | ||
"If the distance to the structure exceeds this value, HUD would display 'Not Found'", | ||
val _radius: String = "The real maximum searching radius used by the underlying method (no idea how it works.)" + | ||
"If you still couldn't find a structure with a big enough MaxSearchRadius, increase this one." + | ||
"If you think searching makes the server slow, decrease this one.", | ||
val _HudInfoLevel: String = "HUD information detail level. 0: Nothing." + | ||
"1+: Structure and Dimension name." + | ||
"2+: Distance to the structure." + | ||
"3: Position of the structure and distance in x/y/z axis.", | ||
val _HudPosition: String = "The side of the information HUD. Either LEFT or RIGHT.", | ||
val _displayWithChatOpen: String = "Displays the compass information HUD even while chat is open.", | ||
val _xOffset: String = "The X offset for information rendered on the HUD. (default:7)", | ||
val _yOffset: String = "The Y offset for information rendered on the HUD. (default:16)", | ||
val _overlayLineOffset: String = "The line offset for information rendered on the HUD. (default:1)", | ||
val _closedEnough: String = "The X/Y/Z-distance won't be shown " + | ||
"if the distance is smaller than the value. (default:0.3)" | ||
) |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/config/FilterMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
enum class FilterMode { | ||
BLACKLIST, WHITELIST | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/config/HudSide.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
enum class HudSide { | ||
LEFT, RIGHT | ||
} |
58 changes: 58 additions & 0 deletions
58
.../io/github/samarium150/minecraft/mod/structures_compass/config/StructuresCompassConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2022 Samarium | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>. | ||
*/ | ||
package io.github.samarium150.minecraft.mod.structures_compass.config | ||
|
||
import com.google.gson.GsonBuilder | ||
import com.google.gson.JsonIOException | ||
import io.github.samarium150.minecraft.mod.structures_compass.data.StructuresCompassData | ||
import io.github.samarium150.minecraft.mod.structures_compass.util.MOD_ID | ||
import net.fabricmc.loader.api.FabricLoader | ||
import java.io.IOException | ||
import java.nio.file.Files | ||
|
||
object StructuresCompassConfig { | ||
|
||
private val configFilePath | ||
get() = FabricLoader.getInstance().configDir.resolve("$MOD_ID.json") | ||
|
||
private val gson = GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create() | ||
|
||
data class ConfigData( | ||
val comments: ConfigComments = ConfigComments(), | ||
val common: CommonConfig, | ||
val client: ClientConfig | ||
) | ||
|
||
var configData = ConfigData(common = CommonConfig(), client = ClientConfig()) | ||
|
||
@Throws(SecurityException::class, IOException::class, JsonIOException::class) | ||
fun load() { | ||
if (Files.exists(configFilePath)) | ||
Files.newBufferedReader(configFilePath).use { reader -> | ||
configData = gson.fromJson(reader, ConfigData::class.java) | ||
} | ||
save() | ||
StructuresCompassData.init() | ||
} | ||
|
||
@Throws(JsonIOException::class, IOException::class) | ||
private fun save() { | ||
Files.newBufferedWriter(configFilePath).use { writer -> | ||
gson.toJson(configData, writer) | ||
} | ||
} | ||
} |
Oops, something went wrong.