Implement velocity listeners / events
This commit is contained in:
parent
779f4785e0
commit
d96398f4a9
14 changed files with 130 additions and 52 deletions
|
|
@ -7,7 +7,7 @@ import java.util.logging.Logger;
|
||||||
import net.frankheijden.serverutils.bukkit.ServerUtils;
|
import net.frankheijden.serverutils.bukkit.ServerUtils;
|
||||||
import net.frankheijden.serverutils.bukkit.commands.BukkitCommandPlugins;
|
import net.frankheijden.serverutils.bukkit.commands.BukkitCommandPlugins;
|
||||||
import net.frankheijden.serverutils.bukkit.commands.BukkitCommandServerUtils;
|
import net.frankheijden.serverutils.bukkit.commands.BukkitCommandServerUtils;
|
||||||
import net.frankheijden.serverutils.bukkit.listeners.BukkitListener;
|
import net.frankheijden.serverutils.bukkit.listeners.BukkitPlayerListener;
|
||||||
import net.frankheijden.serverutils.bukkit.managers.BukkitPluginManager;
|
import net.frankheijden.serverutils.bukkit.managers.BukkitPluginManager;
|
||||||
import net.frankheijden.serverutils.bukkit.managers.BukkitTaskManager;
|
import net.frankheijden.serverutils.bukkit.managers.BukkitTaskManager;
|
||||||
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
||||||
|
|
@ -94,7 +94,7 @@ public class BukkitPlugin extends ServerUtilsPlugin<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enablePlugin() {
|
protected void enablePlugin() {
|
||||||
Bukkit.getPluginManager().registerEvents(new BukkitListener(this), plugin);
|
Bukkit.getPluginManager().registerEvents(new BukkitPlayerListener(this), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,15 @@ package net.frankheijden.serverutils.bukkit.listeners;
|
||||||
|
|
||||||
import net.frankheijden.serverutils.bukkit.entities.BukkitCommandSender;
|
import net.frankheijden.serverutils.bukkit.entities.BukkitCommandSender;
|
||||||
import net.frankheijden.serverutils.bukkit.entities.BukkitPlugin;
|
import net.frankheijden.serverutils.bukkit.entities.BukkitPlugin;
|
||||||
import net.frankheijden.serverutils.common.listeners.ServerListener;
|
import net.frankheijden.serverutils.common.listeners.PlayerListener;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
public class BukkitListener extends ServerListener<
|
public class BukkitPlayerListener extends PlayerListener<BukkitPlugin, BukkitCommandSender> implements Listener {
|
||||||
BukkitPlugin,
|
|
||||||
Plugin,
|
|
||||||
BukkitTask,
|
|
||||||
BukkitCommandSender,
|
|
||||||
CommandSender
|
|
||||||
> implements Listener {
|
|
||||||
|
|
||||||
public BukkitListener(BukkitPlugin plugin) {
|
public BukkitPlayerListener(BukkitPlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.logging.Logger;
|
||||||
import net.frankheijden.serverutils.bungee.ServerUtils;
|
import net.frankheijden.serverutils.bungee.ServerUtils;
|
||||||
import net.frankheijden.serverutils.bungee.commands.BungeeCommandPlugins;
|
import net.frankheijden.serverutils.bungee.commands.BungeeCommandPlugins;
|
||||||
import net.frankheijden.serverutils.bungee.commands.BungeeCommandServerUtils;
|
import net.frankheijden.serverutils.bungee.commands.BungeeCommandServerUtils;
|
||||||
import net.frankheijden.serverutils.bungee.listeners.BungeeServerListener;
|
import net.frankheijden.serverutils.bungee.listeners.BungeePlayerListener;
|
||||||
import net.frankheijden.serverutils.bungee.managers.BungeePluginManager;
|
import net.frankheijden.serverutils.bungee.managers.BungeePluginManager;
|
||||||
import net.frankheijden.serverutils.bungee.managers.BungeeTaskManager;
|
import net.frankheijden.serverutils.bungee.managers.BungeeTaskManager;
|
||||||
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
||||||
|
|
@ -87,7 +87,7 @@ public class BungeePlugin extends ServerUtilsPlugin<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void enablePlugin() {
|
protected void enablePlugin() {
|
||||||
plugin.getProxy().getPluginManager().registerListener(plugin, new BungeeServerListener(this));
|
plugin.getProxy().getPluginManager().registerListener(plugin, new BungeePlayerListener(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,14 @@ package net.frankheijden.serverutils.bungee.listeners;
|
||||||
|
|
||||||
import net.frankheijden.serverutils.bungee.entities.BungeeCommandSender;
|
import net.frankheijden.serverutils.bungee.entities.BungeeCommandSender;
|
||||||
import net.frankheijden.serverutils.bungee.entities.BungeePlugin;
|
import net.frankheijden.serverutils.bungee.entities.BungeePlugin;
|
||||||
import net.frankheijden.serverutils.common.listeners.ServerListener;
|
import net.frankheijden.serverutils.common.listeners.PlayerListener;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
|
||||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
|
||||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
public class BungeeServerListener extends ServerListener<
|
public class BungeePlayerListener extends PlayerListener<BungeePlugin, BungeeCommandSender> implements Listener {
|
||||||
BungeePlugin,
|
|
||||||
Plugin,
|
|
||||||
ScheduledTask,
|
|
||||||
BungeeCommandSender,
|
|
||||||
CommandSender
|
|
||||||
> implements Listener {
|
|
||||||
|
|
||||||
public BungeeServerListener(BungeePlugin plugin) {
|
public BungeePlayerListener(BungeePlugin plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4,15 +4,10 @@ import net.frankheijden.serverutils.common.entities.ServerCommandSender;
|
||||||
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
||||||
import net.frankheijden.serverutils.common.tasks.UpdateCheckerTask;
|
import net.frankheijden.serverutils.common.tasks.UpdateCheckerTask;
|
||||||
|
|
||||||
public abstract class ServerListener<
|
public abstract class PlayerListener<U extends ServerUtilsPlugin<?, ?, C, ?>, C extends ServerCommandSender<?>>
|
||||||
U extends ServerUtilsPlugin<P, T, C, S>,
|
extends ServerUtilsListener<U, C> {
|
||||||
P,
|
|
||||||
T,
|
|
||||||
C extends ServerCommandSender<S>,
|
|
||||||
S
|
|
||||||
> extends ServerUtilsListener<U, P, T, C, S> {
|
|
||||||
|
|
||||||
protected ServerListener(U plugin) {
|
protected PlayerListener(U plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3,13 +3,7 @@ package net.frankheijden.serverutils.common.listeners;
|
||||||
import net.frankheijden.serverutils.common.entities.ServerCommandSender;
|
import net.frankheijden.serverutils.common.entities.ServerCommandSender;
|
||||||
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
||||||
|
|
||||||
public abstract class ServerUtilsListener<
|
public abstract class ServerUtilsListener<U extends ServerUtilsPlugin<?, ?, C, ?>, C extends ServerCommandSender<?>> {
|
||||||
U extends ServerUtilsPlugin<P, T, C, S>,
|
|
||||||
P,
|
|
||||||
T,
|
|
||||||
C extends ServerCommandSender<S>,
|
|
||||||
S
|
|
||||||
> {
|
|
||||||
|
|
||||||
protected final U plugin;
|
protected final U plugin;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import net.frankheijden.serverutils.common.entities.ServerUtilsPlugin;
|
||||||
import net.frankheijden.serverutils.velocity.ServerUtils;
|
import net.frankheijden.serverutils.velocity.ServerUtils;
|
||||||
import net.frankheijden.serverutils.velocity.commands.VelocityCommandPlugins;
|
import net.frankheijden.serverutils.velocity.commands.VelocityCommandPlugins;
|
||||||
import net.frankheijden.serverutils.velocity.commands.VelocityCommandServerUtils;
|
import net.frankheijden.serverutils.velocity.commands.VelocityCommandServerUtils;
|
||||||
|
import net.frankheijden.serverutils.velocity.listeners.VelocityPlayerListener;
|
||||||
import net.frankheijden.serverutils.velocity.managers.VelocityPluginManager;
|
import net.frankheijden.serverutils.velocity.managers.VelocityPluginManager;
|
||||||
import net.frankheijden.serverutils.velocity.managers.VelocityTaskManager;
|
import net.frankheijden.serverutils.velocity.managers.VelocityTaskManager;
|
||||||
|
|
||||||
|
|
@ -85,6 +86,11 @@ public class VelocityPlugin extends ServerUtilsPlugin<
|
||||||
return this.plugin.getDataDirectory().toFile();
|
return this.plugin.getDataDirectory().toFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void enablePlugin() {
|
||||||
|
plugin.getProxy().getEventManager().register(plugin, new VelocityPlayerListener(this));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void reloadPlugin() {
|
protected void reloadPlugin() {
|
||||||
new VelocityCommandPlugins(this).register(commandManager);
|
new VelocityCommandPlugins(this).register(commandManager);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.events;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginDisableEvent;
|
||||||
|
|
||||||
|
public class VelocityPluginDisableEvent extends VelocityPluginEvent implements PluginDisableEvent<PluginContainer> {
|
||||||
|
|
||||||
|
public VelocityPluginDisableEvent(PluginContainer plugin, Stage stage) {
|
||||||
|
super(plugin, stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.events;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginEnableEvent;
|
||||||
|
|
||||||
|
public class VelocityPluginEnableEvent extends VelocityPluginEvent implements PluginEnableEvent<PluginContainer> {
|
||||||
|
|
||||||
|
public VelocityPluginEnableEvent(PluginContainer plugin, Stage stage) {
|
||||||
|
super(plugin, stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.events;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginEvent;
|
||||||
|
|
||||||
|
public abstract class VelocityPluginEvent implements PluginEvent<PluginContainer> {
|
||||||
|
|
||||||
|
private final PluginContainer plugin;
|
||||||
|
private final Stage stage;
|
||||||
|
|
||||||
|
protected VelocityPluginEvent(PluginContainer plugin, Stage stage) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.stage = stage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PluginContainer getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stage getStage() {
|
||||||
|
return stage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.events;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginLoadEvent;
|
||||||
|
|
||||||
|
public class VelocityPluginLoadEvent extends VelocityPluginEvent implements PluginLoadEvent<PluginContainer> {
|
||||||
|
|
||||||
|
public VelocityPluginLoadEvent(PluginContainer plugin, Stage stage) {
|
||||||
|
super(plugin, stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.events;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.plugin.PluginContainer;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginUnloadEvent;
|
||||||
|
|
||||||
|
public class VelocityPluginUnloadEvent extends VelocityPluginEvent implements PluginUnloadEvent<PluginContainer> {
|
||||||
|
|
||||||
|
public VelocityPluginUnloadEvent(PluginContainer plugin, Stage stage) {
|
||||||
|
super(plugin, stage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package net.frankheijden.serverutils.velocity.listeners;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
|
||||||
|
import net.frankheijden.serverutils.common.listeners.PlayerListener;
|
||||||
|
import net.frankheijden.serverutils.velocity.entities.VelocityCommandSender;
|
||||||
|
import net.frankheijden.serverutils.velocity.entities.VelocityPlugin;
|
||||||
|
|
||||||
|
public class VelocityPlayerListener extends PlayerListener<VelocityPlugin, VelocityCommandSender> {
|
||||||
|
|
||||||
|
public VelocityPlayerListener(VelocityPlugin plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPlayerChooseInitialServer(PlayerChooseInitialServerEvent event) {
|
||||||
|
handleUpdate(plugin.getChatProvider().get(event.getPlayer()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -28,9 +28,14 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import net.frankheijden.serverutils.common.entities.CloseableResult;
|
import net.frankheijden.serverutils.common.entities.CloseableResult;
|
||||||
import net.frankheijden.serverutils.common.entities.Result;
|
import net.frankheijden.serverutils.common.entities.Result;
|
||||||
|
import net.frankheijden.serverutils.common.events.PluginEvent;
|
||||||
import net.frankheijden.serverutils.common.managers.AbstractPluginManager;
|
import net.frankheijden.serverutils.common.managers.AbstractPluginManager;
|
||||||
import net.frankheijden.serverutils.velocity.ServerUtils;
|
import net.frankheijden.serverutils.velocity.ServerUtils;
|
||||||
import net.frankheijden.serverutils.velocity.entities.VelocityLoadResult;
|
import net.frankheijden.serverutils.velocity.entities.VelocityLoadResult;
|
||||||
|
import net.frankheijden.serverutils.velocity.events.VelocityPluginDisableEvent;
|
||||||
|
import net.frankheijden.serverutils.velocity.events.VelocityPluginEnableEvent;
|
||||||
|
import net.frankheijden.serverutils.velocity.events.VelocityPluginLoadEvent;
|
||||||
|
import net.frankheijden.serverutils.velocity.events.VelocityPluginUnloadEvent;
|
||||||
import net.frankheijden.serverutils.velocity.reflection.RJavaPluginLoader;
|
import net.frankheijden.serverutils.velocity.reflection.RJavaPluginLoader;
|
||||||
import net.frankheijden.serverutils.velocity.reflection.RVelocityCommandManager;
|
import net.frankheijden.serverutils.velocity.reflection.RVelocityCommandManager;
|
||||||
import net.frankheijden.serverutils.velocity.reflection.RVelocityConsole;
|
import net.frankheijden.serverutils.velocity.reflection.RVelocityConsole;
|
||||||
|
|
@ -79,12 +84,15 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
|
|
||||||
PluginDescription realPlugin = RJavaPluginLoader.loadPlugin(javaPluginLoader, candidate);
|
PluginDescription realPlugin = RJavaPluginLoader.loadPlugin(javaPluginLoader, candidate);
|
||||||
PluginContainer container = RVelocityPluginContainer.newInstance(realPlugin);
|
PluginContainer container = RVelocityPluginContainer.newInstance(realPlugin);
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginLoadEvent(container, PluginEvent.Stage.PRE));
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginLoadEvent(container, PluginEvent.Stage.POST));
|
||||||
|
|
||||||
return new VelocityLoadResult(container);
|
return new VelocityLoadResult(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result enablePlugin(PluginContainer container) {
|
public Result enablePlugin(PluginContainer container) {
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginEnableEvent(container, PluginEvent.Stage.PRE));
|
||||||
if (proxy.getPluginManager().isLoaded(container.getDescription().getId())) return Result.ALREADY_ENABLED;
|
if (proxy.getPluginManager().isLoaded(container.getDescription().getId())) return Result.ALREADY_ENABLED;
|
||||||
|
|
||||||
Object javaPluginLoader = RJavaPluginLoader.newInstance(
|
Object javaPluginLoader = RJavaPluginLoader.newInstance(
|
||||||
|
|
@ -130,12 +138,12 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
);
|
);
|
||||||
|
|
||||||
RVelocityPluginManager.registerPlugin(proxy.getPluginManager(), container);
|
RVelocityPluginManager.registerPlugin(proxy.getPluginManager(), container);
|
||||||
container.getInstance().ifPresent(instance -> {
|
container.getInstance().ifPresent(pluginInstance -> {
|
||||||
RVelocityEventManager.registerInternally(proxy.getEventManager(), container, instance);
|
RVelocityEventManager.registerInternally(proxy.getEventManager(), container, pluginInstance);
|
||||||
RVelocityEventManager.fireForPlugin(
|
RVelocityEventManager.fireForPlugin(
|
||||||
proxy.getEventManager(),
|
proxy.getEventManager(),
|
||||||
new ProxyInitializeEvent(),
|
new ProxyInitializeEvent(),
|
||||||
instance
|
pluginInstance
|
||||||
).join();
|
).join();
|
||||||
|
|
||||||
ConsoleCommandSource console = proxy.getConsoleCommandSource();
|
ConsoleCommandSource console = proxy.getConsoleCommandSource();
|
||||||
|
|
@ -146,7 +154,7 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
PermissionFunction permissionFunction = RVelocityEventManager.fireForPlugin(
|
PermissionFunction permissionFunction = RVelocityEventManager.fireForPlugin(
|
||||||
proxy.getEventManager(),
|
proxy.getEventManager(),
|
||||||
event,
|
event,
|
||||||
instance
|
pluginInstance
|
||||||
).join().createFunction(console);
|
).join().createFunction(console);
|
||||||
|
|
||||||
if (permissionFunction == null) {
|
if (permissionFunction == null) {
|
||||||
|
|
@ -162,12 +170,14 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
RVelocityConsole.setPermissionFunction(console, permissionFunction);
|
RVelocityConsole.setPermissionFunction(console, permissionFunction);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginEnableEvent(container, PluginEvent.Stage.POST));
|
||||||
return Result.SUCCESS;
|
return Result.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result disablePlugin(PluginContainer plugin) {
|
public Result disablePlugin(PluginContainer container) {
|
||||||
Object pluginInstance = plugin.getInstance().orElse(null);
|
proxy.getEventManager().fire(new VelocityPluginDisableEvent(container, PluginEvent.Stage.PRE));
|
||||||
|
Object pluginInstance = container.getInstance().orElse(null);
|
||||||
if (pluginInstance == null) return Result.NOT_EXISTS;
|
if (pluginInstance == null) return Result.NOT_EXISTS;
|
||||||
|
|
||||||
RVelocityEventManager.fireForPlugin(
|
RVelocityEventManager.fireForPlugin(
|
||||||
|
|
@ -176,6 +186,7 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
new ProxyShutdownEvent()
|
new ProxyShutdownEvent()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginDisableEvent(container, PluginEvent.Stage.POST));
|
||||||
return Result.SUCCESS;
|
return Result.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,8 +220,9 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloseableResult unloadPlugin(PluginContainer plugin) {
|
public CloseableResult unloadPlugin(PluginContainer container) {
|
||||||
Optional<?> pluginInstanceOptional = plugin.getInstance();
|
proxy.getEventManager().fire(new VelocityPluginUnloadEvent(container, PluginEvent.Stage.PRE));
|
||||||
|
Optional<?> pluginInstanceOptional = container.getInstance();
|
||||||
if (!pluginInstanceOptional.isPresent()) return new CloseableResult(Result.INVALID_PLUGIN);
|
if (!pluginInstanceOptional.isPresent()) return new CloseableResult(Result.INVALID_PLUGIN);
|
||||||
Object pluginInstance = pluginInstanceOptional.get();
|
Object pluginInstance = pluginInstanceOptional.get();
|
||||||
|
|
||||||
|
|
@ -219,7 +231,7 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
task.cancel();
|
task.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
String pluginId = plugin.getDescription().getId();
|
String pluginId = container.getDescription().getId();
|
||||||
VelocityPluginCommandManager pluginCommandManager = ServerUtils.getInstance().getPluginCommandManager();
|
VelocityPluginCommandManager pluginCommandManager = ServerUtils.getInstance().getPluginCommandManager();
|
||||||
for (String alias : pluginCommandManager.getPluginCommands().removeAll(pluginId)) {
|
for (String alias : pluginCommandManager.getPluginCommands().removeAll(pluginId)) {
|
||||||
proxy.getCommandManager().unregister(alias);
|
proxy.getCommandManager().unregister(alias);
|
||||||
|
|
@ -235,6 +247,7 @@ public class VelocityPluginManager implements AbstractPluginManager<PluginContai
|
||||||
closeables.add((Closeable) loader);
|
closeables.add((Closeable) loader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proxy.getEventManager().fire(new VelocityPluginUnloadEvent(container, PluginEvent.Stage.POST));
|
||||||
return new CloseableResult(closeables);
|
return new CloseableResult(closeables);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue