mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 10:36:06 +01:00
Make contract for core specific listeners and commands
This commit is contained in:
parent
c3674e0a2f
commit
a68b78e5a4
@ -18,7 +18,6 @@ import jakarta.inject.Provider;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -27,13 +26,13 @@ import org.jvnet.hk2.annotations.Service;
|
||||
import org.mvplugins.multiverse.core.anchor.AnchorManager;
|
||||
import org.mvplugins.multiverse.core.api.Destination;
|
||||
import org.mvplugins.multiverse.core.api.MVCore;
|
||||
import org.mvplugins.multiverse.core.commands.CoreCommand;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
import org.mvplugins.multiverse.core.commandtools.PluginLocales;
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
|
||||
import org.mvplugins.multiverse.core.economy.MVEconomist;
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.listeners.CoreListener;
|
||||
import org.mvplugins.multiverse.core.inject.PluginServiceLocator;
|
||||
import org.mvplugins.multiverse.core.inject.PluginServiceLocatorFactory;
|
||||
import org.mvplugins.multiverse.core.placeholders.MultiverseCorePlaceholders;
|
||||
@ -197,7 +196,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
private void registerEvents() {
|
||||
var pluginManager = getServer().getPluginManager();
|
||||
|
||||
Try.run(() -> serviceLocator.getAllServices(InjectableListener.class).forEach(
|
||||
Try.run(() -> serviceLocator.getAllServices(CoreListener.class).forEach(
|
||||
listener -> pluginManager.registerEvents(listener, this)))
|
||||
.onFailure(e -> {
|
||||
throw new RuntimeException("Failed to register listeners. Terminating...", e);
|
||||
@ -209,7 +208,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
|
||||
*/
|
||||
private void registerCommands() {
|
||||
Try.of(() -> commandManagerProvider.get())
|
||||
.andThenTry(commandManager -> serviceLocator.getAllServices(MultiverseCommand.class)
|
||||
.andThenTry(commandManager -> serviceLocator.getAllServices(CoreCommand.class)
|
||||
.forEach(commandManager::registerCommand))
|
||||
.onFailure(e -> {
|
||||
Logging.severe("Failed to register commands");
|
||||
|
@ -20,7 +20,7 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class CheckCommand extends MultiverseCommand {
|
||||
class CheckCommand extends CoreCommand {
|
||||
|
||||
private final DestinationsProvider destinationsProvider;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.mvplugins.multiverse.core.world.options.CloneWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class CloneCommand extends MultiverseCommand {
|
||||
class CloneCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -20,7 +20,7 @@ import org.mvplugins.multiverse.core.exceptions.MultiverseException;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ConfigCommand extends MultiverseCommand {
|
||||
class ConfigCommand extends CoreCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
|
||||
|
@ -14,7 +14,7 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ConfirmCommand extends MultiverseCommand {
|
||||
class ConfirmCommand extends CoreCommand {
|
||||
|
||||
@Inject
|
||||
ConfirmCommand(@NotNull MVCommandManager commandManager) {
|
||||
|
@ -19,7 +19,7 @@ import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class CoordinatesCommand extends MultiverseCommand {
|
||||
class CoordinatesCommand extends CoreCommand {
|
||||
|
||||
private final LocationManipulation locationManipulation;
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package org.mvplugins.multiverse.core.commands;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
|
||||
import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Contract
|
||||
public abstract class CoreCommand extends MultiverseCommand {
|
||||
protected CoreCommand(@NotNull MVCommandManager commandManager) {
|
||||
super(commandManager);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ import org.mvplugins.multiverse.core.world.options.CreateWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class CreateCommand extends MultiverseCommand {
|
||||
class CreateCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private GeneratorProvider generatorProvider;
|
||||
|
@ -19,7 +19,7 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class DebugCommand extends MultiverseCommand {
|
||||
class DebugCommand extends CoreCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
|
||||
|
@ -31,7 +31,7 @@ import org.mvplugins.multiverse.core.world.helpers.PlayerWorldTeleporter;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class DeleteCommand extends MultiverseCommand {
|
||||
class DeleteCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
@ -42,7 +42,7 @@ import static org.mvplugins.multiverse.core.utils.file.FileUtils.getServerProper
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class DumpsCommand extends MultiverseCommand {
|
||||
class DumpsCommand extends CoreCommand {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
private final WorldManager worldManager;
|
||||
|
@ -41,7 +41,7 @@ import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
@Subcommand("gamerule|rule|gamerules|rules")
|
||||
class GameruleCommand extends MultiverseCommand {
|
||||
class GameruleCommand extends CoreCommand {
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
|
@ -35,7 +35,7 @@ import org.mvplugins.multiverse.core.world.generators.GeneratorProvider;
|
||||
*/
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class GeneratorsCommand extends MultiverseCommand {
|
||||
class GeneratorsCommand extends CoreCommand {
|
||||
|
||||
private final GeneratorProvider generatorProvider;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.mvplugins.multiverse.core.world.options.ImportWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ImportCommand extends MultiverseCommand {
|
||||
class ImportCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import org.mvplugins.multiverse.core.world.MultiverseWorld;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class InfoCommand extends MultiverseCommand {
|
||||
class InfoCommand extends CoreCommand {
|
||||
|
||||
private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
|
||||
.builder("--page", Integer.class)
|
||||
|
@ -36,7 +36,7 @@ import org.mvplugins.multiverse.core.world.entrycheck.WorldEntryCheckerProvider;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ListCommand extends MultiverseCommand {
|
||||
class ListCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private final WorldEntryCheckerProvider worldEntryCheckerProvider;
|
||||
|
@ -21,7 +21,7 @@ import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class LoadCommand extends MultiverseCommand {
|
||||
class LoadCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ModifyCommand extends MultiverseCommand {
|
||||
class ModifyCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -34,7 +34,7 @@ import org.mvplugins.multiverse.core.world.options.RegenWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class RegenCommand extends MultiverseCommand {
|
||||
class RegenCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
@ -23,7 +23,7 @@ import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class ReloadCommand extends MultiverseCommand {
|
||||
class ReloadCommand extends CoreCommand {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
private final AnchorManager anchorManager;
|
||||
|
@ -29,7 +29,7 @@ import org.mvplugins.multiverse.core.world.helpers.PlayerWorldTeleporter;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class RemoveCommand extends MultiverseCommand {
|
||||
class RemoveCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
@ -14,7 +14,7 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
import org.mvplugins.multiverse.core.utils.MVCorei18n;
|
||||
|
||||
@Service
|
||||
class RootCommand extends MultiverseCommand {
|
||||
class RootCommand extends CoreCommand {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
|
@ -18,7 +18,7 @@ import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class SetSpawnCommand extends MultiverseCommand {
|
||||
public class SetSpawnCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -19,7 +19,7 @@ import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class SpawnCommand extends MultiverseCommand {
|
||||
class SpawnCommand extends CoreCommand {
|
||||
private final WorldManager worldManager;
|
||||
private final AsyncSafetyTeleporter safetyTeleporter;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class TeleportCommand extends MultiverseCommand {
|
||||
class TeleportCommand extends CoreCommand {
|
||||
|
||||
private final CorePermissionsChecker permissionsChecker;
|
||||
private final AsyncSafetyTeleporter safetyTeleporter;
|
||||
|
@ -28,7 +28,7 @@ import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class UnloadCommand extends MultiverseCommand {
|
||||
class UnloadCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
private final PlayerWorldTeleporter playerWorldTeleporter;
|
||||
|
@ -17,7 +17,7 @@ import org.mvplugins.multiverse.core.commandtools.MultiverseCommand;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class UsageCommand extends MultiverseCommand {
|
||||
class UsageCommand extends CoreCommand {
|
||||
|
||||
@Inject
|
||||
UsageCommand(@NotNull MVCommandManager commandManager) {
|
||||
|
@ -16,7 +16,7 @@ import org.mvplugins.multiverse.core.utils.MVCorei18n;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
class VersionCommand extends MultiverseCommand {
|
||||
class VersionCommand extends CoreCommand {
|
||||
|
||||
private final MultiverseCore plugin;
|
||||
|
||||
|
@ -37,7 +37,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@CommandAlias("mv")
|
||||
public class WhoCommand extends MultiverseCommand {
|
||||
public class WhoCommand extends CoreCommand {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
package org.mvplugins.multiverse.core.inject;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface InjectableListener extends Listener { }
|
@ -0,0 +1,7 @@
|
||||
package org.mvplugins.multiverse.core.listeners;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jvnet.hk2.annotations.Contract;
|
||||
|
||||
@Contract
|
||||
public interface CoreListener extends Listener { }
|
@ -7,14 +7,13 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
/**
|
||||
* Multiverse's Listener for players.
|
||||
*/
|
||||
@Service
|
||||
public class MVChatListener implements InjectableListener {
|
||||
public class MVChatListener implements CoreListener {
|
||||
private final MVCoreConfig config;
|
||||
private final WorldManager worldManager;
|
||||
private final MVPlayerListener playerListener;
|
||||
|
@ -20,7 +20,6 @@ import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.WorldPurger;
|
||||
|
||||
@ -28,7 +27,7 @@ import org.mvplugins.multiverse.core.world.WorldPurger;
|
||||
* Multiverse's Entity {@link Listener}.
|
||||
*/
|
||||
@Service
|
||||
public class MVEntityListener implements InjectableListener {
|
||||
public class MVEntityListener implements CoreListener {
|
||||
private final WorldManager worldManager;
|
||||
private final WorldPurger worldPurger;
|
||||
|
||||
|
@ -40,7 +40,6 @@ import org.mvplugins.multiverse.core.destination.DestinationsProvider;
|
||||
import org.mvplugins.multiverse.core.destination.ParsedDestination;
|
||||
import org.mvplugins.multiverse.core.economy.MVEconomist;
|
||||
import org.mvplugins.multiverse.core.event.MVRespawnEvent;
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
|
||||
import org.mvplugins.multiverse.core.teleportation.TeleportQueue;
|
||||
import org.mvplugins.multiverse.core.utils.result.ResultChain;
|
||||
@ -54,7 +53,7 @@ import org.mvplugins.multiverse.core.world.helpers.EnforcementHandler;
|
||||
* Multiverse's Listener for players.
|
||||
*/
|
||||
@Service
|
||||
public class MVPlayerListener implements InjectableListener {
|
||||
public class MVPlayerListener implements CoreListener {
|
||||
private final Plugin plugin;
|
||||
private final MVCoreConfig config;
|
||||
private final Provider<WorldManager> worldManagerProvider;
|
||||
|
@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.config.MVCoreConfig;
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
import static org.bukkit.PortalType.CUSTOM;
|
||||
@ -30,7 +29,7 @@ import static org.bukkit.PortalType.CUSTOM;
|
||||
* A custom listener for portal related events.
|
||||
*/
|
||||
@Service
|
||||
public class MVPortalListener implements InjectableListener {
|
||||
public class MVPortalListener implements CoreListener {
|
||||
|
||||
private final MVCoreConfig config;
|
||||
private final WorldManager worldManager;
|
||||
|
@ -14,14 +14,13 @@ import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
|
||||
/**
|
||||
* Multiverse's Weather Listener.
|
||||
*/
|
||||
@Service
|
||||
public class MVWeatherListener implements InjectableListener {
|
||||
public class MVWeatherListener implements CoreListener {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
@ -15,7 +15,6 @@ import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.jvnet.hk2.annotations.Service;
|
||||
|
||||
import org.mvplugins.multiverse.core.inject.InjectableListener;
|
||||
import org.mvplugins.multiverse.core.world.WorldManager;
|
||||
import org.mvplugins.multiverse.core.world.options.UnloadWorldOptions;
|
||||
import org.mvplugins.multiverse.core.world.reasons.LoadFailureReason;
|
||||
@ -25,7 +24,7 @@ import org.mvplugins.multiverse.core.world.reasons.UnloadFailureReason;
|
||||
* Multiverse's World Listener.
|
||||
*/
|
||||
@Service
|
||||
public class MVWorldListener implements InjectableListener {
|
||||
public class MVWorldListener implements CoreListener {
|
||||
|
||||
private final WorldManager worldManager;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user