/** * 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() ); }
protected PluginLogger(Plugin plugin) { super( plugin.getClass().getCanonicalName(), null ); pluginName = "[" + plugin.getDescription().getName() + "] "; setParent( plugin.getProxy().getLogger() ); }
public ProxyServer getProxy() { return plugin.getProxy(); }
public ConsoleMessageHandler(Plugin plugin) { this.plugin = plugin; plugin.getProxy().registerChannel("Console"); }
@Override public void registerCommand(BaseCommand command) { command.onRegister(this); for (Map.Entry<String, RootCommand> entry : command.registeredCommands.entrySet()) { String commandName = entry.getKey().toLowerCase(); BungeeRootCommand bungeeCommand = (BungeeRootCommand) entry.getValue(); if (!bungeeCommand.isRegistered) { this.plugin.getProxy().getPluginManager().registerCommand(this.plugin, bungeeCommand); } bungeeCommand.isRegistered = true; registeredCommands.put(commandName, bungeeCommand); } }
private void startSubmitting() { // The data collection is async, as well as sending the data // Bungeecord does not have a main thread, everything is async plugin.getProxy().getScheduler().schedule(plugin, this::submitData, 2, 30, TimeUnit.MINUTES); // Submit the data every 30 minutes, first time after 2 minutes to give other plugins enough time to start // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! // WARNING: Just don't do it! }
public void unregisterCommand(BungeeRootCommand command) { this.plugin.getProxy().getPluginManager().unregisterCommand(command); }
public void enable() { plugin.getProxy().getPluginManager().registerListener(plugin, this); }
/** * 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() ); }
private void triggerRandomEvent() { try { if (Math.random() <= 0.5 && online.size() > 0) { // do a server switch FakePlayer player = online.get((int) (Math.random() * online.size())); if (player.isRandomServerSwitchEnabled()) { player.changeServer(new ArrayList<>(plugin.getProxy().getServers().values()).get((int) (Math.random() * plugin.getProxy().getServers().values().size()))); } } else if (randomJoinLeaveEventsEnabled) { if (Math.random() < 0.7 && offline.size() > 0) { // add player String name = offline.get((int) (Math.random() * offline.size())); FakePlayer player = new FakePlayer(name, new ArrayList<>(plugin.getProxy().getServers().values()).get((int) (Math.random() * plugin.getProxy().getServers().values().size())), true); offline.remove(name); online.add(player); } else if (online.size() > 0) { // remove player FakePlayer fakePlayer = online.get((int) (online.size() * Math.random())); if (BungeeTabListPlus.getInstance().getConfig().fakePlayers.contains(fakePlayer.getName())) { removeFakePlayer(fakePlayer); } } } } catch (Throwable th) { plugin.getLogger().log(Level.SEVERE, "An error occurred while processing random fake player events", th); } }
protected PluginLogger(Plugin plugin) { super( plugin.getClass().getCanonicalName(), null ); pluginName = "[" + plugin.getDescription().getName() + "] "; setParent( plugin.getProxy().getLogger() ); }
public PingTask getServerState(String serverName) { if (serverState.containsKey(serverName)) { return serverState.get(serverName); } ServerInfo serverInfo = ProxyServer.getInstance().getServerInfo(serverName); if (serverInfo != null) { // start server ping tasks int delay = config.pingDelay; if (delay <= 0 || delay > 10) { delay = 10; } PingTask task = new PingTask(serverInfo); serverState.put(serverName, task); plugin.getProxy().getScheduler().schedule(plugin, task, delay, delay, TimeUnit.SECONDS); } return serverState.get(serverName); }
private void startSubmitting() { // The data collection is async, as well as sending the data // Bungeecord does not have a main thread, everything is async plugin.getProxy().getScheduler().schedule(plugin, () -> submitData(), 2, 30, TimeUnit.MINUTES); // Submit the data every 30 minutes, first time after 2 minutes to give other plugins enough time to start // WARNING: Changing the frequency has no effect but your plugin WILL be blocked/deleted! // WARNING: Just don't do it! }
@Override public void run() { String uuid; if (PATTERN_VALID_USERNAME.matcher(nameOrUUID).matches()) { uuid = fetchUUID(nameOrUUID); } else if (PATTERN_VALID_UUID.matcher(nameOrUUID).matches()) { uuid = nameOrUUID; } else { plugin.getLogger().warning("Invalid skin requested: " + nameOrUUID); return; } if (uuid != null) { Icon skin = fetchSkin(uuid); if (skin != null) { cache.put(nameOrUUID, skin); fetchingSkins.remove(nameOrUUID); // we received a new skin -> update tab to all players BungeeTabListPlus.getInstance().resendTabLists(); } else { plugin.getProxy().getScheduler().schedule(plugin, new Runnable() { @Override public void run() { fetchingSkins.remove(nameOrUUID); } }, 1, TimeUnit.MINUTES); } } } }
public BungeeCommandManager(Plugin plugin) { this.plugin = plugin; this.formatters.put(MessageType.ERROR, defaultFormatter = new BungeeMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED)); this.formatters.put(MessageType.SYNTAX, new BungeeMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE)); this.formatters.put(MessageType.INFO, new BungeeMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN)); this.formatters.put(MessageType.HELP, new BungeeMessageFormatter(ChatColor.AQUA, ChatColor.GREEN, ChatColor.YELLOW)); getLocales(); // auto load locales plugin.getProxy().getPluginManager().registerListener(plugin, new ACFBungeeListener(this, plugin)); //BungeeCord has no event for listening for client setting changes plugin.getProxy().getScheduler().schedule(plugin, () -> { ProxyServer.getInstance().getPlayers().forEach(this::readLocale); }, 5, 5, TimeUnit.SECONDS); // TODO more default dependencies for bungee registerDependency(plugin.getClass(), plugin); registerDependency(Plugin.class, plugin); }
public FakePlayerManagerImpl(final Plugin plugin) { this.plugin = plugin; randomJoinLeaveEventsEnabled = true; if (BungeeTabListPlus.getInstance().getConfig().fakePlayers.size() > 0) { offline = new ArrayList<>(BungeeTabListPlus.getInstance().getConfig().fakePlayers); sanitizeFakePlayerNames(); } plugin.getProxy().getScheduler().schedule(plugin, this::triggerRandomEvent, 10, 10, TimeUnit.SECONDS); }
@Override public void callRevokePunishmentEvent(Punishment punishment, boolean massClear) { ((Plugin) getPlugin()).getProxy().getPluginManager().callEvent(new RevokePunishmentEvent(punishment, massClear)); }
@Override public void callPunishmentEvent(Punishment punishment) { ((Plugin) getPlugin()).getProxy().getPluginManager().callEvent(new PunishmentEvent(punishment)); }
@EventHandler public void onPlayerJoin(PostLoginEvent loginEvent) { ProxiedPlayer player = loginEvent.getPlayer(); //the client settings are sent after a successful login Runnable task = () -> manager.readLocale(player); plugin.getProxy().getScheduler().schedule(plugin, task, 1, TimeUnit.SECONDS); }
public PlaceholderAPIHook(BungeeTabListPlus bungeeTabListPlus) { this.bungeeTabListPlus = bungeeTabListPlus; bungeeTabListPlus.getPlugin().getProxy().getScheduler().schedule(bungeeTabListPlus.getPlugin(), () -> bungeeTabListPlus.runInMainThread(this::askServersForPlaceholders), 2, 2, TimeUnit.SECONDS); }