Skip to content

Commit

Permalink
Merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinDaGame committed May 15, 2023
1 parent 06709e0 commit 276ae69
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.kevindagame.voxelsniper.fileHandler;

import com.github.kevindagame.VoxelSniper;

import org.jetbrains.annotations.NotNull;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.LoaderOptions;
Expand All @@ -18,10 +17,18 @@
import java.util.HashMap;
import java.util.Map;

public class YamlConfiguration {
private final Map<String, Object> contents;
public class YamlConfiguration extends ConfigurationSection {

public YamlConfiguration(ClassLoader loader, String fileName) {
super(loadConfiguration(loader, fileName));
}

public YamlConfiguration(File file) {
super(loadConfiguration(file));
}

@NotNull
private static Map<String, Object> loadConfiguration(ClassLoader loader, String fileName) {
Map<String, Object> contents = null;
try (InputStream inputStream = loader.getResourceAsStream(fileName)) {
if (inputStream != null) {
Expand All @@ -31,20 +38,19 @@ public YamlConfiguration(ClassLoader loader, String fileName) {
}
} catch (IOException e) {
e.printStackTrace();
} finally {
this.contents = contents != null ? contents : new HashMap<>();
}
return contents != null ? contents : new HashMap<>();
}

public YamlConfiguration(File file) {
@NotNull
private static Map<String, Object> loadConfiguration(File file) {
Map<String, Object> contents = null;
try (InputStream inputStream = Files.newInputStream(file.toPath())) {
contents = getYaml().load(inputStream);
} catch (IOException e) {
e.printStackTrace();
} finally {
this.contents = contents != null ? contents : new HashMap<>();
}
return contents != null ? contents : new HashMap<>();
}

private static Yaml getYaml() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
import com.github.kevindagame.voxelsniperforge.permissions.ForgePermissionManager;
import com.google.common.base.Preconditions;

import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -53,14 +52,19 @@ public void sendMessage(String message) {
this.player.sendSystemMessage(net.minecraft.network.chat.Component.literal(message));
}

public static MutableComponent toNative(@NotNull Component component) {
if (component == Component.empty()) return net.minecraft.network.chat.Component.empty();
return net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serialize(component));
@Override
public void sendMessage(@NotNull Component message) {
this.player.sendSystemMessage(toNative(message));
}

@Override
public void sendMessage(@NotNull Identity source, @NotNull Component message, @NotNull MessageType type) {
this.player.sendSystemMessage(toNative(message));
public void sendMessage(@NotNull ComponentLike message) {
IPlayer.super.sendMessage(message);
}

public static MutableComponent toNative(@NotNull Component component) {
if (component == Component.empty()) return net.minecraft.network.chat.Component.empty();
return net.minecraft.network.chat.Component.Serializer.fromJson(GsonComponentSerializer.gson().serialize(component));
}

@Override
Expand Down
6 changes: 3 additions & 3 deletions VoxelSniperSpigot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ dependencies {
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.5") // newest worldguard that supports 1.16.5
compileOnly("com.plotsquared:PlotSquared-Core")

implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.20"))
implementation("org.bstats:bstats-bukkit:3.0.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
shadow(platform("com.intellectualsites.bom:bom-1.18.x:1.20"))
shadow("org.bstats:bstats-bukkit:3.0.0")
shadow("net.kyori:adventure-platform-bukkit:4.2.0")
implementation(kotlin("stdlib-jdk8"))

shadow("org.bstats:bstats-bukkit:3.0.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/**
* @author Voxel
*/
public class VoxelSniperListener implements Listener {
public class SpigotVoxelSniperListener implements Listener {

private static final String SNIPER_PERMISSION = "voxelsniper.sniper";
private final SpigotVoxelSniper plugin;
Expand All @@ -32,7 +32,7 @@ public class VoxelSniperListener implements Listener {
/**
* @param plugin The plugin
*/
public VoxelSniperListener(final SpigotVoxelSniper plugin) {
public SpigotVoxelSniperListener(final SpigotVoxelSniper plugin) {
this.plugin = plugin;
}

Expand Down
25 changes: 19 additions & 6 deletions buildSrc/src/main/kotlin/voxel-core.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
`java-library`
Expand All @@ -25,23 +26,34 @@ repositories {
}
}

val shadowNoRuntime by configurations.creating {
extendsFrom(configurations.shadow.get())
}

dependencies {
compileOnly("org.jetbrains:annotations-java5:23.0.0")
compileOnly("com.google.guava:guava:31.1-jre")
compileOnly("com.google.code.gson:gson:2.10.1")

implementation("net.kyori:adventure-api:4.13.1")
implementation("net.kyori:adventure-text-minimessage:4.13.1")
implementation("net.kyori:adventure-text-serializer-legacy:4.13.1")
shadow("net.kyori:adventure-api:4.13.1")
shadow("net.kyori:adventure-text-minimessage:4.13.1")
shadow("net.kyori:adventure-text-serializer-legacy:4.13.1")

implementation(kotlin("stdlib-jdk8"))
implementation("com.google.guava:guava:31.1-jre")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.yaml:snakeyaml:1.33")
shadowNoRuntime("com.google.guava:guava:31.1-jre")
shadowNoRuntime("com.google.code.gson:gson:2.10.1")
shadow("org.yaml:snakeyaml:1.33")

testImplementation("com.google.guava:guava:31.1-jre")
testImplementation("com.google.code.gson:gson:2.10.1")
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:4.5.1")
testImplementation("org.mockito:mockito-inline:4.5.1")
}

configurations.testImplementation.extendsFrom(shadowNoRuntime)
configurations.runtimeClasspath.extendsFrom(configurations.shadow.get())

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
Expand Down Expand Up @@ -71,6 +83,7 @@ tasks {
}

shadowJar {
configurations = listOf(shadowNoRuntime)
minimize()
relocate("com.google", "com.github.kevindagame.voxelsniper.libs.com.google")
relocate("net.kyori", "com.github.kevindagame.voxelsniper.libs.net.kyori")
Expand Down

0 comments on commit 276ae69

Please sign in to comment.