Skip to content

Commit

Permalink
Make contract for core specific listeners and commands
Browse files Browse the repository at this point in the history
  • Loading branch information
benwoo1110 committed Sep 15, 2024
1 parent c3674e0 commit a68b78e
Show file tree
Hide file tree
Showing 37 changed files with 57 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
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;
Expand All @@ -27,13 +26,13 @@
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;

Check warning on line 36 in src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Wrong order for 'org.mvplugins.multiverse.core.inject.PluginServiceLocator' import. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java:36:1: warning: Wrong order for 'org.mvplugins.multiverse.core.inject.PluginServiceLocator' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import org.mvplugins.multiverse.core.inject.PluginServiceLocatorFactory;
import org.mvplugins.multiverse.core.placeholders.MultiverseCorePlaceholders;
Expand Down Expand Up @@ -197,7 +196,7 @@ private void loadAnchors() {
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);
Expand All @@ -209,7 +208,7 @@ private void registerEvents() {
*/
private void registerCommands() {
Try.of(() -> commandManagerProvider.get())
.andThenTry(commandManager -> serviceLocator.getAllServices(MultiverseCommand.class)
.andThenTry(commandManager -> serviceLocator.getAllServices(CoreCommand.class)
.forEach(commandManager::registerCommand))

Check warning on line 212 in src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 '.' has incorrect indentation level 24, expected level should be 16. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/MultiverseCore.java:212:25: warning: '.' has incorrect indentation level 24, expected level should be 16. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
.onFailure(e -> {
Logging.severe("Failed to register commands");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Service
@CommandAlias("mv")
class CheckCommand extends MultiverseCommand {
class CheckCommand extends CoreCommand {

private final DestinationsProvider destinationsProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@Service
@CommandAlias("mv")
class CloneCommand extends MultiverseCommand {
class CloneCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

@Service
@CommandAlias("mv")
class ConfigCommand extends MultiverseCommand {
class ConfigCommand extends CoreCommand {

private final MVCoreConfig config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@Service
@CommandAlias("mv")
class ConfirmCommand extends MultiverseCommand {
class ConfirmCommand extends CoreCommand {

@Inject
ConfirmCommand(@NotNull MVCommandManager commandManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@Service
@CommandAlias("mv")
class CoordinatesCommand extends MultiverseCommand {
class CoordinatesCommand extends CoreCommand {

private final LocationManipulation locationManipulation;

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

@Service
@CommandAlias("mv")
class CreateCommand extends MultiverseCommand {
class CreateCommand extends CoreCommand {

private final WorldManager worldManager;
private GeneratorProvider generatorProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@Service
@CommandAlias("mv")
class DebugCommand extends MultiverseCommand {
class DebugCommand extends CoreCommand {

private final MVCoreConfig config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

@Service
@CommandAlias("mv")
class DeleteCommand extends MultiverseCommand {
class DeleteCommand extends CoreCommand {

private final WorldManager worldManager;
private final PlayerWorldTeleporter playerWorldTeleporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

@Service
@CommandAlias("mv")
class DumpsCommand extends MultiverseCommand {
class DumpsCommand extends CoreCommand {

private final MultiverseCore plugin;
private final WorldManager worldManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
@Service
@CommandAlias("mv")
class GeneratorsCommand extends MultiverseCommand {
class GeneratorsCommand extends CoreCommand {

private final GeneratorProvider generatorProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@Service
@CommandAlias("mv")
class ImportCommand extends MultiverseCommand {
class ImportCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

@Service
@CommandAlias("mv")
class InfoCommand extends MultiverseCommand {
class InfoCommand extends CoreCommand {

private final CommandValueFlag<Integer> PAGE_FLAG = flag(CommandValueFlag
.builder("--page", Integer.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@Service
@CommandAlias("mv")
class ListCommand extends MultiverseCommand {
class ListCommand extends CoreCommand {

private final WorldManager worldManager;
private final WorldEntryCheckerProvider worldEntryCheckerProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@Service
@CommandAlias("mv")
class LoadCommand extends MultiverseCommand {
class LoadCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

@Service
@CommandAlias("mv")
class ModifyCommand extends MultiverseCommand {
class ModifyCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

@Service
@CommandAlias("mv")
class RegenCommand extends MultiverseCommand {
class RegenCommand extends CoreCommand {

private final WorldManager worldManager;
private final PlayerWorldTeleporter playerWorldTeleporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@Service
@CommandAlias("mv")
class ReloadCommand extends MultiverseCommand {
class ReloadCommand extends CoreCommand {

private final MVCoreConfig config;
private final AnchorManager anchorManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@Service
@CommandAlias("mv")
class RemoveCommand extends MultiverseCommand {
class RemoveCommand extends CoreCommand {

private final WorldManager worldManager;
private final PlayerWorldTeleporter playerWorldTeleporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.mvplugins.multiverse.core.utils.MVCorei18n;

@Service
class RootCommand extends MultiverseCommand {
class RootCommand extends CoreCommand {

private final Plugin plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@Service
@CommandAlias("mv")
public class SetSpawnCommand extends MultiverseCommand {
public class SetSpawnCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

@Service
@CommandAlias("mv")
class SpawnCommand extends MultiverseCommand {
class SpawnCommand extends CoreCommand {
private final WorldManager worldManager;
private final AsyncSafetyTeleporter safetyTeleporter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

@Service
@CommandAlias("mv")
class TeleportCommand extends MultiverseCommand {
class TeleportCommand extends CoreCommand {

private final CorePermissionsChecker permissionsChecker;
private final AsyncSafetyTeleporter safetyTeleporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

@Service
@CommandAlias("mv")
class UnloadCommand extends MultiverseCommand {
class UnloadCommand extends CoreCommand {

private final WorldManager worldManager;
private final PlayerWorldTeleporter playerWorldTeleporter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@Service
@CommandAlias("mv")
class UsageCommand extends MultiverseCommand {
class UsageCommand extends CoreCommand {

@Inject
UsageCommand(@NotNull MVCommandManager commandManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@Service
@CommandAlias("mv")
class VersionCommand extends MultiverseCommand {
class VersionCommand extends CoreCommand {

private final MultiverseCore plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

@Service
@CommandAlias("mv")
public class WhoCommand extends MultiverseCommand {
public class WhoCommand extends CoreCommand {

private final WorldManager worldManager;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.mvplugins.multiverse.core.listeners;

import org.bukkit.event.Listener;
import org.jvnet.hk2.annotations.Contract;

@Contract

Check warning on line 6 in src/main/java/org/mvplugins/multiverse/core/listeners/CoreListener.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 Missing a Javadoc comment. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/listeners/CoreListener.java:6:1: warning: Missing a Javadoc comment. (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck)
public interface CoreListener extends Listener { }

Check warning on line 7 in src/main/java/org/mvplugins/multiverse/core/listeners/CoreListener.java

View workflow job for this annotation

GitHub Actions / checkstyle / checkstyle

[checkstyle] reported by reviewdog 🐶 '}' at column 50 should be alone on a line. Raw Output: /github/workspace/./src/main/java/org/mvplugins/multiverse/core/listeners/CoreListener.java:7:50: warning: '}' at column 50 should be alone on a line. (RightCurlyAlone)
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
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;

/**
* Multiverse's Entity {@link Listener}.
*/
@Service
public class MVEntityListener implements InjectableListener {
public class MVEntityListener implements CoreListener {
private final WorldManager worldManager;
private final WorldPurger worldPurger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
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;
Expand All @@ -54,7 +53,7 @@
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
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;
Expand All @@ -30,7 +29,7 @@
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
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;

Expand Down
Loading

0 comments on commit a68b78e

Please sign in to comment.