use of com.velocitypowered.api.plugin.PluginContainer in project LibertyBans by A248.
the class VelocityLauncherTest method allBindings.
@Test
public void allBindings() {
ProxyServer proxyServer = mock(ProxyServer.class);
PluginContainer pluginContainer = mock(PluginContainer.class);
assertNotNull(new VelocityLauncher(Map.entry(pluginContainer, proxyServer), tempDir).launch());
}
use of com.velocitypowered.api.plugin.PluginContainer in project LibertyBans by A248.
the class VelocityInitializer method initialize.
BaseFoundation initialize() {
Platform platform = detectPlatform();
ProxyServer server = velocityPlugin.server;
Path folder = velocityPlugin.folder;
Logger logger = velocityPlugin.logger;
PluginContainer plugin = server.getPluginManager().fromInstance(velocityPlugin).get();
Scheduler scheduler = server.getScheduler();
Executor executor = (cmd) -> scheduler.buildTask(plugin, cmd).schedule();
Path jarFile = plugin.getDescription().getSource().get();
LibertyBansLauncher launcher = new LibertyBansLauncher(new Slf4jBootstrapLogger(velocityPlugin.logger), platform, velocityPlugin.folder, executor, jarFile, new VelocityCulpritFinder(server));
ClassLoader launchLoader = launcher.attemptLaunch().join();
if (launchLoader == null) {
logger.warn("Failed to launch LibertyBans");
return null;
}
BaseFoundation base;
try {
base = new Instantiator("space.arim.libertybans.env.velocity.VelocityLauncher", launchLoader).invoke(Map.Entry.class, Map.entry(plugin, server), folder);
} catch (IllegalArgumentException | SecurityException | ReflectiveOperationException ex) {
logger.warn("Failed to launch LibertyBans", ex);
return null;
}
base.startup();
return base;
}
use of com.velocitypowered.api.plugin.PluginContainer in project HuskChat by WiIIiam278.
the class HuskChatVelocity method onProxyInitialization.
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
instance = this;
// Load config
reloadSettings();
// Load messages
reloadMessages();
// Setup player data getter
Optional<PluginContainer> luckPerms = getProxyServer().getPluginManager().getPlugin("luckperms");
if (luckPerms.isPresent()) {
playerDataGetter = new LuckPermsDataGetter();
} else {
playerDataGetter = new DefaultDataGetter();
}
// Register events
getProxyServer().getEventManager().register(this, new VelocityListener());
// Register commands
new VelocityCommand(new HuskChatCommand(this));
new VelocityCommand(new ChannelCommand(this));
if (Settings.doMessageCommand) {
new VelocityCommand(new MsgCommand(this));
new VelocityCommand(new ReplyCommand(this));
}
if (Settings.doBroadcastCommand) {
new VelocityCommand(new BroadcastCommand(this));
}
if (Settings.doSocialSpyCommand) {
new VelocityCommand(new SocialSpyCommand(this));
}
if (Settings.doLocalSpyCommand) {
new VelocityCommand(new LocalSpyCommand(this));
}
// Register shortcut commands
for (Channel channel : Settings.channels) {
for (String command : channel.shortcutCommands) {
new VelocityCommand(new ShortcutCommand(command, channel.id, this));
}
}
// Initialise metrics
metricsFactory.make(this, METRICS_ID);
// Plugin startup logic
getLoggingAdapter().info("Enabled HuskChat version " + getMetaVersion());
}
use of com.velocitypowered.api.plugin.PluginContainer in project LimboAPI by Elytrium.
the class EventManagerHook method reloadHandlers.
@SuppressWarnings("rawtypes")
public void reloadHandlers() throws IllegalAccessException {
ListMultimap<Class<?>, ?> handlersMap = (ListMultimap<Class<?>, ?>) handlersMapField.get(this);
List disabledHandlers = handlersMap.get(GameProfileRequestEvent.class);
List preEvents = new ArrayList();
List newHandlers = new ArrayList(disabledHandlers);
if (this.handlerRegistrations != null) {
for (int i = 0; i < Array.getLength(this.handlerRegistrations); i++) {
preEvents.add(Array.get(this.handlerRegistrations, i));
}
}
for (Object handler : disabledHandlers) {
PluginContainer pluginContainer = (PluginContainer) pluginField.get(handler);
String id = pluginContainer.getDescription().getId();
if (Settings.IMP.MAIN.PRE_LIMBO_PROFILE_REQUEST_PLUGINS.contains(id)) {
this.plugin.getLogger().info("Hooking all GameProfileRequestEvent events from {} ", id);
preEvents.add(handler);
newHandlers.remove(handler);
}
}
handlersMap.replaceValues(GameProfileRequestEvent.class, newHandlers);
this.handlerRegistrations = Array.newInstance(handlerRegistration, preEvents.size());
for (int i = 0; i < preEvents.size(); i++) {
Array.set(this.handlerRegistrations, i, preEvents.get(i));
}
this.hasHandlerRegistration = preEvents.size() != 0;
}
use of com.velocitypowered.api.plugin.PluginContainer in project Chocolate by GiansCode.
the class ChocolateInfoCommand method perform.
@Override
public void perform(CommandSource commandSource, String[] args) {
StringBuilder commandBuilder = new StringBuilder();
for (ChocolateCommand chocolateCommand : this.chocolatePlugin.getCommandRegister().getChocolateCommands()) {
commandBuilder.append(StringUtils.getInstance().replacePlaceholders(Lang.COMMAND$CHOCOLATE$COMMAND_FORMAT.getString(), "%usage%", chocolateCommand.usage, "%description%", chocolateCommand.description)).append("\n");
}
Optional<PluginContainer> optional = chocolatePlugin.getServer().getPluginManager().getPlugin("chocolate");
if (!optional.isPresent())
return;
PluginDescription pluginDescription = optional.get().getDescription();
sendMessage(commandSource, StringUtils.getInstance().replacePlaceholders(Lang.COMMAND$CHOCOLATE$MSG.getString(), "%authors%", String.join(", ", pluginDescription.getAuthors()), "%commands%", commandBuilder.toString()));
}
Aggregations