Package be.seeseemelk.mockbukkit.plugin
Class PluginManagerMock
java.lang.Object
be.seeseemelk.mockbukkit.PermissionManagerMock
be.seeseemelk.mockbukkit.plugin.PluginManagerMock
- All Implemented Interfaces:
PermissionManager,PluginManager
Mock implementation of a
PluginManager.-
Constructor Summary
ConstructorsConstructorDescriptionPluginManagerMock(@NotNull ServerMock server) Constructs a newPluginManagerMockfor the providedServerMock. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCommandsFrom(@NotNull Plugin plugin) Add commands from a certain plugin to the internal list of commands.voidassertEventFired(@NotNull Class<? extends Event> eventClass) Asserts that a specific event or one of it's sub-events has been fired at least once.<T extends Event>
voidassertEventFired(@NotNull Class<T> eventClass, @NotNull Predicate<T> predicate) Asserts that there is at least one event of a certain class for which the predicate is true.<T extends Event>
voidassertEventFired(@Nullable String message, @NotNull Class<T> eventClass, @NotNull Predicate<T> predicate) Asserts that there is at least one event of a certain class for which the predicate is true.voidassertEventFired(@Nullable String message, @NotNull Predicate<Event> predicate) Asserts that at least one event conforms to the given predicate.voidassertEventFired(@NotNull Predicate<Event> predicate) Asserts that at least one event conforms to the given predicate.voidassertEventNotFired(@NotNull Class<? extends Event> eventClass) Asserts that a specific event or one of it's sub-event has not been fired.voidassertEventNotFired(@NotNull Class<? extends Event> eventClass, @Nullable String message) Asserts that a specific event or one of it's sub-event has not been fired.voidvoidcallEventAsynchronously(@NotNull Event event) <T extends Event>
voidcallEventAsynchronously(T event, @Nullable Consumer<T> func) voidThis method clears the history ofevents.void@NotNull FilecreateTemporaryDirectory(@NotNull String name) Tries to create a temporary directory.@NotNull FilecreateTemporaryPluginFile(@NotNull String name) Tries to create a temporary plugin file.voiddisablePlugin(@NotNull Plugin plugin) voidvoidenablePlugin(@NotNull Plugin plugin) @NotNull Collection<PluginCommand> Get a collection of all available commands.@NotNull FileCreates a new unique temporary directory.Plugin @NotNull []booleanisPluginEnabled(@NotNull String name) booleanisPluginEnabled(@Nullable Plugin plugin) booleanisTransitiveDependency(PluginMeta pluginMeta, PluginMeta dependencyConfig) loadPlugin(@NotNull File file) @NotNull JavaPluginloadPlugin(@NotNull Class<? extends JavaPlugin> class1, Object @NotNull [] parameters) Load a plugin from a class.@NotNull JavaPluginloadPlugin(@NotNull Class<? extends JavaPlugin> class1, @NotNull PluginDescriptionFile description, @NotNull Object @NotNull [] parameters) Load a plugin from a class.Plugin[]loadPlugins(@NotNull File directory) @NotNull Plugin[]loadPlugins(@NotNull File[] files) voidoverridePermissionManager(@NotNull Plugin plugin, @Nullable PermissionManager permissionManager) voidregisterEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin) voidregisterEvent(@NotNull Class<? extends Event> event, @NotNull Listener listener, @NotNull EventPriority priority, @NotNull EventExecutor executor, @NotNull Plugin plugin, boolean ignoreCancelled) voidregisterEvents(@NotNull Listener listener, @NotNull Plugin plugin) voidregisterInterface(@NotNull Class<? extends PluginLoader> loader) voidregisterLoadedPlugin(@NotNull Plugin plugin) Registers a plugin that has already been loaded.voidunload()Should be called when the plugin manager is not used anymore.voidunregisterPluginEvents(@NotNull Plugin plugin) Unregisters all listeners for a plugin.booleanTimings are used for event timings on a live server - they serve no purpose during a artificial test environ.Methods inherited from class be.seeseemelk.mockbukkit.PermissionManagerMock
addPermission, addPermissions, clearPermissions, getDefaultPermissions, getDefaultPermSubscriptions, getPermission, getPermissions, getPermissionSubscriptions, recalculatePermissionDefaults, removePermission, removePermission, subscribeToDefaultPerms, subscribeToPermission, unsubscribeFromDefaultPerms, unsubscribeFromPermissionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.papermc.paper.plugin.PermissionManager
addPermissions, clearPermissionsMethods inherited from interface org.bukkit.plugin.PluginManager
addPermission, getDefaultPermissions, getDefaultPermSubscriptions, getPermission, getPermissions, getPermissionSubscriptions, recalculatePermissionDefaults, removePermission, removePermission, subscribeToDefaultPerms, subscribeToPermission, unsubscribeFromDefaultPerms, unsubscribeFromPermission
-
Constructor Details
-
PluginManagerMock
Constructs a newPluginManagerMockfor the providedServerMock.- Parameters:
server- The server this is for.
-
-
Method Details
-
unload
public void unload()Should be called when the plugin manager is not used anymore. -
assertEventFired
public void assertEventFired(@Nullable @Nullable String message, @NotNull @NotNull Predicate<Event> predicate) Asserts that at least one event conforms to the given predicate.- Parameters:
message- The message to display when no event conforms.predicate- The predicate to test against.
-
assertEventFired
Asserts that at least one event conforms to the given predicate.- Parameters:
predicate- The predicate to test against.
-
assertEventFired
public <T extends Event> void assertEventFired(@Nullable @Nullable String message, @NotNull @NotNull Class<T> eventClass, @NotNull @NotNull Predicate<T> predicate) Asserts that there is at least one event of a certain class for which the predicate is true.- Type Parameters:
T- The type of event that is expected.- Parameters:
message- The message to display if no event is found.eventClass- The class type that the event should be an instance of.predicate- The predicate to test the event against.
-
assertEventFired
public <T extends Event> void assertEventFired(@NotNull @NotNull Class<T> eventClass, @NotNull @NotNull Predicate<T> predicate) Asserts that there is at least one event of a certain class for which the predicate is true.- Type Parameters:
T- The type of event that is expected.- Parameters:
eventClass- The class type that the event should be an instance of.predicate- The predicate to test the event against.
-
assertEventFired
Asserts that a specific event or one of it's sub-events has been fired at least once.- Parameters:
eventClass- The class of the event to check for.
-
assertEventNotFired
Asserts that a specific event or one of it's sub-event has not been fired.- Parameters:
eventClass- The class of the event to check for.
-
assertEventNotFired
public void assertEventNotFired(@NotNull @NotNull Class<? extends Event> eventClass, @Nullable @Nullable String message) Asserts that a specific event or one of it's sub-event has not been fired.- Parameters:
eventClass- The class of the event to check for.message- The message to print when failed.
-
getPlugin
- Specified by:
getPluginin interfacePluginManager
-
getPlugins
- Specified by:
getPluginsin interfacePluginManager
-
getCommands
Get a collection of all available commands.- Returns:
- A collection of all available commands.
-
getParentTemporaryDirectory
Creates a new unique temporary directory.- Returns:
- The directory.
- Throws:
IOException- If an IO error occurs.
-
createTemporaryDirectory
@NotNull public @NotNull File createTemporaryDirectory(@NotNull @NotNull String name) throws IOException Tries to create a temporary directory.- Parameters:
name- The name of the directory to create.- Returns:
- The created temporary directory.
- Throws:
IOException- when the directory could not be created.
-
createTemporaryPluginFile
@NotNull public @NotNull File createTemporaryPluginFile(@NotNull @NotNull String name) throws IOException Tries to create a temporary plugin file.- Parameters:
name- The name of the plugin.- Returns:
- The created temporary file.
- Throws:
IOException- when the file could not be created.
-
registerLoadedPlugin
Registers a plugin that has already been loaded. This is necessary to register plugins loaded from external jars.- Parameters:
plugin- The plugin that has been loaded.
-
loadPlugin
@NotNull public @NotNull JavaPlugin loadPlugin(@NotNull @NotNull Class<? extends JavaPlugin> class1, @NotNull @NotNull PluginDescriptionFile description, @NotNull @NotNull Object @NotNull [] parameters) Load a plugin from a class. It will use the system resourceplugin.ymlas the resource file.- Parameters:
class1- The plugin to load.description- ThePluginDescriptionFilethat contains information about the plugin.parameters- Extra parameters to pass on to the plugin constructor. Must not benull.- Returns:
- The loaded plugin.
-
loadPlugin
@NotNull public @NotNull JavaPlugin loadPlugin(@NotNull @NotNull Class<? extends JavaPlugin> class1, Object @NotNull [] parameters) Load a plugin from a class. It will use the system resourceplugin.ymlas the resource file.- Parameters:
class1- The plugin to load.parameters- Extra parameters to pass on to the plugin constructor.- Returns:
- The loaded plugin.
-
callEvent
- Specified by:
callEventin interfacePluginManager
-
callEventAsynchronously
- Parameters:
event- The asynchronousEventto call.
-
callEventAsynchronously
public <T extends Event> void callEventAsynchronously(@NotNull T event, @Nullable @Nullable Consumer<T> func) - Type Parameters:
T- The event type.- Parameters:
event- The asynchronousEventto call.func- A function to invoke after the event has been called.
-
enablePlugin
- Specified by:
enablePluginin interfacePluginManager
-
addCommandsFrom
Add commands from a certain plugin to the internal list of commands.- Parameters:
plugin- The plugin from which to read commands.
-
registerInterface
public void registerInterface(@NotNull @NotNull Class<? extends PluginLoader> loader) throws IllegalArgumentException - Specified by:
registerInterfacein interfacePluginManager- Throws:
IllegalArgumentException
-
isPluginEnabled
- Specified by:
isPluginEnabledin interfacePluginManager
-
isPluginEnabled
- Specified by:
isPluginEnabledin interfacePluginManager
-
loadPlugin
- Specified by:
loadPluginin interfacePluginManager- Throws:
UnknownDependencyException
-
loadPlugins
- Specified by:
loadPluginsin interfacePluginManager
-
loadPlugins
- Specified by:
loadPluginsin interfacePluginManager
-
disablePlugins
public void disablePlugins()- Specified by:
disablePluginsin interfacePluginManager
-
clearPlugins
public void clearPlugins()- Specified by:
clearPluginsin interfacePluginManager
-
clearEvents
public void clearEvents()This method clears the history ofevents. Doing that can be very useful if you want to assert fresh events usingassertEventFired(Class)or similar. -
registerEvents
- Specified by:
registerEventsin interfacePluginManager
-
unregisterPluginEvents
Unregisters all listeners for a plugin.- Parameters:
plugin- The plugin.
-
registerEvent
public void registerEvent(@NotNull @NotNull Class<? extends Event> event, @NotNull @NotNull Listener listener, @NotNull @NotNull EventPriority priority, @NotNull @NotNull EventExecutor executor, @NotNull @NotNull Plugin plugin) - Specified by:
registerEventin interfacePluginManager
-
registerEvent
public void registerEvent(@NotNull @NotNull Class<? extends Event> event, @NotNull @NotNull Listener listener, @NotNull @NotNull EventPriority priority, @NotNull @NotNull EventExecutor executor, @NotNull @NotNull Plugin plugin, boolean ignoreCancelled) - Specified by:
registerEventin interfacePluginManager
-
disablePlugin
- Specified by:
disablePluginin interfacePluginManager
-
useTimings
public boolean useTimings()Timings are used for event timings on a live server - they serve no purpose during a artificial test environ.- Specified by:
useTimingsin interfacePluginManager- Returns:
- boolean.false
-
isTransitiveDependency
- Specified by:
isTransitiveDependencyin interfacePluginManager
-
overridePermissionManager
public void overridePermissionManager(@NotNull @NotNull Plugin plugin, @Nullable @Nullable PermissionManager permissionManager) - Specified by:
overridePermissionManagerin interfacePluginManager
-