diff --git a/src/main/java/su/nightexpress/nightcore/command/CommandFlag.java b/src/main/java/su/nightexpress/nightcore/command/CommandFlag.java index 438c696..cac45fb 100644 --- a/src/main/java/su/nightexpress/nightcore/command/CommandFlag.java +++ b/src/main/java/su/nightexpress/nightcore/command/CommandFlag.java @@ -8,6 +8,7 @@ import su.nightexpress.nightcore.util.NumberUtil; import java.util.function.Function; +@Deprecated public class CommandFlag { public static final char PREFIX = '-'; diff --git a/src/main/java/su/nightexpress/nightcore/command/CommandResult.java b/src/main/java/su/nightexpress/nightcore/command/CommandResult.java index 1ca9a29..81c6c79 100644 --- a/src/main/java/su/nightexpress/nightcore/command/CommandResult.java +++ b/src/main/java/su/nightexpress/nightcore/command/CommandResult.java @@ -7,6 +7,7 @@ import su.nightexpress.nightcore.util.NumberUtil; import java.util.HashMap; import java.util.Map; +@Deprecated public class CommandResult { private final String label; diff --git a/src/main/java/su/nightexpress/nightcore/command/api/NightCommand.java b/src/main/java/su/nightexpress/nightcore/command/api/NightCommand.java index 279283e..78b74ae 100644 --- a/src/main/java/su/nightexpress/nightcore/command/api/NightCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/api/NightCommand.java @@ -12,6 +12,7 @@ import su.nightexpress.nightcore.util.placeholder.Placeholder; import java.util.Collection; import java.util.List; +@Deprecated public interface NightCommand extends Placeholder { @NotNull List getTab(@NotNull Player player, int arg, @NotNull String[] args); diff --git a/src/main/java/su/nightexpress/nightcore/command/api/NightPluginCommand.java b/src/main/java/su/nightexpress/nightcore/command/api/NightPluginCommand.java index 5be56f6..b502f48 100644 --- a/src/main/java/su/nightexpress/nightcore/command/api/NightPluginCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/api/NightPluginCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.TabExecutor; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +@Deprecated public interface NightPluginCommand extends NightCommand, TabExecutor { @Nullable NightCommand getDefaultCommand(); diff --git a/src/main/java/su/nightexpress/nightcore/command/base/HelpSubCommand.java b/src/main/java/su/nightexpress/nightcore/command/base/HelpSubCommand.java index 6e8656b..98cecc8 100644 --- a/src/main/java/su/nightexpress/nightcore/command/base/HelpSubCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/base/HelpSubCommand.java @@ -13,6 +13,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.Set; +@Deprecated public class HelpSubCommand extends AbstractCommand { public HelpSubCommand(@NotNull NightCorePlugin plugin) { diff --git a/src/main/java/su/nightexpress/nightcore/command/base/ReloadSubCommand.java b/src/main/java/su/nightexpress/nightcore/command/base/ReloadSubCommand.java index f84d3f8..1b8a43f 100644 --- a/src/main/java/su/nightexpress/nightcore/command/base/ReloadSubCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/base/ReloadSubCommand.java @@ -8,6 +8,7 @@ import su.nightexpress.nightcore.command.CommandResult; import su.nightexpress.nightcore.command.impl.AbstractCommand; import su.nightexpress.nightcore.core.CoreLang; +@Deprecated public class ReloadSubCommand extends AbstractCommand { public ReloadSubCommand(@NotNull NightCorePlugin plugin, @NotNull Permission permission) { diff --git a/src/main/java/su/nightexpress/nightcore/command/impl/AbstractCommand.java b/src/main/java/su/nightexpress/nightcore/command/impl/AbstractCommand.java index b7c5eca..bd51bf1 100644 --- a/src/main/java/su/nightexpress/nightcore/command/impl/AbstractCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/impl/AbstractCommand.java @@ -17,6 +17,7 @@ import su.nightexpress.nightcore.util.placeholder.PlaceholderMap; import java.util.*; import java.util.stream.Stream; +@Deprecated public abstract class AbstractCommand

implements NightCommand { protected final P plugin; diff --git a/src/main/java/su/nightexpress/nightcore/command/impl/BaseCommand.java b/src/main/java/su/nightexpress/nightcore/command/impl/BaseCommand.java index 131ecb7..244a897 100644 --- a/src/main/java/su/nightexpress/nightcore/command/impl/BaseCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/impl/BaseCommand.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import su.nightexpress.nightcore.NightCorePlugin; import su.nightexpress.nightcore.command.CommandResult; +@Deprecated public class BaseCommand extends PluginCommand { public BaseCommand(@NotNull NightCorePlugin plugin) { diff --git a/src/main/java/su/nightexpress/nightcore/command/impl/PluginCommand.java b/src/main/java/su/nightexpress/nightcore/command/impl/PluginCommand.java index 26ea59d..2f1bdc9 100644 --- a/src/main/java/su/nightexpress/nightcore/command/impl/PluginCommand.java +++ b/src/main/java/su/nightexpress/nightcore/command/impl/PluginCommand.java @@ -16,6 +16,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +@Deprecated public abstract class PluginCommand

extends AbstractCommand

implements NightPluginCommand { private Command backend; diff --git a/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java b/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java index 7977177..84e14f9 100644 --- a/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java +++ b/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java @@ -11,6 +11,7 @@ import su.nightexpress.nightcore.util.wrapper.UniSound; import java.util.*; import java.util.function.Function; import java.util.function.Supplier; +import java.util.function.UnaryOperator; import java.util.stream.Collectors; public class ConfigValue { @@ -22,6 +23,7 @@ public class ConfigValue { private final Writer writer; private T value; + private UnaryOperator onRead; public ConfigValue(@NotNull String path, @NotNull Reader reader, @@ -246,22 +248,31 @@ public class ConfigValue { } @NotNull - public T read(@NotNull FileConfig cfg) { - if (!cfg.contains(this.getPath())) { - this.write(cfg); + public ConfigValue onRead(@NotNull UnaryOperator onRead) { + this.onRead = onRead; + return this; + } + + @NotNull + public T read(@NotNull FileConfig config) { + if (!config.contains(this.getPath())) { + this.write(config); } if (this.getDescription().length > 0 && !this.getDescription()[0].isEmpty()) { - cfg.setComments(this.getPath(), this.getDescription()); + config.setComments(this.getPath(), this.getDescription()); } - return (this.value = this.reader.read(cfg, this.getPath(), this.getDefaultValue())); + + UnaryOperator operator = this.onRead == null ? value -> value : this.onRead; + + return (this.value = operator.apply(this.reader.read(config, this.getPath(), this.getDefaultValue()))); } - public void write(@NotNull FileConfig cfg) { - this.getWriter().write(cfg, this.getPath(), this.get()); + public void write(@NotNull FileConfig config) { + this.getWriter().write(config, this.getPath(), this.get()); } - public boolean remove(@NotNull FileConfig cfg) { - return cfg.remove(this.getPath()); + public boolean remove(@NotNull FileConfig config) { + return config.remove(this.getPath()); } @NotNull @@ -300,11 +311,11 @@ public class ConfigValue { public interface Reader { - @NotNull T read(@NotNull FileConfig cfg, @NotNull String path, @NotNull T def); + @NotNull T read(@NotNull FileConfig config, @NotNull String path, @NotNull T def); } public interface Writer { - void write(@NotNull FileConfig cfg, @NotNull String path, @NotNull T obj); + void write(@NotNull FileConfig config, @NotNull String path, @NotNull T obj); } } diff --git a/src/main/java/su/nightexpress/nightcore/util/Colorizer.java b/src/main/java/su/nightexpress/nightcore/util/Colorizer.java index 3a8c282..2bd8207 100644 --- a/src/main/java/su/nightexpress/nightcore/util/Colorizer.java +++ b/src/main/java/su/nightexpress/nightcore/util/Colorizer.java @@ -13,9 +13,9 @@ import java.util.stream.Collectors; public class Colorizer { - public static final Pattern PATTERN_HEX = Pattern.compile("#([A-Fa-f0-9]{6})"); + @Deprecated public static final Pattern PATTERN_HEX = Pattern.compile("#([A-Fa-f0-9]{6})"); //public static final Pattern PATTERN_HEX_LEGACY = Pattern.compile("(?:^|[^<])(#[A-Fa-f0-9]{6})(?:$|[^:>])"); - public static final Pattern PATTERN_GRADIENT = Pattern.compile("(.*?)"); + @Deprecated public static final Pattern PATTERN_GRADIENT = Pattern.compile("(.*?)"); @NotNull public static String apply(@NotNull String str) { @@ -44,6 +44,7 @@ public class Colorizer { } @NotNull + @Deprecated public static String hex(@NotNull String str) { TimedMatcher timedMatcher = TimedMatcher.create(PATTERN_HEX, str); //Matcher matcher = PATTERN_HEX.matcher(str); @@ -60,6 +61,7 @@ public class Colorizer { return timedMatcher.getMatcher().appendTail(buffer).toString(); } + @Deprecated private static ChatColor[] createGradient(@NotNull java.awt.Color start, @NotNull java.awt.Color end, int length) { ChatColor[] colors = new ChatColor[length]; for (int index = 0; index < length; index++) { @@ -76,6 +78,7 @@ public class Colorizer { } @NotNull + @Deprecated public static String gradient(@NotNull String string) { TimedMatcher timedMatcher = TimedMatcher.create(PATTERN_GRADIENT, string); //Matcher matcher = PATTERN_GRADIENT.matcher(string); @@ -126,6 +129,7 @@ public class Colorizer { } @NotNull + @Deprecated public static String plainHex(@NotNull String str) { StringBuilder builder = new StringBuilder(str); diff --git a/src/main/java/su/nightexpress/nightcore/util/Lists.java b/src/main/java/su/nightexpress/nightcore/util/Lists.java index 8dd0bb4..e9f6579 100644 --- a/src/main/java/su/nightexpress/nightcore/util/Lists.java +++ b/src/main/java/su/nightexpress/nightcore/util/Lists.java @@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; +import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -63,6 +64,16 @@ public class Lists { return indexOf(array, valueToFind) != -1; } + @NotNull + public static Set modify(@NotNull Set set, @NotNull Function function) { + return set.stream().map(function).collect(Collectors.toCollection(HashSet::new)); + } + + @NotNull + public static List modify(@NotNull List set, @NotNull Function function) { + return set.stream().map(function).collect(Collectors.toCollection(ArrayList::new)); + } + @NotNull public static List> split(@NotNull List list, int targetSize) { List> lists = new ArrayList<>();