org.bukkit.plugin.PluginDescriptionFile Java Examples
The following examples show how to use
org.bukkit.plugin.PluginDescriptionFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimePluginLoader.java From PGM with GNU Affero General Public License v3.0 | 7 votes |
@SuppressWarnings("unchecked") public Plugin loadPlugin(PluginDescriptionFile plugin) throws UnknownDependencyException { final SimplePluginManager manager = (SimplePluginManager) server.getPluginManager(); try { final File file = new File("plugins", plugin.getName()); final Class[] init = new Class[] { PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, File.class }; final JavaPlugin instance = (JavaPlugin) Class.forName(plugin.getMain()) .getConstructor(init) .newInstance(this, server, plugin, file, file); readField(SimplePluginManager.class, manager, List.class, "plugins").add(instance); readField(SimplePluginManager.class, manager, Map.class, "lookupNames") .put(instance.getName().toLowerCase(), instance); return instance; } catch (Throwable t) { throw new UnknownDependencyException( t, "Unable to load plugin: " + plugin.getName() + " (" + plugin.getMain() + ")"); } }
Example #2
Source File: VersionCommand.java From Kettle with GNU General Public License v3.0 | 6 votes |
private String getAuthors(final PluginDescriptionFile desc) { StringBuilder result = new StringBuilder(); List<String> authors = desc.getAuthors(); for (int i = 0; i < authors.size(); i++) { if (result.length() > 0) { result.append(ChatColor.WHITE); if (i < authors.size() - 1) { result.append(", "); } else { result.append(" and "); } } result.append(ChatColor.GREEN); result.append(authors.get(i)); } return result.toString(); }
Example #3
Source File: SurvivalGames.java From Survival-Games with GNU General Public License v3.0 | 6 votes |
public void onDisable() { disabling = false; PluginDescriptionFile pdfFile = p.getDescription(); SettingsManager.getInstance().saveSpawns(); SettingsManager.getInstance().saveSystemConfig(); for (Game g: GameManager.getInstance().getGames()) { try { g.disable(); } catch(Exception e) { // Will throw useless "tried to register task blah blah error." Use the method below to reset the arena without a task. } QueueManager.getInstance().rollback(g.getID(), true); } logger.info(pdfFile.getName() + " version " + pdfFile.getVersion() + " has now been disabled and reset"); }
Example #4
Source File: EchoPetPlugin.java From SonarPet with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (commandLabel.equalsIgnoreCase("echopet")) { if (sender.hasPermission("echopet.petadmin")) { PluginDescriptionFile pdFile = this.getDescription(); sender.sendMessage(ChatColor.RED + "-------- SonarPet --------"); sender.sendMessage(ChatColor.GOLD + "Author: " + ChatColor.YELLOW + "DSH105"); sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.YELLOW + pdFile.getVersion()); sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.YELLOW + pdFile.getWebsite()); sender.sendMessage(ChatColor.GOLD + "Commands are registered at runtime to provide you with more dynamic control over the command labels."); sender.sendMessage(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Command Registration:"); sender.sendMessage(ChatColor.GOLD + "Main: " + OPTIONS.getCommandString()); sender.sendMessage(ChatColor.GOLD + "Admin: " + OPTIONS.getCommandString() + "admin"); } else { Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.petadmin")); return true; } } return false; }
Example #5
Source File: PerWorldInventoryInitializationTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { dataFolder = temporaryFolder.newFolder(); // Wire various Bukkit components setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); given(server.getScheduler()).willReturn(mock(BukkitScheduler.class)); given(server.getPluginManager()).willReturn(pluginManager); given(server.getVersion()).willReturn("1.9.4-RC1"); // SettingsManager always returns the default given(settings.getProperty(any(Property.class))).willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return ((Property<?>) invocation.getArguments()[0]).getDefaultValue(); } }); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); }
Example #6
Source File: PerworldInventoryCommandHandlingTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { File dataFolder = temporaryFolder.newFolder(); // Set mock server setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); Injector injector = new InjectorBuilder().addDefaultHandlers("me.gnat008.perworldinventory").create(); injector.register(PermissionManager.class, permissionManager); injector.register(ConvertCommand.class, convertCommand); injector.register(HelpCommand.class, helpCommand); injector.register(PerWorldInventoryCommand.class, pwiCommand); injector.register(ReloadCommand.class, reloadCommand); injector.register(SetWorldDefaultCommand.class, setWorldDefaultsCommand); injector.register(VersionCommand.class, versionCommand); plugin.registerCommands(injector); TestHelper.setField(PerWorldInventory.class, "permissionManager", plugin, permissionManager); }
Example #7
Source File: CraftCrashReport.java From Thermos with GNU General Public License v3.0 | 6 votes |
public Object call() throws Exception { StringWriter value = new StringWriter(); try { value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(net.minecraft.server.MinecraftServer.getServer().isServerInOnlineMode())); value.append("\n Plugins: {"); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { PluginDescriptionFile description = plugin.getDescription(); value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(','); } value.append("}\n Warnings: ").append(Bukkit.getWarningState().name()); value.append("\n Threads: {"); for (Map.Entry<Thread, ? extends Object[]> entry : Thread.getAllStackTraces().entrySet()) { value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(','); } value.append("}\n ").append(Bukkit.getScheduler().toString()); } catch (Throwable t) { value.append("\n Failed to handle CraftCrashReport:\n"); PrintWriter writer = new PrintWriter(value); t.printStackTrace(writer); writer.flush(); } return value.toString(); }
Example #8
Source File: CraftCrashReport.java From Kettle with GNU General Public License v3.0 | 6 votes |
public Object call() throws Exception { StringWriter value = new StringWriter(); try { value.append("\n Running: ").append(Bukkit.getName()).append(" version ").append(Bukkit.getVersion()).append(" (Implementing API version ").append(Bukkit.getBukkitVersion()).append(") ").append(String.valueOf(MinecraftServer.getServerCB().isServerInOnlineMode())); value.append("\n Plugins: {"); for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { PluginDescriptionFile description = plugin.getDescription(); value.append(' ').append(description.getFullName()).append(' ').append(description.getMain()).append(' ').append(Arrays.toString(description.getAuthors().toArray())).append(','); } value.append("}\n Warnings: ").append(Bukkit.getWarningState().name()); value.append("\n Reload Count: ").append(String.valueOf(MinecraftServer.getServerCB().server.reloadCount)); value.append("\n Threads: {"); for (Map.Entry<Thread, ? extends Object[]> entry : Thread.getAllStackTraces().entrySet()) { value.append(' ').append(entry.getKey().getState().name()).append(' ').append(entry.getKey().getName()).append(": ").append(Arrays.toString(entry.getValue())).append(','); } value.append("}\n ").append(Bukkit.getScheduler().toString()); } catch (Throwable t) { value.append("\n Failed to handle CraftCrashReport:\n"); PrintWriter writer = new PrintWriter(value); t.printStackTrace(writer); writer.flush(); } return value.toString(); }
Example #9
Source File: VersionCommand.java From Kettle with GNU General Public License v3.0 | 6 votes |
private void describeToSender(Plugin plugin, CommandSender sender) { PluginDescriptionFile desc = plugin.getDescription(); sender.sendMessage(ChatColor.GREEN + desc.getName() + ChatColor.WHITE + " version " + ChatColor.GREEN + desc.getVersion()); if (desc.getDescription() != null) { sender.sendMessage(desc.getDescription()); } if (desc.getWebsite() != null) { sender.sendMessage("Website: " + ChatColor.GREEN + desc.getWebsite()); } if (!desc.getAuthors().isEmpty()) { if (desc.getAuthors().size() == 1) { sender.sendMessage("Author: " + getAuthors(desc)); } else { sender.sendMessage("Authors: " + getAuthors(desc)); } } }
Example #10
Source File: PerWorldInventoryInitializationTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { dataFolder = temporaryFolder.newFolder(); // Wire various Bukkit components setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); given(server.getScheduler()).willReturn(mock(BukkitScheduler.class)); given(server.getPluginManager()).willReturn(pluginManager); given(server.getVersion()).willReturn("1.9.4-RC1"); // SettingsManager always returns the default given(settings.getProperty(any(Property.class))).willAnswer(new Answer<Object>() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { return ((Property<?>) invocation.getArguments()[0]).getDefaultValue(); } }); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); }
Example #11
Source File: PerworldInventoryCommandHandlingTest.java From PerWorldInventory with GNU General Public License v3.0 | 6 votes |
@Before public void setUpPlugin() throws IOException { File dataFolder = temporaryFolder.newFolder(); // Set mock server setField(Bukkit.class, "server", null, server); given(server.getLogger()).willReturn(mock(Logger.class)); // PluginDescriptionFile is final and so cannot be mocked PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "PerWorldInventory", "N/A", PerWorldInventory.class.getCanonicalName()); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); plugin = new PerWorldInventory(pluginLoader, descriptionFile, dataFolder, null); setField(JavaPlugin.class, "logger", plugin, mock(PluginLogger.class)); Injector injector = new InjectorBuilder().addDefaultHandlers("me.gnat008.perworldinventory").create(); injector.register(PermissionManager.class, permissionManager); injector.register(ConvertCommand.class, convertCommand); injector.register(HelpCommand.class, helpCommand); injector.register(PerWorldInventoryCommand.class, pwiCommand); injector.register(ReloadCommand.class, reloadCommand); injector.register(SetWorldDefaultCommand.class, setWorldDefaultsCommand); injector.register(VersionCommand.class, versionCommand); plugin.registerCommands(injector); TestHelper.setField(PerWorldInventory.class, "permissionManager", plugin, permissionManager); }
Example #12
Source File: CommandReload.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Command(name = "reload", permission = Permissions.PERMISSION_RELOAD, descref = Messages.Help.Description.RELOAD, usage = "/spleef reload") public void onReloadCommand(CommandContext context, HeavySpleef heavySpleef) { CommandSender sender = context.getSender(); if (sender instanceof Player) { sender = heavySpleef.getSpleefPlayer(sender); } long timeBefore = System.currentTimeMillis(); heavySpleef.reload(); long timeDif = System.currentTimeMillis() - timeBefore; PluginDescriptionFile pdf = heavySpleef.getPlugin().getDescription(); sender.sendMessage(i18n.getVarString(Messages.Command.PLUGIN_RELOADED) .setVariable("time-dif-ms", String.valueOf(timeDif)) .setVariable("time-dif-s", String.valueOf(timeDif / 1000D)) .setVariable("version", pdf.getVersion()) .toString()); }
Example #13
Source File: PGMServer.java From PGM with GNU Affero General Public License v3.0 | 6 votes |
protected void setupPlugins() { server.loadPlugins(); final RuntimePluginLoader loader = new RuntimePluginLoader(server); // TODO: Investigate why ViaRewind needs to be enabled explicitly final Plugin rewind = server.getPluginManager().getPlugin("ViaRewind"); if (rewind != null) { loader.togglePlugin(rewind, true); } for (PluginDescriptionFile plugin : plugins) { loader.loadPlugin(plugin); } server.enablePlugins(PluginLoadOrder.POSTWORLD); }
Example #14
Source File: AuthMeInitializationTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Before public void initAuthMe() throws IOException { dataFolder = temporaryFolder.newFolder(); File settingsFile = new File(dataFolder, "config.yml"); JavaPluginLoader pluginLoader = new JavaPluginLoader(server); Files.copy(TestHelper.getJarFile(TestHelper.PROJECT_ROOT + "config.test.yml"), settingsFile); // Mock / wire various Bukkit components given(server.getLogger()).willReturn(Logger.getAnonymousLogger()); ReflectionTestUtils.setField(Bukkit.class, null, "server", server); given(server.getPluginManager()).willReturn(pluginManager); // PluginDescriptionFile is final: need to create a sample one PluginDescriptionFile descriptionFile = new PluginDescriptionFile( "AuthMe", "N/A", AuthMe.class.getCanonicalName()); // Initialize AuthMe authMe = new AuthMe(pluginLoader, descriptionFile, dataFolder, null); }
Example #15
Source File: uSkyBlock.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public synchronized boolean isRequirementsMet(CommandSender sender, Command command, String... args) { if (maintenanceMode && !( (command instanceof AdminCommand && args != null && args.length > 0 && args[0].equals("maintenance")) || command instanceof SetMaintenanceCommand)) { sender.sendMessage(tr("\u00a7cMAINTENANCE:\u00a7e uSkyBlock is currently in maintenance mode")); return false; } if (missingRequirements == null) { PluginManager pluginManager = getServer().getPluginManager(); missingRequirements = ""; for (String[] pluginReq : depends) { if (pluginReq.length > 2 && pluginReq[2].equals("optional")) { // Do check the version if an optional requirement is present. if (!pluginManager.isPluginEnabled(pluginReq[0])) { continue; } } if (pluginReq.length > 2 && pluginReq[2].equals("optionalIf")) { if (pluginManager.isPluginEnabled(pluginReq[3])) { continue; } } if (pluginManager.isPluginEnabled(pluginReq[0])) { PluginDescriptionFile desc = pluginManager.getPlugin(pluginReq[0]).getDescription(); if (VersionUtil.getVersion(desc.getVersion()).isLT(pluginReq[1])) { missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}\u00a7e but only \u00a7cv{2}\u00a7e was found!\n", pluginReq[0], pluginReq[1], desc.getVersion()); } } else { missingRequirements += tr("\u00a7buSkyBlock\u00a7e depends on \u00a79{0}\u00a7e >= \u00a7av{1}", pluginReq[0], pluginReq[1]); } } } if (missingRequirements.isEmpty()) { return true; } else { sender.sendMessage(missingRequirements.split("\n")); return false; } }
Example #16
Source File: uSkyBlock.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
public String getVersionInfo(boolean checkEnabled) { PluginDescriptionFile description = getDescription(); String msg = pre("\u00a77Name: \u00a7b{0}\n", description.getName()); msg += pre("\u00a77Version: \u00a7b{0}\n", description.getVersion()); msg += pre("\u00a77Description: \u00a7b{0}\n", description.getDescription()); msg += pre("\u00a77Language: \u00a7b{0} ({1})\n", getConfig().get("language", "en"), I18nUtil.getI18n().getLocale()); msg += pre("\u00a79 State: d={0}, r={1}, i={2}, p={3}, n={4}, awe={5}\n", Settings.island_distance, Settings.island_radius, islandLogic.getSize(), playerLogic.getSize(), Settings.nether_enabled, AsyncWorldEditHandler.isAWE()); msg += pre("\u00a77Server: \u00a7e{0} {1}\n", getServer().getName(), getServer().getVersion()); msg += pre("\u00a79 State: online={0}, bungee={1}\n", ServerUtil.isOnlineMode(), ServerUtil.isBungeeEnabled()); msg += pre("\u00a77------------------------------\n"); for (String[] dep : depends) { Plugin dependency = getServer().getPluginManager().getPlugin(dep[0]); if (dependency != null) { String status = pre("N/A"); if (checkEnabled) { if (dependency.isEnabled()) { if (VersionUtil.getVersion(dependency.getDescription().getVersion()).isLT(dep[1])) { status = pre("\u00a7eWRONG-VERSION"); } else { status = pre("\u00a72ENABLED"); } } else { status = pre("\u00a74DISABLED"); } } msg += pre("\u00a77\u00a7d{0} \u00a7f{1} \u00a77({2}\u00a77)\n", dependency.getName(), dependency.getDescription().getVersion(), status); } } msg += pre("\u00a77------------------------------\n"); return msg; }
Example #17
Source File: HookWorldGuard.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
public static WorldGuardVersion getWorldGuardVersion() { if(worldGuardVersion != null) return worldGuardVersion; PluginManager manager = Bukkit.getPluginManager(); Plugin plugin = manager.getPlugin("WorldGuard"); if(plugin == null) return (worldGuardVersion = WorldGuardVersion.ERROR); PluginDescriptionFile pdf = plugin.getDescription(); String version = pdf.getVersion(); if(version.startsWith("6.1")) return (worldGuardVersion = WorldGuardVersion.V6_1); if(version.startsWith("6.2")) return (worldGuardVersion = WorldGuardVersion.V6_2); if(version.startsWith("7.0")) return (worldGuardVersion = WorldGuardVersion.V7_0); return (worldGuardVersion = WorldGuardVersion.ERROR); }
Example #18
Source File: CommandVersion.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
@Command(name = "version", descref = Messages.Help.Description.VERSION, usage = "/spleef version") public void onVersionCommand(CommandContext context, HeavySpleef heavySpleef) { CommandSender sender = context.getSender(); if (sender instanceof Player) { sender = heavySpleef.getSpleefPlayer(sender); } Plugin plugin = heavySpleef.getPlugin(); PluginDescriptionFile desc = plugin.getDescription(); sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "HeavySpleef " + ChatColor.GREEN + "v" + desc.getVersion() + ChatColor.GRAY + " by " + ChatColor.GREEN + "Matze" + ChatColor.GRAY + " (matzefratze123)"); sender.sendMessage(ChatColor.GRAY + "Visit http://dev.bukkit.org/bukkit-plugins/heavyspleef for more information"); }
Example #19
Source File: Notifier.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private void hookIfEnabled(String pluginName) { PluginManager manager = Bukkit.getPluginManager(); if(!manager.isPluginEnabled(pluginName)) return; Plugin plugin = manager.getPlugin(pluginName); if(plugin == null) return; PluginDescriptionFile description = plugin.getDescription(); String nameAndVersion = description.getFullName(); Logger logger = getLogger(); logger.info("Successfully hooked into " + nameAndVersion); }
Example #20
Source File: CompatibilityCitizens.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private boolean checkForSentinel() { PluginManager manager = Bukkit.getPluginManager(); if(!manager.isPluginEnabled("Sentinel")) return false; Plugin plugin = manager.getPlugin("Sentinel"); if(plugin == null) return false; PluginDescriptionFile description = plugin.getDescription(); String fullName = description.getFullName(); Logger logger = getLogger(); logger.info("Successfully hooked into " + fullName); return true; }
Example #21
Source File: CompatibilityCitizens.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private boolean checkForCitizens() { PluginManager manager = Bukkit.getPluginManager(); if(!manager.isPluginEnabled("Citizens")) return true; Plugin plugin = manager.getPlugin("Citizens"); if(plugin == null) return true; PluginDescriptionFile description = plugin.getDescription(); String fullName = description.getFullName(); Logger logger = getLogger(); logger.info("Successfully hooked into " + fullName); return false; }
Example #22
Source File: EchoPetPlugin.java From EchoPet with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { if (commandLabel.equalsIgnoreCase("ecupdate")) { if (sender.hasPermission("echopet.update")) { if (updateChecked) { @SuppressWarnings("unused") Updater updater = new Updater(this, 53655, this.getFile(), Updater.UpdateType.NO_VERSION_CHECK, true); return true; } else { sender.sendMessage(this.prefix + ChatColor.GOLD + " An update is not available."); return true; } } else { Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.update")); return true; } } else if (commandLabel.equalsIgnoreCase("echopet")) { if (sender.hasPermission("echopet.petadmin")) { PluginDescriptionFile pdFile = this.getDescription(); sender.sendMessage(ChatColor.RED + "-------- EchoPet --------"); sender.sendMessage(ChatColor.GOLD + "Author: " + ChatColor.YELLOW + "DSH105"); sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.YELLOW + pdFile.getVersion()); sender.sendMessage(ChatColor.GOLD + "Website: " + ChatColor.YELLOW + pdFile.getWebsite()); sender.sendMessage(ChatColor.GOLD + "Commands are registered at runtime to provide you with more dynamic control over the command labels."); sender.sendMessage(ChatColor.GOLD + "" + ChatColor.UNDERLINE + "Command Registration:"); sender.sendMessage(ChatColor.GOLD + "Main: " + this.OPTIONS.getCommandString()); sender.sendMessage(ChatColor.GOLD + "Admin: " + this.OPTIONS.getCommandString() + "admin"); } else { Lang.sendTo(sender, Lang.NO_PERMISSION.toString().replace("%perm%", "echopet.petadmin")); return true; } } return false; }
Example #23
Source File: SkyBlockHook.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private static void printHookInfo(CompatibilitySkyBlock expansion, String pluginName) { PluginManager manager = Bukkit.getPluginManager(); if(!manager.isPluginEnabled(pluginName)) return; Plugin plugin = manager.getPlugin(pluginName); if(plugin == null) return; PluginDescriptionFile description = plugin.getDescription(); String fullName = description.getFullName(); Logger logger = expansion.getLogger(); logger.info("Successfully hooked into " + fullName); }
Example #24
Source File: PGMServer.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public static void main(String[] args) throws InvalidDescriptionException { BasicConfigurator.configure(); new PGMServer( new PluginDescriptionFile( Thread.currentThread().getContextClassLoader().getResourceAsStream("plugin.yml"))) .run(); }
Example #25
Source File: PGMServer.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public PGMServer(PluginDescriptionFile... plugins) { super( new OptionParser() { { this.acceptsAll(Lists.newArrayList("config"), "") .withRequiredArg() .ofType(File.class) .defaultsTo(new File("server.properties")); this.acceptsAll(Lists.newArrayList("sportpaper-settings"), "") .withRequiredArg() .ofType(File.class) .defaultsTo(new File("sportpaper.yml")); this.acceptsAll(Lists.newArrayList("plugins"), "") .withRequiredArg() .ofType(File.class) .defaultsTo(new File("plugins")); } }.parse()); this.plugins = plugins; this.name = super.getServerModName() + " (with " + Stream.of(plugins) .map(PluginDescriptionFile::getName) .collect(Collectors.joining(", ")) + ")"; }
Example #26
Source File: PGMPlugin.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public PGMPlugin( PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file) { super(loader, server, description, dataFolder, file); }
Example #27
Source File: PlanBukkitMocker.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
PlanBukkitMocker withPluginDescription() { try (InputStream in = Files.newInputStream(getFile("/plugin.yml").toPath())) { PluginDescriptionFile description = new PluginDescriptionFile(in); doReturn(description).when(planMock).getDescription(); } catch (IOException | InvalidDescriptionException e) { System.out.println("Error while setting plugin description"); } return this; }
Example #28
Source File: Updater.java From QuickShop-Reremake with GNU General Public License v3.0 | 5 votes |
public static void replaceTheJar(byte[] data) throws RuntimeException, IOException { File pluginFolder = new File("plugins"); if (!pluginFolder.exists()) { throw new RuntimeException("Can't find the plugins folder."); } if (!pluginFolder.isDirectory()) { throw new RuntimeException("Plugins not a folder."); } File[] plugins = pluginFolder.listFiles(); if (plugins == null) { throw new IOException("Can't get the files in plugins folder"); } File quickshop = null; for (File plugin : plugins) { try { PluginDescriptionFile desc = QuickShop.instance.getPluginLoader().getPluginDescription(plugin); if (!desc.getName().equals(QuickShop.instance.getDescription().getName())) { continue; } Util.debugLog("Selected: " + plugin.getPath()); quickshop = plugin; break; } catch (InvalidDescriptionException e) { // Ignore } } } if (quickshop == null) { throw new RuntimeException("Failed to get QuickShop Jar File."); } OutputStream outputStream = new FileOutputStream(quickshop, false); outputStream.write(data); outputStream.flush(); outputStream.close(); }
Example #29
Source File: JavaPlugin.java From Kettle with GNU General Public License v3.0 | 5 votes |
final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) { this.loader = loader; this.server = server; this.file = file; this.description = description; this.dataFolder = dataFolder; this.classLoader = classLoader; this.configFile = new File(dataFolder, "config.yml"); this.logger = new PluginLogger(this); }
Example #30
Source File: JavaPlugin.java From Kettle with GNU General Public License v3.0 | 5 votes |
protected JavaPlugin(final JavaPluginLoader loader, final PluginDescriptionFile description, final File dataFolder, final File file) { final ClassLoader classLoader = this.getClass().getClassLoader(); if (classLoader instanceof PluginClassLoader) { throw new IllegalStateException("Cannot use initialization constructor at runtime"); } init(loader, loader.server, description, dataFolder, file, classLoader); }