From 5f37e63b0f1c122ba3e68283ac09c95de0d1b738 Mon Sep 17 00:00:00 2001 From: Paldiu Date: Mon, 1 Mar 2021 22:56:13 -0600 Subject: [PATCH] BLEEDING EDGE v1.3_06 --- .../io/github/simplexdev/api/IStructure.java | 4 +++ .../simplexcore/ban/BanFactory.java | 33 ++++++++++++++++++- .../simplexcore/config/YamlFactory.java | 6 ++++ .../simplexcore/utils/Utilities.java | 5 +++ .../simplexdev/simplexcore/utils/Wrapper.java | 11 +++++-- 5 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/simplexdev/api/IStructure.java b/src/main/java/io/github/simplexdev/api/IStructure.java index b483ccb..663fa90 100644 --- a/src/main/java/io/github/simplexdev/api/IStructure.java +++ b/src/main/java/io/github/simplexdev/api/IStructure.java @@ -6,6 +6,8 @@ import org.bukkit.NamespacedKey; import org.bukkit.World; import org.bukkit.block.Block; +import java.io.File; + public interface IStructure { NamespacedKey getNamespacedKey(); @@ -26,4 +28,6 @@ public interface IStructure { Size getApproximateSize(); Block[] getBlocks(); + + File getStructureFile(); } diff --git a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java index 0963457..dd52756 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/ban/BanFactory.java @@ -1,16 +1,20 @@ package io.github.simplexdev.simplexcore.ban; import io.github.simplexdev.api.IBan; -import io.github.simplexdev.simplexcore.chat.Messages; import io.github.simplexdev.api.func.VoidSupplier; +import io.github.simplexdev.simplexcore.chat.Messages; +import io.github.simplexdev.simplexcore.config.Yaml; import io.github.simplexdev.simplexcore.utils.Constants; import io.github.simplexdev.simplexcore.utils.Utilities; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import java.io.File; import java.util.Date; import java.util.UUID; +import static io.github.simplexdev.simplexcore.utils.Utilities.pathway; + public final class BanFactory { private final Player player; private final CommandSender sender; @@ -44,6 +48,21 @@ public final class BanFactory { return this; } + public void write(Yaml yaml, IBan ban) { + yaml.set(pathway("offender"), ban.getOffender()); + yaml.set(pathway("sender"), ban.getSender()); + yaml.set(pathway("duration"), ban.getBanDuration()); + yaml.set(pathway("date"), ban.getDate()); + yaml.set(pathway("type"), ban.getBanType()); + yaml.set(pathway("id"), ban.getBanId()); + yaml.set(pathway("reason"), ban.getBanReason()); + yaml.create(); + } + + public Yaml read(File yamlFile) { + return null; + } + /** * Creates a new instance of the abstract class Ban. * @@ -92,6 +111,18 @@ public final class BanFactory { } + public IBan getBan(String banId) { + return null; + } + + public IBan getBan(Player player) { + return null; + } + + public IBan getBan(UUID offenderUUID) { + return null; + } + private VoidSupplier assignBanDuration() { return () -> { if (type.equals(BanType.PERMANENT)) { diff --git a/src/main/java/io/github/simplexdev/simplexcore/config/YamlFactory.java b/src/main/java/io/github/simplexdev/simplexcore/config/YamlFactory.java index 8e96a4c..259d06a 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/config/YamlFactory.java +++ b/src/main/java/io/github/simplexdev/simplexcore/config/YamlFactory.java @@ -2,6 +2,8 @@ package io.github.simplexdev.simplexcore.config; import io.github.simplexdev.simplexcore.plugin.SimplexAddon; import io.github.simplexdev.simplexcore.utils.Trio; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.configuration.file.YamlConfiguration; import java.io.File; @@ -22,6 +24,10 @@ public final class YamlFactory { return new Yaml(plugin, resourcePath, directory, fileName); } + public FileConfiguration load(File yamlFile) { + return YamlConfiguration.loadConfiguration(yamlFile); + } + public Yaml setDefaultPathways() { return from("config.yml", plugin.getDataFolder(), "config.yml"); } diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java b/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java index 5f140c8..824dbd5 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java +++ b/src/main/java/io/github/simplexdev/simplexcore/utils/Utilities.java @@ -1,5 +1,6 @@ package io.github.simplexdev.simplexcore.utils; +import io.github.simplexdev.api.func.Path; import io.github.simplexdev.simplexcore.ban.BanType; import java.util.ArrayList; @@ -68,4 +69,8 @@ public final class Utilities { String temp = String.valueOf(character).toUpperCase(); return temp.charAt(0); } + + public static Path pathway(String pathway) { + return () -> pathway; + } } \ No newline at end of file diff --git a/src/main/java/io/github/simplexdev/simplexcore/utils/Wrapper.java b/src/main/java/io/github/simplexdev/simplexcore/utils/Wrapper.java index 25cd046..5e10baa 100644 --- a/src/main/java/io/github/simplexdev/simplexcore/utils/Wrapper.java +++ b/src/main/java/io/github/simplexdev/simplexcore/utils/Wrapper.java @@ -1,11 +1,11 @@ package io.github.simplexdev.simplexcore.utils; +import io.github.simplexdev.api.func.VoidSupplier; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import java.util.function.Consumer; import java.util.function.Function; -import java.util.function.Predicate; public final class Wrapper { protected T bean; @@ -61,8 +61,13 @@ public final class Wrapper { return new Wrapper<>(function.apply(get())); } - public final Wrapper filter(Consumer predicate) { - predicate.accept(get()); + public final Wrapper filter(Consumer consumer) { + consumer.accept(get()); + return this; + } + + public final Wrapper then(VoidSupplier supplier) { + supplier.get(); return this; } }