- *
- * @param the command sender type
- */
-public class ArcCommandManager extends CommandManager implements PluginAware {
-
- /**
- * The owning plugin of the command.
- */
- public static final CommandMeta.Key PLUGIN = CommandMeta.Key.of(String.class, "distributor-core:plugin");
-
- private final MindustryPlugin plugin;
- private final Function commandSenderMapper;
- private final Function backwardsCommandSenderMapper;
-
- private @MonotonicNonNull CommandHandler handler;
-
- /**
- * Creates a new {@link ArcCommandManager}.
- *
- * @param plugin the owning plugin
- * @param commandSenderMapper the function that will convert the {@link CommandSender} to the command sender type of
- * your choice
- * @param backwardsCommandSenderMapper the function that will convert your command sender
- * type to {@link CommandSender}
- * @param async whether the command manager should execute commands asynchronously
- */
- public ArcCommandManager(
- final MindustryPlugin plugin,
- final Function commandSenderMapper,
- final Function backwardsCommandSenderMapper,
- final boolean async) {
- super(
- async
- ? AsynchronousCommandExecutionCoordinator.builder()
- .withAsynchronousParsing()
- .withExecutor(runnable -> DistributorProvider.get()
- .getPluginScheduler()
- .scheduleAsync(plugin)
- .execute(runnable))
- .build()
- : CommandExecutionCoordinator.simpleCoordinator(),
- CommandRegistrationHandler.nullCommandRegistrationHandler());
-
- this.plugin = plugin;
- this.commandSenderMapper = commandSenderMapper;
- this.backwardsCommandSenderMapper = backwardsCommandSenderMapper;
-
- this.registerCapability(CloudCapability.StandardCapabilities.ROOT_COMMAND_DELETION);
-
- this.captionRegistry((caption, sender) -> {
- final var source = DistributorProvider.get().getGlobalLocalizationSource();
- final var locale =
- this.getBackwardsCommandSenderMapper().apply(sender).getLocale();
- final var format = source.localize(caption.getKey(), locale);
- return format != null ? format.toPattern() : "???" + caption.getKey() + "???";
- });
-
- this.captionVariableReplacementHandler((format, variables) -> {
- final var arguments = new Object[variables.length];
- for (int i = 0; i < variables.length; i++) {
- arguments[i] = variables[i].getValue();
- }
- try {
- return MessageFormat.format(format, arguments);
- } catch (final IllegalArgumentException e) {
- this.plugin.getLogger().error("Failed to format {}.", format, e);
- return "???" + format + "???";
- }
- });
-
- this.parserRegistry()
- .registerAnnotationMapper(
- AllTeams.class,
- (annotation, typeToken) ->
- ParserParameters.single(ArcParserParameters.TEAM_MODE, TeamMode.ALL));
-
- this.parserRegistry()
- .registerParserSupplier(TypeToken.get(Player.class), params -> new PlayerArgument.PlayerParser<>());
-
- this.parserRegistry()
- .registerParserSupplier(
- TypeToken.get(Administration.PlayerInfo.class),
- params -> new PlayerInfoArgument.PlayerInfoParser<>());
-
- this.parserRegistry()
- .registerParserSupplier(
- TypeToken.get(Team.class),
- params -> new TeamArgument.TeamParser<>(
- params.get(ArcParserParameters.TEAM_MODE, TeamMode.BASE)));
- }
-
- /**
- * Creates a simple {@link ArcCommandManager} with {@link CommandSender} as the command sender type.
- */
- public static ArcCommandManager standard(final MindustryPlugin plugin) {
- return new ArcCommandManager<>(plugin, Function.identity(), Function.identity(), false);
- }
-
- /**
- * Creates a simple async {@link ArcCommandManager} with {@link CommandSender} as the command sender type.
- */
- public static ArcCommandManager standardAsync(final MindustryPlugin plugin) {
- return new ArcCommandManager<>(plugin, Function.identity(), Function.identity(), true);
- }
-
- /**
- * Creates a simple {@link ArcCommandManager} with {@link Player} as the command sender type.
- *
- * Warning: this will crash the server if it used with the console command handler.
- */
- public static ArcCommandManager player(final MindustryPlugin plugin) {
- return new ArcCommandManager<>(plugin, CommandSender::getPlayer, CommandSender::player, false);
- }
-
- /**
- * Creates a simple async {@link ArcCommandManager} with {@link Player} as the command sender type.
- *
- * Warning: this will crash the server if it used with the console command handler.
- */
- public static ArcCommandManager playerAsync(final MindustryPlugin plugin) {
- return new ArcCommandManager<>(plugin, CommandSender::getPlayer, CommandSender::player, true);
- }
-
- /**
- * Initializes the command manager with it's backing command handler.
- *
- * @param handler the backing command handler
- */
- public final void initialize(final CommandHandler handler) {
- this.commandRegistrationHandler(new ArcRegistrationHandler<>(this, handler));
- this.transitionOrThrow(RegistrationState.BEFORE_REGISTRATION, RegistrationState.REGISTERING);
- this.handler = handler;
- this.parameterInjectorRegistry()
- .registerInjector(CommandHandler.class, (ctx, annotation) -> ArcCommandManager.this.handler);
- }
-
- /**
- * Returns the command sender mapper of this command manager.
- */
- public final Function getCommandSenderMapper() {
- return this.commandSenderMapper;
- }
-
- /**
- * Returns the backwards command sender mapper of this command manager.
- */
- public final Function getBackwardsCommandSenderMapper() {
- return this.backwardsCommandSenderMapper;
- }
-
- /**
- * A shortcut method for creating an AnnotationParser.
- *
- * @param type the type token of the command sender
- * @return the created annotation parser
- */
- public AnnotationParser createAnnotationParser(final TypeToken type) {
- return new AnnotationParser<>(this, type, params -> {
- final var builder = CommandMeta.simple().with(this.createDefaultCommandMeta());
- if (params.has(StandardParameters.DESCRIPTION)) {
- builder.with(CommandMeta.DESCRIPTION, params.get(StandardParameters.DESCRIPTION, ""));
- }
- return builder.build();
- });
- }
-
- /**
- * A shortcut method for creating an AnnotationParser.
- *
- * @param type the type of the command sender
- * @return the created annotation parser
- */
- public final AnnotationParser createAnnotationParser(final Class type) {
- return this.createAnnotationParser(TypeToken.get(type));
- }
-
- /**
- * A shortcut method for creating recipe commands, with steps executing synchronously or asynchronously.
- *
- * @param value the initial value of the recipe, usually a {@link cloud.commandframework.context.CommandContext
- * command context}
- * @return the created recipe
- * @deprecated see {@link fr.xpdustry.distributor.api.scheduler.PluginScheduler#recipe(MindustryPlugin, Object)}
- */
- @SuppressWarnings("removal")
- @Deprecated
- public final PluginTaskRecipe recipe(final V value) {
- return DistributorProvider.get().getPluginScheduler().recipe(this.plugin, value);
- }
-
- @SuppressWarnings("NullableProblems")
- @Override
- public boolean hasPermission(final C sender, final String permission) {
- if (permission.isEmpty()) {
- return true;
- }
- final var caller = this.backwardsCommandSenderMapper.apply(sender);
- if (caller.isConsole()) {
- return true;
- }
- return DistributorProvider.get()
- .getPermissionService()
- .getPlayerPermission(MUUID.of(caller.getPlayer()), permission)
- .asBoolean();
- }
-
- @Override
- public CommandMeta createDefaultCommandMeta() {
- return CommandMeta.simple()
- .with(PLUGIN, this.plugin.getDescriptor().getName())
- .build();
- }
-
- @Override
- public final MindustryPlugin getPlugin() {
- return this.plugin;
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/ArcParserParameters.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/ArcParserParameters.java
deleted file mode 100644
index 362b00dc..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/ArcParserParameters.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command;
-
-import cloud.commandframework.arguments.parser.ParserParameter;
-import fr.xpdustry.distributor.api.command.argument.TeamArgument.TeamMode;
-import io.leangen.geantyref.TypeToken;
-
-/**
- * A collection of {@link ParserParameter} used by Distributor to resolve Mindustry types in the
- * {@link cloud.commandframework.arguments.parser.ParserRegistry}.
- */
-public final class ArcParserParameters {
-
- /**
- * Whether a {@link mindustry.game.Team} argument should include all the teams or only the base ones.
- */
- public static final ParserParameter TEAM_MODE =
- new ParserParameter<>("team_mode", TypeToken.get(TeamMode.class));
-
- private ArcParserParameters() {}
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerArgument.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerArgument.java
deleted file mode 100644
index 40a23f85..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerArgument.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.argument;
-
-import cloud.commandframework.ArgumentDescription;
-import cloud.commandframework.arguments.CommandArgument;
-import cloud.commandframework.arguments.parser.ArgumentParseResult;
-import cloud.commandframework.arguments.parser.ArgumentParser;
-import cloud.commandframework.captions.Caption;
-import cloud.commandframework.captions.CaptionVariable;
-import cloud.commandframework.context.CommandContext;
-import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
-import cloud.commandframework.exceptions.parsing.ParserException;
-import fr.xpdustry.distributor.api.command.ArcCaptionKeys;
-import fr.xpdustry.distributor.api.util.Players;
-import java.io.Serial;
-import java.util.List;
-import java.util.Queue;
-import java.util.function.BiFunction;
-import mindustry.gen.Player;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * A command argument for an online {@link Player}.
- *
- * @param the command sender type
- */
-public final class PlayerArgument extends CommandArgument {
-
- private PlayerArgument(
- final boolean required,
- final String name,
- final String defaultValue,
- final @Nullable BiFunction, String, List> suggestionsProvider,
- final ArgumentDescription defaultDescription) {
- super(
- required,
- name,
- new PlayerParser<>(),
- defaultValue,
- Player.class,
- suggestionsProvider,
- defaultDescription);
- }
-
- /**
- * Creates a new {@link Builder}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static Builder builder(final String name) {
- return new Builder<>(name);
- }
-
- /**
- * Creates a new required {@link PlayerArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static PlayerArgument of(final String name) {
- return PlayerArgument.builder(name).asRequired().build();
- }
-
- /**
- * Creates a new optional {@link PlayerArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static PlayerArgument optional(final String name) {
- return PlayerArgument.builder(name).asOptional().build();
- }
-
- /**
- * The internal builder class of {@link PlayerArgument}.
- *
- * @param the command sender type
- */
- public static final class Builder extends CommandArgument.TypedBuilder> {
-
- private Builder(final String name) {
- super(Player.class, name);
- }
-
- /**
- * Construct a new {@link PlayerArgument}.
- *
- * @return the constructed player argument
- */
- @Override
- public PlayerArgument build() {
- return new PlayerArgument<>(
- this.isRequired(),
- this.getName(),
- this.getDefaultValue(),
- this.getSuggestionsProvider(),
- this.getDefaultDescription());
- }
- }
-
- /**
- * An argument parser that outputs an online {@link Player} in the current server.
- *
- * @param the command sender type
- */
- public static final class PlayerParser implements ArgumentParser {
-
- @Override
- public ArgumentParseResult parse(final CommandContext ctx, final Queue inputQueue) {
- final var input = inputQueue.peek();
- if (input == null) {
- return ArgumentParseResult.failure(new NoInputProvidedException(PlayerParser.class, ctx));
- }
-
- final var players = Players.findPlayers(input, true);
-
- if (players.isEmpty()) {
- return ArgumentParseResult.failure(new PlayerNotFoundException(input, ctx));
- } else if (players.size() > 1) {
- return ArgumentParseResult.failure(new TooManyPlayersFoundException(input, ctx));
- } else {
- inputQueue.remove();
- return ArgumentParseResult.success(players.get(0));
- }
- }
-
- @Override
- public List suggestions(final CommandContext commandContext, final String input) {
- return Players.findPlayers(input, true).stream()
- .map(Player::plainName)
- .toList();
- }
-
- @Override
- public boolean isContextFree() {
- return true;
- }
- }
-
- /**
- * An exception thrown when a parsing error occurs while searching for a player.
- */
- public static class PlayerParseException extends ParserException {
-
- @Serial
- private static final long serialVersionUID = 3264229396134848993L;
-
- private final String input;
-
- /**
- * Creates a new {@link PlayerParseException}.
- *
- * @param input the input string
- * @param ctx the command context
- * @param caption the error caption of this exception
- */
- public PlayerParseException(final String input, final CommandContext> ctx, final Caption caption) {
- super(PlayerParser.class, ctx, caption, CaptionVariable.of("input", input));
- this.input = input;
- }
-
- /**
- * Returns the input string.
- */
- public final String getInput() {
- return this.input;
- }
- }
-
- /**
- * An exception thrown when too many players are found for the given input.
- */
- public static final class TooManyPlayersFoundException extends PlayerParseException {
-
- @Serial
- private static final long serialVersionUID = 2964533701700707264L;
-
- /**
- * Creates a new {@link TooManyPlayersFoundException}.
- *
- * @param input the input string
- * @param ctx the command context
- */
- public TooManyPlayersFoundException(final String input, final CommandContext> ctx) {
- super(input, ctx, ArcCaptionKeys.ARGUMENT_PARSE_FAILURE_PLAYER_TOO_MANY);
- }
- }
-
- /**
- * An exception thrown when no player was found for the given input.
- */
- public static final class PlayerNotFoundException extends PlayerParseException {
-
- @Serial
- private static final long serialVersionUID = 4683487234146844501L;
-
- /**
- * Creates a new {@link PlayerNotFoundException}.
- *
- * @param input the input string
- * @param ctx the command context
- */
- public PlayerNotFoundException(final String input, final CommandContext> ctx) {
- super(input, ctx, ArcCaptionKeys.ARGUMENT_PARSE_FAILURE_PLAYER_NOT_FOUND);
- }
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerInfoArgument.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerInfoArgument.java
deleted file mode 100644
index 0235445f..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/PlayerInfoArgument.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.argument;
-
-import cloud.commandframework.ArgumentDescription;
-import cloud.commandframework.arguments.CommandArgument;
-import cloud.commandframework.arguments.parser.ArgumentParseResult;
-import cloud.commandframework.arguments.parser.ArgumentParser;
-import cloud.commandframework.context.CommandContext;
-import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
-import fr.xpdustry.distributor.api.command.argument.PlayerArgument.PlayerNotFoundException;
-import fr.xpdustry.distributor.api.command.argument.PlayerArgument.TooManyPlayersFoundException;
-import fr.xpdustry.distributor.api.util.MUUID;
-import fr.xpdustry.distributor.api.util.Players;
-import java.util.List;
-import java.util.Queue;
-import java.util.function.BiFunction;
-import mindustry.Vars;
-import mindustry.gen.Player;
-import mindustry.net.Administration.PlayerInfo;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * A command argument for an offline player, always guaranteed to return if an uuid is provided.
- * Can also search in online players.
- *
- * @param the command sender type
- */
-public final class PlayerInfoArgument extends CommandArgument {
-
- public PlayerInfoArgument(
- final boolean required,
- final String name,
- final String defaultValue,
- final @Nullable BiFunction, String, List> suggestionsProvider,
- final ArgumentDescription defaultDescription) {
- super(
- required,
- name,
- new PlayerInfoParser<>(),
- defaultValue,
- PlayerInfo.class,
- suggestionsProvider,
- defaultDescription);
- }
-
- /**
- * Creates a new {@link Builder}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static Builder builder(final String name) {
- return new Builder<>(name);
- }
-
- /**
- * Creates a new required {@link PlayerInfoArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created argument
- */
- public static PlayerInfoArgument of(final String name) {
- return PlayerInfoArgument.builder(name).asRequired().build();
- }
-
- /**
- * Creates a new optional {@link PlayerInfoArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created argument
- */
- public static PlayerInfoArgument optional(final String name) {
- return PlayerInfoArgument.builder(name).asOptional().build();
- }
-
- /**
- * The internal builder class of {@link PlayerInfoArgument}.
- *
- * @param the command sender type
- */
- public static final class Builder extends CommandArgument.TypedBuilder> {
-
- private Builder(final String name) {
- super(PlayerInfo.class, name);
- }
-
- /**
- * Construct a new {@link PlayerInfoArgument}.
- *
- * @return the constructed argument
- */
- @Override
- public PlayerInfoArgument build() {
- return new PlayerInfoArgument<>(
- this.isRequired(),
- this.getName(),
- this.getDefaultValue(),
- this.getSuggestionsProvider(),
- this.getDefaultDescription());
- }
- }
-
- /**
- * An argument parser that outputs a {@link PlayerInfo} from an online {@link Player} or an offline player in
- * this server.
- *
- * @param the command sender type
- */
- public static final class PlayerInfoParser implements ArgumentParser {
-
- @Override
- public ArgumentParseResult parse(final CommandContext ctx, final Queue inputQueue) {
- final var input = inputQueue.peek();
- if (input == null) {
- return ArgumentParseResult.failure(new NoInputProvidedException(PlayerInfoParser.class, ctx));
- }
-
- if (MUUID.isUuid(input)) {
- inputQueue.remove();
- return ArgumentParseResult.success(Vars.netServer.admins.getInfo(input));
- }
-
- final var players = Players.findPlayers(input);
-
- if (players.isEmpty()) {
- return ArgumentParseResult.failure(new PlayerNotFoundException(input, ctx));
- } else if (players.size() > 1) {
- return ArgumentParseResult.failure(new TooManyPlayersFoundException(input, ctx));
- } else {
- inputQueue.remove();
- return ArgumentParseResult.success(players.get(0).getInfo());
- }
- }
-
- @Override
- public List suggestions(final CommandContext commandContext, final String input) {
- return Players.findPlayers(input, true).stream()
- .map(Player::plainName)
- .toList();
- }
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/TeamArgument.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/TeamArgument.java
deleted file mode 100644
index adc22225..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/argument/TeamArgument.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.argument;
-
-import cloud.commandframework.ArgumentDescription;
-import cloud.commandframework.arguments.CommandArgument;
-import cloud.commandframework.arguments.parser.ArgumentParseResult;
-import cloud.commandframework.arguments.parser.ArgumentParser;
-import cloud.commandframework.captions.CaptionVariable;
-import cloud.commandframework.context.CommandContext;
-import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
-import cloud.commandframework.exceptions.parsing.ParserException;
-import fr.xpdustry.distributor.api.command.ArcCaptionKeys;
-import java.io.Serial;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Queue;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import mindustry.game.Team;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * A command argument for a {@link Team}.
- *
- * @param the command sender type
- */
-public final class TeamArgument extends CommandArgument {
-
- private TeamArgument(
- final boolean required,
- final String name,
- final String defaultValue,
- final @Nullable BiFunction, String, List> suggestionsProvider,
- final ArgumentDescription defaultDescription,
- final TeamMode teamMode) {
- super(
- required,
- name,
- new TeamParser<>(teamMode),
- defaultValue,
- Team.class,
- suggestionsProvider,
- defaultDescription);
- }
-
- /**
- * Creates a new {@link TeamArgument.Builder}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static TeamArgument.Builder builder(final String name) {
- return new TeamArgument.Builder<>(name);
- }
-
- /**
- * Creates a new required {@link TeamArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static TeamArgument of(final String name) {
- return TeamArgument.builder(name).asRequired().build();
- }
-
- /**
- * Creates a new optional {@link TeamArgument}.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static TeamArgument optional(final String name) {
- return TeamArgument.builder(name).asOptional().build();
- }
-
- /**
- * Creates a new required {@link TeamArgument} with the {@link TeamMode#BASE} mode, which means that only the 6 base
- * teams can be used.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static TeamArgument base(final String name) {
- return new TeamArgument.Builder(name).withTeamMode(TeamMode.BASE).build();
- }
-
- /**
- * Creates a new required {@link TeamArgument} with the {@link TeamMode#ALL} mode, which means that all 256 teams
- * can be used.
- *
- * @param name the name of the argument
- * @param the command sender type
- * @return the created builder
- */
- public static TeamArgument all(final String name) {
- return new TeamArgument.Builder(name).withTeamMode(TeamMode.ALL).build();
- }
-
- /**
- * The parsing mode for a {@link TeamArgument}.
- */
- public enum TeamMode {
- /**
- * Only the 6 base teams can be used.
- *
- * @see Team#baseTeams
- */
- BASE,
- /**
- * All 256 teams can be used.
- *
- * @see Team#all
- */
- ALL
- }
-
- /**
- * The internal builder class of {@link TeamArgument}.
- *
- * @param the command sender type
- */
- public static final class Builder extends CommandArgument.TypedBuilder> {
-
- private TeamMode teamMode = TeamMode.BASE;
-
- private Builder(final String name) {
- super(Team.class, name);
- }
-
- /**
- * Sets the parsing mode for the {@link TeamArgument}.
- *
- * @param teamMode the parsing mode
- * @return this builder
- */
- public Builder withTeamMode(final TeamMode teamMode) {
- this.teamMode = teamMode;
- return this;
- }
-
- /**
- * Construct a new {@link TeamArgument}.
- *
- * @return the constructed team argument
- */
- @Override
- public TeamArgument build() {
- return new TeamArgument<>(
- this.isRequired(),
- this.getName(),
- this.getDefaultValue(),
- this.getSuggestionsProvider(),
- this.getDefaultDescription(),
- this.teamMode);
- }
- }
-
- /**
- * An argument parser that outputs a {@link Team}.
- *
- * @param the command sender type
- */
- public static final class TeamParser implements ArgumentParser {
-
- private static final Map BASE_TEAMS = Arrays.stream(Team.baseTeams)
- .collect(Collectors.toUnmodifiableMap(t -> t.name.toLowerCase(Locale.ROOT), Function.identity()));
-
- private static final Map ALL_TEAMS = Arrays.stream(Team.all)
- .collect(Collectors.toUnmodifiableMap(t -> t.name.toLowerCase(Locale.ROOT), Function.identity()));
-
- private final TeamMode teamMode;
-
- public TeamParser(final TeamMode teamMode) {
- this.teamMode = teamMode;
- }
-
- @Override
- public ArgumentParseResult parse(final CommandContext ctx, final Queue inputQueue) {
- final var input = inputQueue.peek();
- if (input == null) {
- return ArgumentParseResult.failure(new NoInputProvidedException(TeamArgument.TeamParser.class, ctx));
- }
-
- final var name = input.toLowerCase(Locale.ROOT);
- if (this.getTeamIndex().containsKey(name)) {
- inputQueue.remove();
- return ArgumentParseResult.success(this.getTeamIndex().get(name));
- } else {
- return ArgumentParseResult.failure(new TeamParseException(input, ctx, this.teamMode));
- }
- }
-
- @Override
- public List suggestions(final CommandContext ctx, final String input) {
- final var name = input.toLowerCase(Locale.ROOT);
- return BASE_TEAMS.keySet().stream()
- .filter(t -> t.startsWith(name))
- .sorted()
- .toList();
- }
-
- @Override
- public boolean isContextFree() {
- return true;
- }
-
- private Map getTeamIndex() {
- return this.teamMode == TeamMode.ALL ? ALL_TEAMS : BASE_TEAMS;
- }
- }
-
- /**
- * Exception thrown when a team cannot be found for the given input and {@link TeamMode}.
- */
- public static final class TeamParseException extends ParserException {
-
- @Serial
- private static final long serialVersionUID = -2213430000642727576L;
-
- private final String input;
- private final TeamMode teamMode;
-
- /**
- * Creates a new {@link TeamParseException}.
- *
- * @param input the input string
- * @param ctx the command context
- * @param teamMode the team mode
- */
- public TeamParseException(final String input, final CommandContext> ctx, final TeamMode teamMode) {
- super(
- PlayerArgument.PlayerParser.class,
- ctx,
- ArcCaptionKeys.ARGUMENT_PARSE_FAILURE_TEAM,
- CaptionVariable.of("input", input),
- CaptionVariable.of("teamMode", teamMode.name()));
- this.input = input;
- this.teamMode = teamMode;
- }
-
- public String getInput() {
- return this.input;
- }
-
- public TeamMode getTeamMode() {
- return this.teamMode;
- }
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/CommandSender.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/CommandSender.java
deleted file mode 100644
index 3338019f..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/CommandSender.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.sender;
-
-import fr.xpdustry.distributor.api.DistributorProvider;
-import java.util.Locale;
-import mindustry.gen.Player;
-
-/**
- * Represents an entity that can send commands.
- */
-public interface CommandSender {
-
- /**
- * Wraps a player into a command sender.
- *
- * @param player the player to wrap
- * @return the player command sender
- */
- static CommandSender player(final Player player) {
- return new PlayerCommandSender(player);
- }
-
- /**
- * Returns the console command sender of this server.
- */
- static CommandSender console() {
- return ConsoleCommandSender.INSTANCE;
- }
-
- /**
- * Sends a simple message to the sender.
- *
- * @param content the message to send
- */
- void sendMessage(final String content);
-
- /**
- * Sends a localized message to the sender.
- *
- * Note: if the string is not found, the key will be sent instead. Such as {@code ???key???}.
- *
- * @param key the key of the message to send
- * @param args the arguments to format the message with
- */
- default void sendLocalizedMessage(final String key, final Object... args) {
- final var format =
- DistributorProvider.get().getGlobalLocalizationSource().localize(key, this.getLocale());
- this.sendMessage(format == null ? "???" + key + " ???" : format.format(args));
- }
-
- /**
- * Sends a warning message to the sender.
- *
- * @param content the warning to send
- */
- void sendWarning(final String content);
-
- /**
- * Sends a localized warning message to the sender.
- *
- * Note: if the key is not found, the key will be sent instead. Such as {@code ???key???}.
- *
- * @param key the key of the warning to send
- * @param args the arguments to format the warning with
- */
- default void sendLocalizedWarning(final String key, final Object... args) {
- final var format =
- DistributorProvider.get().getGlobalLocalizationSource().localize(key, this.getLocale());
- this.sendWarning(format == null ? "???" + key + " ???" : format.format(args));
- }
-
- /**
- * Returns the locale of this sender.
- */
- Locale getLocale();
-
- /**
- * @return the player proxied by this sender if it's a player.
- * @throws UnsupportedOperationException if this sender is not a player.
- */
- Player getPlayer();
-
- /**
- * Returns whether this sender is a player.
- */
- boolean isPlayer();
-
- /**
- * Returns whether this sender is the console.
- */
- boolean isConsole();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/ConsoleCommandSender.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/ConsoleCommandSender.java
deleted file mode 100644
index 92bb9f66..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/ConsoleCommandSender.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.sender;
-
-import arc.util.Log;
-import java.util.Locale;
-import mindustry.gen.Player;
-
-final class ConsoleCommandSender implements CommandSender {
-
- static final ConsoleCommandSender INSTANCE = new ConsoleCommandSender();
-
- private ConsoleCommandSender() {}
-
- @Override
- public void sendMessage(final String content) {
- for (final var line : content.split("\n", -1)) {
- Log.info(line);
- }
- }
-
- @Override
- public void sendWarning(final String content) {
- for (final var line : content.split("\n", -1)) {
- Log.warn(line);
- }
- }
-
- @Override
- public Locale getLocale() {
- return Locale.getDefault();
- }
-
- @Override
- public Player getPlayer() {
- throw new UnsupportedOperationException("This sender is not a player.");
- }
-
- @Override
- public boolean isPlayer() {
- return false;
- }
-
- @Override
- public boolean isConsole() {
- return true;
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/PlayerCommandSender.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/PlayerCommandSender.java
deleted file mode 100644
index bc3ebea7..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/sender/PlayerCommandSender.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.sender;
-
-import java.util.Locale;
-import mindustry.gen.Player;
-
-final class PlayerCommandSender implements CommandSender {
-
- private final Player player;
- private final Locale locale;
-
- PlayerCommandSender(final Player player) {
- this.player = player;
- this.locale = Locale.forLanguageTag(player.locale().replace('_', '-'));
- }
-
- @Override
- public void sendMessage(final String content) {
- this.player.sendMessage(content);
- }
-
- @Override
- public void sendWarning(final String content) {
- this.player.sendMessage("[red]" + content);
- }
-
- @Override
- public Locale getLocale() {
- return this.locale;
- }
-
- @Override
- public Player getPlayer() {
- return this.player;
- }
-
- @Override
- public boolean isPlayer() {
- return true;
- }
-
- @Override
- public boolean isConsole() {
- return false;
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/specifier/AllTeams.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/specifier/AllTeams.java
deleted file mode 100644
index fd2ddb81..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/command/specifier/AllTeams.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.specifier;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation used to specify that a {@link mindustry.game.Team} command argument can represent all the teams instead of the 6 base
- * teams.
- *
- * @see fr.xpdustry.distributor.api.command.argument.TeamArgument.TeamMode#ALL
- */
-@Target(ElementType.PARAMETER)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface AllTeams {}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/event/EventBus.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/event/EventBus.java
deleted file mode 100644
index 2a9bbfae..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/event/EventBus.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.event;
-
-import fr.xpdustry.distributor.api.plugin.MindustryPlugin;
-import fr.xpdustry.distributor.api.util.Priority;
-import java.util.function.Consumer;
-
-/**
- * The event bus of this server. A better alternative to {@link arc.Events}.
- *
- * Event subscribers registered with this class will not crash the server if an exception is thrown but be logged instead.
- * Subscribers also come with {@link EventSubscription} objects to dynamically unsubscribe them. And also
- * {@link Priority} to make sure your subscribers are called in a specific order.
- *
{@code
- * final EventBus bus = DistributorProvider.get().getEventBus();
- * final MindustryPlugin plugin = ...;
- * final EventSubscription subscription = bus.subscribe(EventType.PlayerJoin.class, plugin, event -> {
- * event.player.sendMessage("Hello " + event.player.name() + "!");
- * });
- * // When no longer needed, you can unsubscribe the listener
- * subscription.unsubscribe();
- * }
- *
- * This class also provides a way to subscribe to events using methods annotated with {@link EventHandler}.
- *
- *
{@code
- * public final class PlayerListener {
- * @EventHandler
- * public void onPlayerJoin(final EventType.PlayerJoin event) {
- * event.player.sendMessage("Hello, " + event.player.name() + "!");
- * }
- * }
- *
- * public final class MyPlugin extends AbstractMindustryPlugin {
- * @Override
- * public void onInit() {
- * DistributorProvider.get().getEventBus().parse(this, new PlayerListener());
- * }
- * }
- * }
- */
-public interface EventBus {
-
- /**
- * Subscribe to an event.
- *
- * @param event the event class to subscribe to
- * @param priority the priority of the listener
- * @param plugin the plugin that owns the listener
- * @param listener the listener to subscribe
- * @param the type of the event
- * @return the subscription of the subscribed listener
- */
- EventSubscription subscribe(
- final Class event, final Priority priority, final MindustryPlugin plugin, final Consumer listener);
-
- /**
- * Subscribe to an event.
- *
- * @param event the event class to subscribe to
- * @param plugin the plugin that owns the listener
- * @param listener the listener to subscribe
- * @param the type of the event
- * @return the subscription of the subscribed listener
- */
- default EventSubscription subscribe(
- final Class event, final MindustryPlugin plugin, final Consumer listener) {
- return this.subscribe(event, Priority.NORMAL, plugin, listener);
- }
-
- /**
- * Subscribe to an event.
- *
- * @param event the event enum to subscribe to
- * @param priority the priority of the listener
- * @param plugin the plugin that owns the listener
- * @param listener the listener to subscribe
- * @param the type of the enum event
- * @return the subscription of the subscribed listener
- */
- > EventSubscription subscribe(
- final E event, final Priority priority, final MindustryPlugin plugin, final Runnable listener);
-
- /**
- * Subscribe to an event.
- *
- * @param event the event enum to subscribe to
- * @param plugin the plugin that owns the listener
- * @param listener the listener to subscribe
- * @param the type of the enum event
- * @return the subscription of the subscribed listener
- */
- default > EventSubscription subscribe(
- final E event, final MindustryPlugin plugin, final Runnable listener) {
- return this.subscribe(event, Priority.NORMAL, plugin, listener);
- }
-
- /**
- * Posts the event to the arc event bus.
- *
- * @param event the event to post
- * @param the type of the event
- */
- void post(final E event);
-
- /**
- * Posts the event to the arc event bus to the listeners of the given super class.
- *
- * @param clazz the class of the event
- * @param event the event to post
- * @param the type of the event
- */
- void post(final Class super E> clazz, final E event);
-
- /**
- * Posts the enum event to the arc event bus.
- *
- * @param event the enum event to post
- * @param the type of the enum event
- */
- > void post(final E event);
-
- /**
- * Parses the given listener to extract methods annotated with {@link EventHandler} and subscribes them to this
- * event bus.
- *
- * @param plugin the plugin that owns the listener
- * @param listener the listener to parse
- * @return the subscription of the subscribed handlers
- * @deprecated replace with {@link fr.xpdustry.distributor.api.plugin.PluginAnnotationParser}
- */
- @Deprecated(forRemoval = true)
- EventSubscription parse(final MindustryPlugin plugin, final Object listener);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSource.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSource.java
deleted file mode 100644
index 0c0a3f71..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSource.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * A helper class for adding localization support to your plugin.
- */
-public interface LocalizationSource {
-
- /**
- * Returns a {@code LocalizationSource} for the router language {@code :^)}.
- */
- static LocalizationSource router() {
- return RouterLocalizationSource.INSTANCE;
- }
-
- /**
- * Returns the localized string for the given key or {@code null} if absent.
- *
- *
{@code
- * // Send a localized message to every player
- * final LocalizationSource source = ...;
- * Groups.player.each(player -> {
- * final var locale = Locale.forLanguageTag(player.locale().replace('_', '-'));
- * final var message = source.localize("example.key", locale);
- * player.sendMessage(message == null ? "???example.key???" : message);
- * }
- * }
- *
- * @param key the key of the string to localize
- * @return the localized string contained in a {@link MessageFormat}, or {@code null} if no string was found.
- */
- @Nullable MessageFormat localize(final String key, final Locale locale);
-
- /**
- * Shorthand method to directly format a localized string, with a failover to a default value {@code ???key???}.
- *
- *
{@code
- * // Send a localized message to every player
- * final LocalizationSource source = ...;
- * Groups.player.each(player -> {
- * final var locale = Locale.forLanguageTag(player.locale().replace('_', '-'));
- * player.sendMessage(source.format("example.key", locale));
- * }
- * }
- *
- * @param key the key of the string to localize
- * @param locale the locale to use
- * @param args the arguments to pass to the {@link MessageFormat#format(Object)}
- * @return the formatted string, or {@code ???key???} if no string was found.
- */
- default String format(final String key, final Locale locale, final Object... args) {
- final var format = this.localize(key, locale);
- return format == null ? "???" + key + "???" : format.format(args);
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistry.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistry.java
deleted file mode 100644
index 8667955d..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistry.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.Map;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.function.Function;
-
-/**
- * A mutable localization source that can register localized strings.
- */
-public interface LocalizationSourceRegistry extends LocalizationSource {
-
- /**
- * Creates a new {@code LocalizationSourceRegistry} instance.
- *
- * @param defaultLocale the default locale of the localization source
- * @return a new {@code LocalizationSourceRegistry} instance
- */
- static LocalizationSourceRegistry create(final Locale defaultLocale) {
- return new LocalizationSourceRegistryImpl(defaultLocale);
- }
-
- /**
- * Registers a map of localized strings.
- *
- *
{@code
- * final var strings = new HashMap();
- * strings.put("example.hello", new MessageFormat("Hello {0}!", Locale.ENGLISH));
- * strings.put("example.goodbye", new MessageFormat("Goodbye {0}!", Locale.ENGLISH));
- * registry.registerAll(Locale.ENGLISH, strings);
- * }
- *
- * @param locale the locale to register the strings to
- * @param formats the map of localized strings
- * @throws IllegalArgumentException if a key is already registered
- */
- default void registerAll(final Locale locale, final Map formats) {
- this.registerAll(locale, formats.keySet(), formats::get);
- }
-
- /**
- * Registers a resource bundle of localized strings.
- *
- * @param locale the locale to register the strings to
- * @param bundle the resource bundle to use
- * @throws IllegalArgumentException if a key is already registered
- */
- default void registerAll(final Locale locale, final ResourceBundle bundle) {
- this.registerAll(locale, bundle.keySet(), key -> new MessageFormat(bundle.getString(key), locale));
- }
-
- /**
- * Registers a resource bundle of localized strings via the classpath.
- *
- *
- *
- * @param locale the locale to register the strings to
- * @param baseName the base name of the resource bundle
- * @param loader the class loader to use
- * @throws IllegalArgumentException if a key is already registered
- */
- default void registerAll(final Locale locale, final String baseName, final ClassLoader loader) {
- this.registerAll(locale, ResourceBundle.getBundle(baseName, locale, loader));
- }
-
- /**
- * Registers a resource bundle of localized strings via a file system.
- *
- *
{@code
- * final var english = Paths.get("bundle_en.properties");
- * registry.registerAll(Locale.ENGLISH, path);
- * final var english = Paths.get("bundle_fr.properties");
- * registry.registerAll(Locale.FRENCH, path);
- * }
- *
- * @param locale the locale to register the strings to
- * @param path the path to the bundle file
- * @throws IllegalArgumentException if a key is already registered
- */
- default void registerAll(final Locale locale, final Path path) throws IOException {
- try (final BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
- this.registerAll(locale, new PropertyResourceBundle(reader));
- }
- }
-
- /**
- * Registers a set of localized strings by using a mapping function to obtain each string.
- *
- * @param locale the locale to register the strings to
- * @param keys the set of keys to register
- * @param function the mapping function
- * @throws IllegalArgumentException if the key is already registered
- */
- default void registerAll(
- final Locale locale, final Set keys, final Function function) {
- for (final var key : keys) {
- this.register(key, locale, function.apply(key));
- }
- }
-
- /**
- * Registers a localized string.
- *
- * @param key the key of the string
- * @param locale the locale to register the string to
- * @param format the localized string
- * @throws IllegalArgumentException if the key is already registered
- */
- void register(final String key, final Locale locale, final MessageFormat format);
-
- /**
- * Checks if a key is already registered, for any locale.
- *
- * @param key the key to check
- * @return {@code true} if the key is already registered, {@code false} otherwise
- */
- boolean registered(final String key);
-
- /**
- * Checks if a key is already registered for a specific locale.
- *
- * @param key the key to check
- * @param locale the locale to check
- * @return {@code true} if the key is already registered for the specific locale, {@code false} otherwise
- */
- boolean registered(final String key, final Locale locale);
-
- /**
- * Unregisters a localized string.
- *
- * @param key the key of the string
- */
- void unregister(final String key);
-
- /**
- * Returns the default locale of this source.
- */
- Locale getDefaultLocale();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistryImpl.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistryImpl.java
deleted file mode 100644
index 39b98b55..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/LocalizationSourceRegistryImpl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-final class LocalizationSourceRegistryImpl implements LocalizationSourceRegistry {
-
- private final Map entries = new ConcurrentHashMap<>();
- private final Locale defaultLocale;
-
- LocalizationSourceRegistryImpl(final Locale defaultLocale) {
- this.defaultLocale = defaultLocale;
- }
-
- @Override
- public @Nullable MessageFormat localize(final String key, final Locale locale) {
- return this.entries.containsKey(key) ? this.entries.get(key).localize(locale) : null;
- }
-
- @Override
- public void register(final String key, final Locale locale, final MessageFormat format) {
- if (!this.entries.computeIfAbsent(key, k -> new Localization()).register(locale, format)) {
- throw new IllegalArgumentException(
- String.format("A localization is already present: %s for %s.", key, locale));
- }
- }
-
- @Override
- public void unregister(final String key) {
- this.entries.remove(key);
- }
-
- @Override
- public boolean registered(final String key) {
- return this.entries.containsKey(key);
- }
-
- @Override
- public boolean registered(final String key, final Locale locale) {
- return this.entries.containsKey(key) && this.entries.get(key).formats.containsKey(locale);
- }
-
- @Override
- public Locale getDefaultLocale() {
- return this.defaultLocale;
- }
-
- private final class Localization {
-
- private final Map formats = new ConcurrentHashMap<>();
-
- private boolean register(final Locale locale, final MessageFormat format) {
- return this.formats.putIfAbsent(locale, format) == null;
- }
-
- private @Nullable MessageFormat localize(final Locale locale) {
- var format = this.formats.get(locale);
- if (format == null) {
- // try without the country
- format = this.formats.get(new Locale(locale.getLanguage()));
- }
- if (format == null) {
- // try with default locale of this registry
- format = this.formats.get(LocalizationSourceRegistryImpl.this.defaultLocale);
- }
- if (format == null) {
- // try local default locale of this JVM
- format = this.formats.get(Locale.getDefault());
- }
- return format;
- }
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSource.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSource.java
deleted file mode 100644
index 1d48220b..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-/**
- * A mutable localization source that delegates the localization lookup to other sources in FIFO order.
- */
-public interface MultiLocalizationSource extends LocalizationSource {
-
- /**
- * Creates a new {@code MultiLocalizationSource} instance.
- */
- static MultiLocalizationSource create() {
- return new MultiLocalizationSourceImpl();
- }
-
- /**
- * Adds a localization source to the list of sources.
- *
- * @param source the source to add
- */
- void addLocalizationSource(final LocalizationSource source);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSourceImpl.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSourceImpl.java
deleted file mode 100644
index e93107c4..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/MultiLocalizationSourceImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-import java.text.MessageFormat;
-import java.util.ArrayDeque;
-import java.util.Deque;
-import java.util.Locale;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-final class MultiLocalizationSourceImpl implements MultiLocalizationSource {
-
- private final Deque sources = new ArrayDeque<>();
-
- @Override
- public void addLocalizationSource(final LocalizationSource source) {
- this.sources.add(source);
- }
-
- @Override
- public @Nullable MessageFormat localize(final String key, final Locale locale) {
- final var iterator = this.sources.descendingIterator();
-
- while (iterator.hasNext()) {
- final var translation = iterator.next().localize(key, locale);
- if (translation != null) {
- return translation;
- }
- }
-
- return null;
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/RouterLocalizationSource.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/RouterLocalizationSource.java
deleted file mode 100644
index 08720677..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/localization/RouterLocalizationSource.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.localization;
-
-import java.text.MessageFormat;
-import java.util.Locale;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-final class RouterLocalizationSource implements LocalizationSource {
-
- static final RouterLocalizationSource INSTANCE = new RouterLocalizationSource();
-
- static final Locale ROUTER_LOCALE = new Locale("router");
- private static final MessageFormat ROUTER_FORMAT = new MessageFormat("router", ROUTER_LOCALE);
-
- private RouterLocalizationSource() {}
-
- @Override
- public @Nullable MessageFormat localize(final String key, final Locale locale) {
- return locale.equals(ROUTER_LOCALE) ? ROUTER_FORMAT : null;
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/package-info.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/package-info.java
deleted file mode 100644
index b07c128e..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/package-info.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2022 Xpdustry
- *
- * 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 .
- */
-@DefaultQualifier(
- value = NonNull.class,
- locations = {
- TypeUseLocation.CONSTRUCTOR_RESULT,
- TypeUseLocation.EXCEPTION_PARAMETER,
- TypeUseLocation.EXPLICIT_LOWER_BOUND,
- TypeUseLocation.EXPLICIT_UPPER_BOUND,
- TypeUseLocation.FIELD,
- TypeUseLocation.IMPLICIT_LOWER_BOUND,
- TypeUseLocation.IMPLICIT_UPPER_BOUND,
- TypeUseLocation.LOWER_BOUND,
- TypeUseLocation.PARAMETER,
- TypeUseLocation.RECEIVER,
- TypeUseLocation.RESOURCE_VARIABLE,
- TypeUseLocation.RETURN,
- TypeUseLocation.UPPER_BOUND,
- TypeUseLocation.OTHERWISE,
- })
-package fr.xpdustry.distributor.api;
-
-import org.checkerframework.checker.nullness.qual.NonNull;
-import org.checkerframework.framework.qual.DefaultQualifier;
-import org.checkerframework.framework.qual.TypeUseLocation;
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/PluginAnnotationParser.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/PluginAnnotationParser.java
deleted file mode 100644
index 1c8f15f7..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/PluginAnnotationParser.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.plugin;
-
-/**
- * A plugin component responsible for scanning the plugin instance and its listener for annotations.
- */
-public interface PluginAnnotationParser {
-
- /**
- * Creates a simple plugin annotation parser that will parse and register
- * {@link fr.xpdustry.distributor.api.scheduler.TaskHandler task handlers} and
- * {@link fr.xpdustry.distributor.api.event.EventHandler event handlers}.
- *
- * @param plugin The owning plugin
- * @return the created plugin annotation parser
- */
- static PluginAnnotationParser simple(final MindustryPlugin plugin) {
- return new SimplePluginAnnotationParser(plugin);
- }
-
- /**
- * Parses the given object for annotations related to the plugin.
- *
- * @param object The object to be scanned for annotations.
- * It can be the plugin instance or its listener.
- */
- void parse(final Object object);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/SimplePluginAnnotationParser.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/SimplePluginAnnotationParser.java
deleted file mode 100644
index 181c124b..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/plugin/SimplePluginAnnotationParser.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.plugin;
-
-import fr.xpdustry.distributor.api.DistributorProvider;
-import fr.xpdustry.distributor.api.event.EventHandler;
-import fr.xpdustry.distributor.api.scheduler.Cancellable;
-import fr.xpdustry.distributor.api.scheduler.TaskHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.function.Consumer;
-
-final class SimplePluginAnnotationParser implements PluginAnnotationParser {
-
- private final MindustryPlugin plugin;
-
- SimplePluginAnnotationParser(final MindustryPlugin plugin) {
- this.plugin = plugin;
- }
-
- @Override
- public void parse(final Object object) {
- for (final var method : object.getClass().getDeclaredMethods()) {
- parseEvents(object, method);
- parseTasks(object, method);
- }
- }
-
- private void parseEvents(final Object object, final Method method) {
- final var annotation = method.getAnnotation(EventHandler.class);
- if (annotation == null) {
- return;
- }
- if (method.getParameterCount() != 1) {
- throw new IllegalArgumentException("The event handler on " + method + " hasn't the right parameter count.");
- } else if (!method.canAccess(object)) {
- method.setAccessible(true);
- }
-
- final var handler = new MethodEventHandler<>(object, method, plugin);
- DistributorProvider.get()
- .getEventBus()
- .subscribe(handler.getEventType(), annotation.priority(), plugin, handler);
- }
-
- private void parseTasks(final Object object, final Method method) {
- final var annotation = method.getAnnotation(TaskHandler.class);
- if (annotation == null) {
- return;
- }
- if (method.getParameterCount() > 1) {
- throw new IllegalArgumentException("The event handler on " + method + " hasn't the right parameter count.");
- } else if (!method.canAccess(object)) {
- method.setAccessible(true);
- } else if (method.getParameterCount() == 1 && !Cancellable.class.equals(method.getParameterTypes()[0])) {
- throw new IllegalArgumentException("The event handler on " + method + " hasn't the right parameter type.");
- }
-
- final var scheduler = DistributorProvider.get().getPluginScheduler();
- final var builder = annotation.async() ? scheduler.scheduleAsync(plugin) : scheduler.scheduleSync(plugin);
- if (annotation.interval() > -1) {
- builder.repeat(annotation.interval(), annotation.unit());
- }
- if (annotation.delay() > -1) {
- builder.delay(annotation.delay(), annotation.unit());
- }
- builder.execute(new MethodTaskHandler(object, method));
- }
-
- private static final class MethodEventHandler implements Consumer {
-
- private final Object target;
- private final Method method;
- private final MindustryPlugin plugin;
-
- private MethodEventHandler(final Object target, final Method method, final MindustryPlugin plugin) {
- this.target = target;
- this.method = method;
- this.plugin = plugin;
- }
-
- @Override
- public void accept(final E event) {
- try {
- this.method.invoke(this.target, event);
- } catch (final InvocationTargetException e) {
- this.plugin
- .getLogger()
- .atError()
- .setMessage("An error occurred while handling a {} event.")
- .addArgument(event.getClass().getSimpleName())
- .setCause(e.getTargetException())
- .log();
- } catch (final ReflectiveOperationException e) {
- throw new RuntimeException("Failed to call " + this.method + " on " + this.target, e);
- }
- }
-
- @SuppressWarnings("unchecked")
- public Class getEventType() {
- return (Class) this.method.getParameterTypes()[0];
- }
- }
-
- private static final class MethodTaskHandler implements Consumer {
-
- private final Object object;
- private final Method method;
-
- private MethodTaskHandler(final Object object, final Method method) {
- this.object = object;
- this.method = method;
- }
-
- @Override
- public void accept(final Cancellable cancellable) {
- try {
- if (this.method.getParameterCount() == 1) {
- this.method.invoke(this.object, cancellable);
- } else {
- this.method.invoke(this.object);
- }
- } catch (final IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException("Unable to invoke " + this.method, e);
- }
- }
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/Cancellable.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/Cancellable.java
deleted file mode 100644
index 19658c68..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/Cancellable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-/**
- * A {@code Cancellable} is used to cancel a task.
- */
-public interface Cancellable {
-
- /**
- * Cancels the task bound to this {@code Cancellable}.
- */
- void cancel();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/MindustryTimeUnit.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/MindustryTimeUnit.java
deleted file mode 100644
index 7e9cd0a9..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/MindustryTimeUnit.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import java.util.Optional;
-import java.util.concurrent.TimeUnit;
-import org.checkerframework.checker.nullness.qual.Nullable;
-
-/**
- * Time units used by the {@link PluginTaskBuilder} and {@link PluginTask} classes to represent time.
- */
-public enum MindustryTimeUnit {
-
- /**
- * Time unit representing one thousandth of a second.
- */
- MILLISECONDS(TimeUnit.MILLISECONDS),
-
- /**
- * Time unit representing one game loop, which is 60 times per second.
- */
- TICKS(null),
-
- /**
- * Time unit representing one thousandth of a millisecond.
- */
- SECONDS(TimeUnit.SECONDS),
-
- /**
- * Time unit representing sixty seconds.
- */
- MINUTES(TimeUnit.MINUTES),
-
- /**
- * Time unit representing sixty minutes.
- */
- HOURS(TimeUnit.HOURS),
-
- /**
- * Time unit representing twenty-four hours.
- */
- DAYS(TimeUnit.DAYS);
-
- private final @Nullable TimeUnit unit;
-
- MindustryTimeUnit(final @Nullable TimeUnit unit) {
- this.unit = unit;
- }
-
- /**
- * Converts the given duration in the given time unit to this time unit.
- *
- * Since this method is equivalent to {@link TimeUnit#convert(long, TimeUnit)}:
- *
- *
If it overflows, the result will be {@link Long#MAX_VALUE} if the duration is positive,
- * or {@link Long#MIN_VALUE} if it is negative.
- *
Conversions are floored so converting 999 milliseconds to seconds results in 0.
- *
- *
- * @param sourceDuration the duration to convert
- * @param sourceUnit the time unit of the duration
- * @return the converted duration
- * @see TimeUnit#convert(long, TimeUnit)
- */
- public long convert(final long sourceDuration, final MindustryTimeUnit sourceUnit) {
- if (this == sourceUnit) {
- return sourceDuration;
- }
- final var sourceJavaUnit = sourceUnit.getJavaTimeUnit();
- final var targetJavaUnit = this.getJavaTimeUnit();
-
- if (sourceJavaUnit.isPresent() && targetJavaUnit.isPresent()) {
- return targetJavaUnit.get().convert(sourceDuration, sourceJavaUnit.get());
- } else if (sourceJavaUnit.isEmpty()) {
- return targetJavaUnit
- .orElseThrow()
- .convert((long) Math.nextUp(sourceDuration * (1000F / 60F)), TimeUnit.MILLISECONDS);
- } else {
- final var millis = TimeUnit.MILLISECONDS.convert(sourceDuration, sourceJavaUnit.orElseThrow());
- if (millis == Long.MAX_VALUE || millis == Long.MIN_VALUE) {
- return millis;
- }
- return (long) (millis * (60F / 1000L));
- }
- }
-
- /**
- * Returns the Java time unit associated with this Mindustry time unit, if any.
- */
- public Optional getJavaTimeUnit() {
- return Optional.ofNullable(this.unit);
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginScheduler.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginScheduler.java
deleted file mode 100644
index 5c4d0538..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginScheduler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import fr.xpdustry.distributor.api.plugin.MindustryPlugin;
-import java.util.List;
-
-/**
- * A {@code PluginScheduler} is used to schedule tasks for a plugin. A better alternative to {@link arc.util.Timer}.
- */
-public interface PluginScheduler {
-
- /**
- * Returns a new {@link PluginTaskBuilder} instance scheduling a synchronous task.
- *
- * @param plugin the plugin to schedule the task for.
- * @return a new {@link PluginTaskBuilder} instance.
- */
- PluginTaskBuilder scheduleSync(final MindustryPlugin plugin);
-
- /**
- * Returns a new {@link PluginTaskBuilder} instance scheduling an asynchronous task.
- *
- * @param plugin the plugin to schedule the task for.
- * @return a new {@link PluginTaskBuilder} instance.
- */
- PluginTaskBuilder scheduleAsync(final MindustryPlugin plugin);
-
- /**
- * Returns a new {@link PluginTaskRecipe} instance.
- *
- * @param plugin the plugin to schedule the task for.
- * @param value the initial value.
- * @return a new {@link PluginTaskRecipe} instance.
- * @deprecated The recipe API is awful given the better alternatives such as completable futures, coroutines,
- * or even the structured concurrency API of java 21.
- */
- @Deprecated(forRemoval = true)
- PluginTaskRecipe recipe(final MindustryPlugin plugin, final V value);
-
- /**
- * Parses the given object to extract methods annotated with {@link TaskHandler} and schedules them to the arc
- * event bus.
- *
- * @param plugin the plugin that owns the listener
- * @param object the object to parse
- * @return a list of scheduled tasks
- * @deprecated replace with {@link fr.xpdustry.distributor.api.plugin.PluginAnnotationParser}
- */
- @Deprecated(forRemoval = true)
- List> parse(final MindustryPlugin plugin, final Object object);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTask.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTask.java
deleted file mode 100644
index dfd0eca2..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTask.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import fr.xpdustry.distributor.api.plugin.PluginAware;
-import java.util.concurrent.Future;
-
-/**
- * A {@code PluginTask} is a future used by a {@link PluginScheduler}.
- *
- * @param the type of the value returned by this task.
- */
-public interface PluginTask extends Future, PluginAware {
-
- /**
- * Returns whether this future is executed asynchronously.
- */
- boolean isAsync();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskBuilder.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskBuilder.java
deleted file mode 100644
index 6ecad447..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskBuilder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import java.util.function.Consumer;
-import java.util.function.Supplier;
-
-/**
- * A helper object for building and scheduling a {@link PluginTask}.
- *
- *
{@code
- * final PluginScheduler scheduler = DistributorProvider.get().getPluginScheduler();
- * final MindustryPlugin plugin = ...;
- * // Warn the players the server is close in 5 minutes.
- * Groups.player.each(p -> p.sendMessage("The server will restart in 5 minutes."));
- * // Now schedule the closing task.
- * scheduler.scheduleSync(plugin).delay(5L, MindustryTimeUnit.MINUTES).execute(() -> Core.app.exit());
- * }
- */
-public interface PluginTaskBuilder {
-
- /**
- * Run the task after a delay.
- *
- * @param delay the delay.
- * @param unit the time unit of the delay.
- * @return this builder.
- */
- PluginTaskBuilder delay(final long delay, final MindustryTimeUnit unit);
-
- /**
- * Run the task periodically with a fixed interval.
- * Stops the periodic execution if an exception is thrown.
- *
- * @param interval the interval between the end of the last execution and the start of the next.
- * @param unit the time unit of the interval.
- * @return this builder.
- */
- PluginTaskBuilder repeat(final long interval, final MindustryTimeUnit unit);
-
- /**
- * Build and schedule the task with the given task.
- *
- * @param runnable the task to run.
- * @return a new plugin task.
- */
- PluginTask execute(final Runnable runnable);
-
- /**
- * Build and schedule the task with the given task.
- *
- * @param consumer the task to run, with a cancellable object to stop the task if it's periodic.
- * @return a new plugin task.
- */
- PluginTask execute(final Consumer consumer);
-
- /**
- * Build and schedule the task with the given task.
- *
- * @param supplier the task to run, with an output value. Won't output any result value if the task is periodic.
- * @return a new plugin task.
- */
- PluginTask execute(final Supplier supplier);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskRecipe.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskRecipe.java
deleted file mode 100644
index 1adbe5dd..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/PluginTaskRecipe.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-/**
- * A {@code PluginTaskRecipe} is a helper class for creating staged {@link PluginTask}s.
- * It will basically execute each step (asynchronously or not) in separate tasks, then returning the result.
- *
- *
- *
- * @param the type of the result.
- */
-public interface PluginTaskRecipe {
-
- PluginTaskRecipe thenAccept(final Consumer consumer);
-
- PluginTaskRecipe thenApply(final Function function);
-
- PluginTaskRecipe thenRun(final Runnable runnable);
-
- PluginTaskRecipe thenAcceptAsync(final Consumer consumer);
-
- PluginTaskRecipe thenApplyAsync(final Function function);
-
- PluginTaskRecipe thenRunAsync(final Runnable runnable);
-
- PluginTask execute();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/TaskHandler.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/TaskHandler.java
deleted file mode 100644
index 97d95662..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/scheduler/TaskHandler.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.scheduler;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marks a method as a task handler, meaning it will be registered and called as a scheduled task in the
- * {@link PluginScheduler}.
- *
- * The annotated method can have one {@link Cancellable} parameter to allow the task to cancel itself.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface TaskHandler {
-
- /**
- * The interval between each execution of the task.
- * The task will be executed once if the interval is set to a value below -1.
- */
- long interval() default -1;
-
- /**
- * The initial delay before the first execution of the task.
- * The task will be executed immediately if the delay is set to a value below -1.
- */
- long delay() default -1;
-
- /**
- * The time unit of the interval and initial delay.
- */
- MindustryTimeUnit unit() default MindustryTimeUnit.SECONDS;
-
- /**
- * Whether the task should be executed asynchronously.
- */
- boolean async() default false;
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/PlayerValidator.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/PlayerValidator.java
deleted file mode 100644
index 09cbedd9..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/PlayerValidator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security;
-
-import fr.xpdustry.distributor.api.util.MUUID;
-
-/**
- * A service to check player identities based on usids since uuids are very easy to steal.
- */
-public interface PlayerValidator {
-
- /**
- * Checks whether a player muuid is valid.
- *
- * @param muuid the player's muuid.
- * @return {@code true} if the muuid is valid, {@code false} if invalid or unknown.
- */
- boolean isValid(final MUUID muuid);
-
- /**
- * Checks whether a player uuid is bound to any muuid inside the validator.
- *
- * @param uuid the player's uuid.
- * @return {@code true} if the uuid is bound to a muuid, {@code false} otherwise.
- */
- boolean contains(final String uuid);
-
- /**
- * Checks whether a player muuid is present inside this validator.
- *
- * @param muuid the player's muuid.
- * @return {@code true} if the muuid is present, {@code false} otherwise.
- */
- boolean contains(final MUUID muuid);
-
- /**
- * Marks the given muuid as valid.
- *
- * @param muuid the player's muuid.
- */
- void validate(final MUUID muuid);
-
- /**
- * Marks the given muuid as invalid.
- *
- * @param muuid the player's muuid.
- */
- void invalidate(final MUUID muuid);
-
- /**
- * Marks all muuid with the given uuid as invalid.
- *
- * @param uuid the player's uuid.
- */
- void invalidate(final String uuid);
-
- /**
- * Invalidates all muuids.
- */
- void invalidateAll();
-
- /**
- * Removes all muuid validation statuses with the given uuid from the validator.
- *
- * @param uuid the player's uuid.
- */
- void remove(final String uuid);
-
- /**
- * Removes muuid validation statuses from the validator.
- *
- * @param muuid the player's muuid.
- */
- void remove(final MUUID muuid);
-
- /**
- * Removes all muuid validation statuses from the validator.
- */
- void removeAll();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/GroupPermissible.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/GroupPermissible.java
deleted file mode 100644
index 4bbf2f6b..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/GroupPermissible.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security.permission;
-
-/**
- * A permissible representing a group, for easily managing set of permissions with players or other groups.
- */
-public interface GroupPermissible extends Permissible {
-
- /**
- * Returns the weight of this group.
- *
- * Note: the higher the weight, the higher the priority during permission lookup.
- */
- int getWeight();
-
- /**
- * Sets the weight of this group.
- *
- * Note: the higher the weight, the higher the priority during permission lookup.
- */
- void setWeight(int weight);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/Permissible.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/Permissible.java
deleted file mode 100644
index 271e10f2..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/Permissible.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security.permission;
-
-import fr.xpdustry.distributor.api.util.Tristate;
-import java.util.Collection;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/**
- * Represents an entity that can be assigned permissions.
- */
-public interface Permissible {
-
- /**
- * Regex pattern used to validate permission strings.
- *
- * Notes:
- *
- * Permission strings are composed of a series of nodes separated by dots with alphanumeric characters and minus
- * signs, such as {@code "plugin.command"}.
- *
- * A parent node is always overridden by a child node, such as {@code "plugin.command"} overriding {@code "plugin"}.
- *
- * Wildcards are also allowed, but they currently have the same effect as a normal node, such as {@code "plugin.command.*"} equals {@code "plugin.command"}.
- *
- * The only relevant use of wildcards is the root permission {@code "*"} permission. It
- * allows you to set a default value for all permissions.
- *
- */
- String PERMISSION_REGEX = "^(\\*|[a-z\\d\\-]+)(\\.(\\*|[a-z\\d\\-]+))*$";
-
- Pattern PERMISSION_PATTERN = Pattern.compile(PERMISSION_REGEX);
-
- /**
- * Returns the name of this permissible.
- */
- String getName();
-
- /**
- * Returns the state for a given permission.
- *
- *
{@link Tristate#TRUE} if the permission is explicitly granted.
- *
{@link Tristate#FALSE} if the permission is explicitly denied.
- *
{@link Tristate#UNDEFINED} if the permission is not set or it does not match the
- * {@link #PERMISSION_REGEX regex}.
- *
- *
- * @param permission the permission string
- * @return the state of the permission
- */
- Tristate getPermission(final String permission);
-
- /**
- * Sets the state for a given permission.
- *
- *
{@link Tristate#TRUE} to explicitly grant the permission.
- *
{@link Tristate#FALSE} to explicitly deny the permission.
- *
{@link Tristate#UNDEFINED} to remove the permission.
- *
- *
- * @param permission the permission string
- * @param state the state of the permission
- */
- void setPermission(final String permission, final Tristate state);
-
- /**
- * Sets the state for a given permission.
- *
- *
{@code true} to explicitly grant the permission.
- *
{@code false} to explicitly deny the permission.
- *
- *
- * @param permission the permission string
- * @param state the state of the permission
- */
- default void setPermission(final String permission, final boolean state) {
- this.setPermission(permission, Tristate.of(state));
- }
-
- /**
- * Returns the permissions of this permissible as a map.
- */
- Map getPermissions();
-
- /**
- * Sets the permissions of this permissible.
- *
- * @param permissions the permissions to set
- */
- void setPermissions(final Map permissions);
-
- /**
- * Returns the parents of this permissible.
- */
- Collection getParentGroups();
-
- /**
- * Sets the parents of this permissible.
- *
- * @param parents the groups to set
- */
- void setParentGroups(final Collection parents);
-
- /**
- * Adds a parent to this permissible.
- */
- void addParentGroup(final String group);
-
- /**
- * Removes a parent from this permissible.
- */
- void removeParentGroup(final String group);
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissibleManager.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissibleManager.java
deleted file mode 100644
index 092d6564..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissibleManager.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security.permission;
-
-import java.util.Optional;
-
-/**
- * A manager for a specific type of permissible.
- *
- * @param
the type of permissible
- */
-public interface PermissibleManager
{
-
- /**
- * Saves the given permissible.
- *
- * @param permissible the permissible to save
- */
- void save(final P permissible);
-
- /**
- * Saves the given permissibles in bulk.
- *
- * @param permissibles the permissibles to save
- */
- default void saveAll(final Iterable
permissibles) {
- permissibles.forEach(this::save);
- }
-
- /**
- * Returns the permissible with the given id. If not found, a new permissible is created.
- *
- * @param id the id of the permissible
- * @return the permissible or a new one
- */
- P findOrCreateById(final String id);
-
- /**
- * Returns the permissible with the given id. If not found, an empty optional is returned.
- *
- * @param id the id of the permissible
- * @return the permissible or an empty optional
- */
- Optional
findById(final String id);
-
- /**
- * Returns all the permissibles.
- */
- Iterable
findAll();
-
- /**
- * Checks if the permissible exists in the database.
- *
- * @param permissible the permissible to check
- * @return {@code true} if the permissible exists, {@code false} otherwise
- */
- boolean exists(final P permissible);
-
- /**
- * Checks if the permissible exists in the database by id.
- *
- * @param id the id of the permissible
- * @return {@code true} if the permissible exists, {@code false} otherwise
- */
- default boolean existsById(final String id) {
- return this.findById(id).isPresent();
- }
-
- /**
- * Returns the number of permissibles.
- */
- long count();
-
- /**
- * Deletes the given permissible by id if it exists.
- *
- * @param id the id of the permissible to delete
- */
- void deleteById(final String id);
-
- /**
- * Deletes the given permissible.
- *
- * @param permissible the permissible to delete
- */
- void delete(final P permissible);
-
- /**
- * Deletes all the permissibles.
- */
- void deleteAll();
-
- /**
- * Deletes all the given permissibles in bulk.
- *
- * @param permissibles the permissibles to delete
- */
- default void deleteAll(final Iterable
permissibles) {
- permissibles.forEach(this::delete);
- }
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissionService.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissionService.java
deleted file mode 100644
index 54c022bf..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PermissionService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security.permission;
-
-import fr.xpdustry.distributor.api.util.MUUID;
-import fr.xpdustry.distributor.api.util.Tristate;
-
-/**
- * A service that manages permissions.
- */
-public interface PermissionService {
-
- /**
- * Looks up the permission of a player. Taking into account:
- *
- *
the player's parent groups
- *
the player's validation status
- *
- *
- * @param muuid the player's muuid.
- * @return the state of the permission for the player.
- */
- Tristate getPlayerPermission(final MUUID muuid, final String permission);
-
- /**
- * Looks up the permission of a player. Taking into account:
- *
- *
the player's parent groups
- *
- *
- * @param uuid the player's uuid.
- * @return the state of the permission for the player.
- */
- Tristate getPlayerPermission(final String uuid, final String permission);
-
- /**
- * Looks up the permission of a group. Taking into account:
- *
- *
the group's parent groups
- *
- *
- * @param group the group's name.
- * @return the state of the permission for the group.
- */
- Tristate getGroupPermission(final String group, final String permission);
-
- /**
- * Returns the permissible manager for players.
- */
- PermissibleManager getPlayerPermissionManager();
-
- /**
- * Returns the permissible manager for groups.
- */
- PermissibleManager getGroupPermissionManager();
-}
diff --git a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PlayerPermissible.java b/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PlayerPermissible.java
deleted file mode 100644
index 880e1385..00000000
--- a/distributor-api/src/main/java/fr/xpdustry/distributor/api/security/permission/PlayerPermissible.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.security.permission;
-
-/**
- * A permissible representing a specific player.
- */
-public interface PlayerPermissible extends Permissible {
-
- /**
- * Returns the UUID of this player.
- */
- String getUuid();
-}
diff --git a/distributor-api/src/test/java/fr/xpdustry/distributor/api/command/argument/AbstractArgumentTest.java b/distributor-api/src/test/java/fr/xpdustry/distributor/api/command/argument/AbstractArgumentTest.java
deleted file mode 100644
index 185e8b6f..00000000
--- a/distributor-api/src/test/java/fr/xpdustry/distributor/api/command/argument/AbstractArgumentTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Distributor, a feature-rich framework for Mindustry plugins.
- *
- * Copyright (C) 2023 Xpdustry
- *
- * 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 .
- */
-package fr.xpdustry.distributor.api.command.argument;
-
-import cloud.commandframework.arguments.CommandArgument;
-import cloud.commandframework.context.CommandContext;
-import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
-import java.util.ArrayDeque;
-import java.util.Arrays;
-import java.util.Queue;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public abstract class AbstractArgumentTest> {
-
- private CommandContext