/** * Called by the loader to initialize the fields in this plugin. * * @param proxy current proxy instance * @param description the description that describes this plugin */ final void init(ProxyServer proxy, PluginDescription description) { this.proxy = proxy; this.description = description; this.file = description.getFile(); this.logger = new PluginLogger( this ); }
/** * Checks if the command is registered and can possibly be executed by the * sender (without taking permissions into account). * * @param commandName the name of the command * @param sender the sender executing the command * @return whether the command will be handled */ public boolean isExecutableCommand(String commandName, CommandSender sender) { return getCommandIfEnabled( commandName, sender ) != null; }
@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { return loadClass0( name, resolve, true ); }
public void enablePlugins() { for ( Plugin plugin : plugins.values() ) { try { plugin.onEnable(); ProxyServer.getInstance().getLogger().log( Level.INFO, "Enabled plugin {0} version {1} by {2}", new Object[] { plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getAuthor() } ); } catch ( Throwable t ) { ProxyServer.getInstance().getLogger().log( Level.WARNING, "Exception encountered when loading plugin: " + plugin.getDescription().getName(), t ); } } }
@Override public void onEnable() { getProxy().getPluginManager().registerCommand( this, new CommandSend() ); } }
protected PluginLogger(Plugin plugin) { super( plugin.getClass().getCanonicalName(), null ); pluginName = "[" + plugin.getDescription().getName() + "] "; setParent( plugin.getProxy().getLogger() ); }
/** * Gets the data folder where this plugin may store arbitrary data. It will * be a child of {@link ProxyServer#getPluginsFolder()}. * * @return the data folder of this plugin */ public final File getDataFolder() { return new File( getProxy().getPluginsFolder(), getDescription().getName() ); }
@Deprecated public ExecutorService getExecutorService() { if ( service == null ) { String name = ( getDescription() == null ) ? "unknown" : getDescription().getName(); service = Executors.newCachedThreadPool( new ThreadFactoryBuilder().setNameFormat( name + " Pool Thread #%1$d" ) .setThreadFactory( new GroupedThreadFactory( this, name ) ).build() ); } return service; } //
public boolean dispatchCommand(CommandSender sender, String commandLine) { return dispatchCommand( sender, commandLine, null ); }
@Override public boolean hasPermission(String permission) { return bungee.getPluginManager().callEvent( new PermissionCheckEvent( this, permission, permissions.contains( permission ) ) ).hasPermission(); }
/** * Register a command so that it may be executed. * * @param plugin the plugin owning this command * @param command the command to register */ public void registerCommand(Plugin plugin, Command command) { commandMap.put( command.getName().toLowerCase( Locale.ROOT ), command ); for ( String alias : command.getAliases() ) { commandMap.put( alias.toLowerCase( Locale.ROOT ), command ); } commandsByPlugin.put( plugin, command ); }
@Override public ExecutorService getExecutorService(Plugin plugin) { return plugin.getExecutorService(); } };
/** * Checks whether this message is run on this proxy server. * * @return if this command runs on the proxy * @see PluginManager#isExecutableCommand(java.lang.String, net.md_5.bungee.api.CommandSender) */ public boolean isProxyCommand() { if ( !isCommand() ) { return false; } int index = message.indexOf( " " ); String commandName = ( index == -1 ) ? message.substring( 1 ) : message.substring( 1, index ); CommandSender sender = ( getSender() instanceof CommandSender ) ? (CommandSender) getSender() : null; return ProxyServer.getInstance().getPluginManager().isExecutableCommand( commandName, sender ); } }
@Override public void onEnable() { getProxy().getPluginManager().registerCommand( this, new CommandList() ); } }
@Override public int complete(String buffer, int cursor, List<CharSequence> candidates) { List<String> suggestions = new ArrayList<>(); proxy.getPluginManager().dispatchCommand( proxy.getConsole(), buffer, suggestions ); candidates.addAll( suggestions ); int lastSpace = buffer.lastIndexOf( ' ' ); return ( lastSpace == -1 ) ? cursor - buffer.length() : cursor - ( buffer.length() - lastSpace - 1 ); } }
@Override public void handle(ClientSettings settings) throws Exception { con.setSettings( settings ); SettingsChangedEvent settingsEvent = new SettingsChangedEvent( con ); bungee.getPluginManager().callEvent( settingsEvent ); }
private Class<?> loadClass0(String name, boolean resolve, boolean checkOther) throws ClassNotFoundException { try { return super.loadClass( name, resolve ); } catch ( ClassNotFoundException ex ) { } if ( checkOther ) { for ( PluginClassloader loader : allLoaders ) { if ( loader != this ) { try { return loader.loadClass0( name, resolve, false ); } catch ( ClassNotFoundException ex ) { } } } } throw new ClassNotFoundException( name ); } }
@Override public void onEnable() { getProxy().getPluginManager().registerCommand( this, new CommandFind() ); } }
@Override public void onEnable() { getProxy().getPluginManager().registerCommand( this, new CommandServer() ); } }
@Override public void onEnable() { getProxy().getPluginManager().registerCommand( this, new CommandAlert() ); getProxy().getPluginManager().registerCommand( this, new CommandAlertRaw() ); } }