diff --git a/build.gradle.kts b/build.gradle.kts index 9c56f6a..308416d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,11 @@ import de.chojo.Repo +import net.minecrell.pluginyml.bukkit.BukkitPluginDescription.Permission.Default.FALSE plugins { id("org.cadixdev.licenser") version "0.6.1" id("com.github.johnrengelman.shadow") version "8.1.1" id("de.chojo.publishdata") version "1.2.4" + id("net.minecrell.plugin-yml.bukkit") version "0.5.3" java `maven-publish` } @@ -17,10 +19,17 @@ repositories { } dependencies { - compileOnly("de.eldoria", "schematicbrushreborn-api", "2.4.3") + compileOnly("de.eldoria", "schematicbrushreborn-api", "2.5.0-DEV") compileOnly("org.spigotmc", "spigot-api", "1.13.2-R0.1-SNAPSHOT") compileOnly("com.sk89q.worldedit", "worldedit-bukkit", "7.2.14") + bukkitLibrary("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.14.2") + bukkitLibrary("com.fasterxml.jackson.core:jackson-core:2.14.2") + bukkitLibrary("com.fasterxml.jackson.core:jackson-databind:2.14.2") + bukkitLibrary("net.kyori:adventure-platform-bukkit:4.3.0") + bukkitLibrary("net.kyori:adventure-text-minimessage:4.13.0") + + testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2") } @@ -37,6 +46,7 @@ java { } publishData { + addBuildData() addRepo(Repo.main("", "https://eldonexus.de/repository/maven-releases/", false)) addRepo(Repo.dev("DEV", "https://eldonexus.de/repository/maven-dev/", true)) addRepo(Repo.snapshot("SNAPSHOT", "https://eldonexus.de/repository/maven-snapshots/", true)) @@ -82,7 +92,6 @@ tasks { shadowJar { relocate("de.eldoria.eldoutilities", "de.eldoria.schematicbrush.libs.eldoutilities") relocate("de.eldoria.messageblocker", "de.eldoria.schematicbrush.libs.messageblocker") - relocate("net.kyori", "de.eldoria.schematicbrush.libs.kyori") mergeServiceFiles() } @@ -90,7 +99,7 @@ tasks { from(sourceSets.main.get().resources.srcDirs) { filesMatching("plugin.yml") { expand( - "version" to publishData.getVersion(true) + "version" to publishData.getVersion(true) ) } duplicatesStrategy = DuplicatesStrategy.INCLUDE @@ -112,3 +121,29 @@ tasks { dependsOn(shadowJar) } } + +bukkit { + name = "SurvivalSchematicBrush" + main = "de.eldoria.survivalbrush.SurvivalBrush" + apiVersion = "1.16" + version = publishData.getVersion(true) + authors = listOf("RainbowDashLabs") + depend = listOf("SchematicBrushReborn") + + permissions { + register("survivalschematicbrush.paste.bypass") { + default = FALSE + description = "Allow to bypass block pasting check when in survival" + } + + register("survivalschematicbrush.limit.bypass") { + default = FALSE + description = "Allow to bypass max schematic size" + } + + register("survivalschematicbrush.limit.") { + default = FALSE + description = "Set the max blocks a schematic can have" + } + } +} diff --git a/src/main/java/de/eldoria/survivalbrush/SurvivalBrush.java b/src/main/java/de/eldoria/survivalbrush/SurvivalBrush.java index 2355fd2..bac448e 100644 --- a/src/main/java/de/eldoria/survivalbrush/SurvivalBrush.java +++ b/src/main/java/de/eldoria/survivalbrush/SurvivalBrush.java @@ -6,18 +6,35 @@ package de.eldoria.survivalbrush; +import de.eldoria.eldoutilities.config.template.PluginBaseConfiguration; import de.eldoria.eldoutilities.plugin.EldoPlugin; +import de.eldoria.eldoutilities.updater.lynaupdater.LynaUpdateChecker; +import de.eldoria.eldoutilities.updater.lynaupdater.LynaUpdateData; import de.eldoria.survivalbrush.configuration.BlockSettings; -import de.eldoria.survivalbrush.configuration.Configuration; +import de.eldoria.survivalbrush.configuration.JacksonConfiguration; +import de.eldoria.survivalbrush.configuration.LegacyConfiguration; import de.eldoria.survivalbrush.listener.PasteListener; import org.bukkit.configuration.serialization.ConfigurationSerializable; import java.util.List; +import java.util.logging.Level; public class SurvivalBrush extends EldoPlugin { @Override public void onPluginEnable() throws Throwable { - var configuration = new Configuration(this); + var configuration = new JacksonConfiguration(this); + PluginBaseConfiguration base = configuration.secondary(PluginBaseConfiguration.KEY); + if (base.version() == 0) { + var legacyConfiguration = new LegacyConfiguration(this); + getLogger().log(Level.INFO, "Migrating configuration to jackson."); + configuration.main().blockSettings(legacyConfiguration.blockSettings()); + base.version(1); + base.lastInstalledVersion(this); + configuration.save(); + } + + LynaUpdateChecker.lyna(LynaUpdateData.builder(this, 7).build()).start(); + registerListener(new PasteListener(this, configuration)); } @@ -25,9 +42,4 @@ public void onPluginEnable() throws Throwable { public List> getConfigSerialization() { return List.of(BlockSettings.class); } - - @Override - public void onPluginDisable() throws Throwable { - super.onPluginDisable(); - } } diff --git a/src/main/java/de/eldoria/survivalbrush/configuration/BlockSettings.java b/src/main/java/de/eldoria/survivalbrush/configuration/BlockSettings.java index 76f0da8..8f8de5b 100644 --- a/src/main/java/de/eldoria/survivalbrush/configuration/BlockSettings.java +++ b/src/main/java/de/eldoria/survivalbrush/configuration/BlockSettings.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; +@SuppressWarnings("FieldMayBeFinal") public class BlockSettings implements ConfigurationSerializable { private static final List DEFAULT_BLACKLIST = List.of(Material.SHULKER_BOX, Material.WHITE_SHULKER_BOX, @@ -34,7 +35,7 @@ public class BlockSettings implements ConfigurationSerializable { Material.CHEST, Material.TRAPPED_CHEST, Material.FURNACE); - private final List pasteBlacklist; + private List pasteBlacklist; public BlockSettings() { pasteBlacklist = DEFAULT_BLACKLIST; diff --git a/src/main/java/de/eldoria/survivalbrush/configuration/ConfigFile.java b/src/main/java/de/eldoria/survivalbrush/configuration/ConfigFile.java new file mode 100644 index 0000000..0a53298 --- /dev/null +++ b/src/main/java/de/eldoria/survivalbrush/configuration/ConfigFile.java @@ -0,0 +1,20 @@ +/* + * SPDX-License-Identifier: AGPL-3.0-only + * + * Copyright (C) 2021 EldoriaRPG Team and Contributor + */ + +package de.eldoria.survivalbrush.configuration; + +@SuppressWarnings("FieldMayBeFinal") +public class ConfigFile { + private BlockSettings blockSettings = new BlockSettings(); + + public BlockSettings blockSettings() { + return blockSettings; + } + + public void blockSettings(BlockSettings blockSettings) { + this.blockSettings = blockSettings; + } +} diff --git a/src/main/java/de/eldoria/survivalbrush/configuration/Configuration.java b/src/main/java/de/eldoria/survivalbrush/configuration/Configuration.java index 548f090..3ffff99 100644 --- a/src/main/java/de/eldoria/survivalbrush/configuration/Configuration.java +++ b/src/main/java/de/eldoria/survivalbrush/configuration/Configuration.java @@ -6,27 +6,6 @@ package de.eldoria.survivalbrush.configuration; -import de.eldoria.eldoutilities.configuration.EldoConfig; -import org.bukkit.plugin.Plugin; - -public class Configuration extends EldoConfig { - private BlockSettings blockSettings; - - public Configuration(Plugin plugin) { - super(plugin); - } - - @Override - protected void reloadConfigs() { - blockSettings = getConfig().getObject("blockSettings", BlockSettings.class, new BlockSettings()); - } - - @Override - protected void saveConfigs() { - getConfig().set("blockSettings", blockSettings); - } - - public BlockSettings blockSettings() { - return blockSettings; - } +public interface Configuration { + BlockSettings blockSettings(); } diff --git a/src/main/java/de/eldoria/survivalbrush/configuration/JacksonConfiguration.java b/src/main/java/de/eldoria/survivalbrush/configuration/JacksonConfiguration.java new file mode 100644 index 0000000..a4ddedd --- /dev/null +++ b/src/main/java/de/eldoria/survivalbrush/configuration/JacksonConfiguration.java @@ -0,0 +1,24 @@ +/* + * SPDX-License-Identifier: AGPL-3.0-only + * + * Copyright (C) 2021 EldoriaRPG Team and Contributor + */ + +package de.eldoria.survivalbrush.configuration; + +import de.eldoria.eldoutilities.config.ConfigKey; +import de.eldoria.eldoutilities.config.JacksonConfig; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; + +public class JacksonConfiguration extends JacksonConfig implements Configuration { + public JacksonConfiguration(@NotNull Plugin plugin) { + super(plugin, ConfigKey.defaultConfig(ConfigFile.class, ConfigFile::new)); + } + + + @Override + public BlockSettings blockSettings() { + return main().blockSettings(); + } +} diff --git a/src/main/java/de/eldoria/survivalbrush/configuration/LegacyConfiguration.java b/src/main/java/de/eldoria/survivalbrush/configuration/LegacyConfiguration.java new file mode 100644 index 0000000..1be065f --- /dev/null +++ b/src/main/java/de/eldoria/survivalbrush/configuration/LegacyConfiguration.java @@ -0,0 +1,33 @@ +/* + * SPDX-License-Identifier: AGPL-3.0-only + * + * Copyright (C) 2021 EldoriaRPG Team and Contributor + */ + +package de.eldoria.survivalbrush.configuration; + +import de.eldoria.eldoutilities.configuration.EldoConfig; +import org.bukkit.plugin.Plugin; + +public class LegacyConfiguration extends EldoConfig implements Configuration { + private BlockSettings blockSettings; + + public LegacyConfiguration(Plugin plugin) { + super(plugin); + } + + @Override + protected void reloadConfigs() { + blockSettings = getConfig().getObject("blockSettings", BlockSettings.class, new BlockSettings()); + } + + @Override + protected void saveConfigs() { + getConfig().set("blockSettings", blockSettings); + } + + @Override + public BlockSettings blockSettings() { + return blockSettings; + } +} diff --git a/src/main/java/de/eldoria/survivalbrush/listener/PasteListener.java b/src/main/java/de/eldoria/survivalbrush/listener/PasteListener.java index ef15dc8..eb3ec67 100644 --- a/src/main/java/de/eldoria/survivalbrush/listener/PasteListener.java +++ b/src/main/java/de/eldoria/survivalbrush/listener/PasteListener.java @@ -11,6 +11,7 @@ import de.eldoria.eldoutilities.container.Pair; import de.eldoria.schematicbrush.event.PrePasteEvent; import de.eldoria.survivalbrush.configuration.Configuration; +import de.eldoria.survivalbrush.configuration.LegacyConfiguration; import de.eldoria.survivalbrush.util.Permissions; import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.text.minimessage.MiniMessage; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml deleted file mode 100644 index 978dd01..0000000 --- a/src/main/resources/plugin.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: SurvivalSchematicBrush -version: ${version} -api-version: 1.13 -author: Hadde -main: de.eldoria.survivalbrush.SurvivalBrush -depend: - - SchematicBrushReborn - -permissions: - survivalschematicbrush.paste.bypass: - default: false - description: Allow to bypass block pasting check when in survival - survivalschematicbrush.limit.bypass: - default: false - description: Allow to bypass max schematic size - survivalschematicbrush.limit.: - default: false - description: Set the max blocks a schematic can have