Java 类org.bukkit.plugin.PluginDescriptionFile 实例源码

项目:Uranium    文件:CraftCrashReport.java   
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();
}
项目:NBTProxy    文件:InfoCommand.java   
public InfoCommand(PluginDescriptionFile pdf) {
    this.infoMsg = new String[] {
            ChatColor.AQUA + "NBTProxy Info:",
            ChatColor.AQUA + "  Description: " + ChatColor.YELLOW + pdf.getDescription(),
            ChatColor.AQUA + "  Version: " + ChatColor.YELLOW + pdf.getVersion(),
            ChatColor.AQUA + "  Authors: " + ChatColor.YELLOW + pdf.getAuthors(),
            ChatColor.AQUA + "  Website: " + ChatColor.YELLOW + pdf.getWebsite()
    };
    HoverEvent clickToCopyToolTip = new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(ChatColor.AQUA + "Click to paste the version into your chatbox."));
    ComponentBuilder msg = new ComponentBuilder("\nNBTProxy Info:\n").color(ChatColor.AQUA);
    appendInfoString(msg, clickToCopyToolTip, "Description", pdf.getDescription());
    appendInfoString(msg, clickToCopyToolTip, "Version", pdf.getVersion());
    appendInfoString(msg, clickToCopyToolTip, "Authors", pdf.getAuthors().toString());
    appendInfoString(msg, clickToCopyToolTip, "Website", pdf.getWebsite());
    this.infoMsgPretty = msg.create();
}
项目:Thirst    文件:Thirst.java   
@Override
public void onEnable()
{
    instance = this;
    PluginDescriptionFile pdf = getDescription();
    log = getLogger();

    new BukkitRunnable()
    {
        public void run()
        {
            loadFiles();
        }
    }.runTaskLater(instance, 2L);

    log.log(Level.INFO, "V"+pdf.getVersion()+" enabled!");
    log.log(Level.INFO, pdf.getName()+" developed by "+pdf.getAuthors());
}
项目:ThermosRebased    文件:CraftCrashReport.java   
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();
}
项目:Thermos-Bukkit    文件:VersionCommand.java   
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));
        }
    }
}
项目:Thermos-Bukkit    文件:VersionCommand.java   
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();
}
项目:economy    文件:SubPluginLoader.java   
public void loadPlugin(Plugin pl, PluginDescriptionFile description) throws InvalidPluginException {
    valid(pl);

    SubPlugin sub = (SubPlugin) pl;
    valid(sub, description);

    sub.setLoader(this);
    sub.setDescription(description);
    sub.setParent(plugin);

    val logger = plugin.getLogger();
    val log = "[Sub|" + description.getName() + "] ";

    sub.setLogger(new Logger(sub.getClass().getCanonicalName(), null) {
        public void log(LogRecord record) {
            record.setMessage(log + record.getMessage());
            logger.log(record);
        }
    });
    Fun.load(sub);
    Bukkit.getPluginManager().enablePlugin(sub);
}
项目:SinglePlayerSleep    文件:ConfigAPI.java   
public static  void CheckForConfig(Plugin plugin){
    try{
        PluginDescriptionFile pdfFile = plugin.getDescription();
        if(!plugin.getDataFolder().exists()){
            plugin.getLogger().info(pdfFile.getName() + ": Data Folder doesn't exist");
            plugin.getLogger().info(pdfFile.getName() + ": Creating Data Folder");
            plugin.getDataFolder().mkdirs();
            plugin.getLogger().info(pdfFile.getName() + ": Data Folder Created at " + plugin.getDataFolder());
        }
        File  file = new File(plugin.getDataFolder(), "config.yml");
        plugin.getLogger().info("" + file);
        if(!file.exists()){
            plugin.getLogger().info(pdfFile.getName() + ": config.yml not found, creating!");
            plugin.saveDefaultConfig();
            FileConfiguration config = plugin.getConfig();

            config.options().copyDefaults(true);
            plugin.saveConfig();
        }
        }catch(Exception e){
            e.printStackTrace();
        }
}
项目:SonarPet    文件:EchoPetPlugin.java   
@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;
}
项目:ExilePearl    文件:TestPlugin.java   
public TestPlugin(final Class<T> clazz) throws Exception {
    this.clazz = clazz;

    // Make sure the class is loaded
    getClass().getClassLoader().loadClass(clazz.getName());

    try {
        description = new PluginDescriptionFile(getResource("plugin.yml"));
    } catch (Exception ex) {
        throw new  InvalidDescriptionException(ex);
    }

       final InputStream configStream = getResource("config.yml");
       if (configStream == null) {
           return;
       }
       config = YamlConfiguration.loadConfiguration(new InputStreamReader(configStream, Charsets.UTF_8));
}
项目:Phantom    文件:PluginUtil.java   
public static String getPluginFileName(String name)
{
    File pluginDir = Phantom.getDataFolder().getParentFile();

    for(File f : pluginDir.listFiles())
    {
        if(f.getName().endsWith(".jar"))
        {
            try
            {
                PluginDescriptionFile desc = Phantom.getPluginLoader().getPluginDescription(f);
                if(desc.getName().equalsIgnoreCase(name))
                {
                    return f.getName();
                }
            }

            catch(InvalidDescriptionException e)
            {

            }
        }
    }

    return null;
}
项目:Phantom    文件:PluginUtil.java   
public static String getPluginFileNameUnsafe(String name, Plugin ins)
{
    File pluginDir = ins.getDataFolder().getParentFile();

    for(File f : pluginDir.listFiles())
    {
        if(f.getName().endsWith(".jar"))
        {
            try
            {
                PluginDescriptionFile desc = ins.getPluginLoader().getPluginDescription(f);
                if(desc.getName().equalsIgnoreCase(name))
                {
                    return f.getName();
                }
            }

            catch(InvalidDescriptionException e)
            {

            }
        }
    }

    return null;
}
项目:Virgil    文件:SubCommandHelp.java   
@Override
public void onCommand(CommandSender commandSender, String[] args)
{
    PluginDescriptionFile desc = Virgil.getPlugin().getDescription();
    commandSender.sendMessage(ChatColor.GREEN + "Virgil version " + desc.getVersion());
    commandSender.sendMessage(ChatColor.GREEN + "Authors: " + desc.getAuthors());
    commandSender.sendMessage(ChatColor.GOLD + "Available Commands:");
    for(final VirgilSubCommand subCommand : VirgilSubCommand.getCommands())
    {
        if (commandSender instanceof Player && !VirgilUtils.hasPermission((Player) commandSender, subCommand.getPermission()))
            continue;

        commandSender.sendMessage(ChatColor.GOLD + "- " + ChatColor.AQUA + subCommand.getSyntax() +
            ChatColor.GOLD + "- " + ChatColor.AQUA + subCommand.getDescription());
    }
}
项目:Bukkit_Bungee_PluginLib    文件:UpdaterTest.java   
@Before
public void prepareTestObjects() throws Exception
{
    TestObjects.initMockedJavaPlugin();
    whenNew(at.pcgamingfreaks.Updater.Updater.class).withAnyArguments().thenAnswer(new Answer<Object>()
    {
        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable
        {
            return null;
        }
    });
    suppress(at.pcgamingfreaks.Updater.Updater.class.getDeclaredMethods());
    mockedPluginDescription = mock(PluginDescriptionFile.class);
    when(mockedPluginDescription.getVersion()).thenReturn("v1.8.2-SNAPSHOT");
    when(mockedPluginDescription.getAuthors()).thenReturn(new ArrayList<String>());
    when(TestObjects.getJavaPlugin().getDescription()).thenReturn(mockedPluginDescription);
    mockStatic(Bukkit.class);
    when(Bukkit.getUpdateFolderFile()).thenReturn(new File("plugins/updates"));
}
项目:Thermos    文件:CraftCrashReport.java   
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();
}
项目:TagTabAPI    文件:FakePlugin.java   
public FakePlugin(Plugin parent) {
    this.parent = parent;

    plugins = Reflection.getField(Reflection.makeField(SimplePluginManager.class, "plugins"), parent.getServer().getPluginManager());
    lookupNames = Reflection.getField(Reflection.makeField( SimplePluginManager.class, "lookupNames"), parent.getServer().getPluginManager());

    StringWriter write = new StringWriter();
    parent.getDescription().save(write);
    String yaml = write.toString().replaceAll(parent.getName(), getFakeName());

    try {
        description = new PluginDescriptionFile(new StringReader(yaml));
    } catch (InvalidDescriptionException ex) {
        Throwables.propagate(ex);
    }

    plugins.add(this);
    lookupNames.put(getName(), this);
}
项目:KCauldron    文件:CraftCrashReport.java   
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();
}
项目:CauldronGit    文件:VersionCommand.java   
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));
        }
    }
}
项目:CauldronGit    文件:VersionCommand.java   
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();
}
项目:CauldronGit    文件:CraftCrashReport.java   
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();
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testRecentlyUpdated() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    updateChecker.lastUpgradeCheck = System.currentTimeMillis() - 1000l * 60 * 60 * 12;
    updateChecker.upgradeText = new ArrayList<String>();
    updateChecker.upgradeText.add("hello");

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(1, updateText.size());
    assertEquals("hello", updateText.get(0));
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testUpdateContainsFrenchAndGerman() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.25165825");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("French language option!", updateText.get(0));
    assertEquals("German language option!", updateText.get(1));
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testUpdateContainsOnlyUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.5");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(1, updateText.size());
    assertEquals("New features!", updateText.get(0));
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testUpdateContainsBugFixesAndUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.7");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Bug fixes!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testUpdateContainsPotionsAndUnpredictedFeatures() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.37");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Potions!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
项目:craftinomicon    文件:UpdateCheckerTest.java   
@Test
public void testSNAPSHOT() throws Exception {
    PluginDescriptionFile pluginDescriptionFile = new PluginDescriptionFile(new StringReader("name: craftinomicon\nmain: name.ball.joshua.craftinomicon.Craftinomicon\nversion: 0.2-SNAPSHOT"));
    when(plugin.getDescription()).thenReturn(pluginDescriptionFile);

    Permissible permissible = mock(Permissible.class);
    when(permissible.hasPermission(any(Permission.class))).thenReturn(true);

    setApiResponse("0.2.1.37");

    updateChecker.afterPropertiesSet();

    List<String> updateText = updateChecker.getUpdateText(permissible);
    assertEquals(2, updateText.size());
    assertEquals("Potions!", updateText.get(0));
    assertEquals("Additional new features not listed here!", updateText.get(1));
}
项目:Cauldron-Old    文件:CraftCrashReport.java   
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();
}
项目:Cauldron-Reloaded    文件:CraftCrashReport.java   
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();
}
项目:PerWorldInventory    文件:PerWorldInventoryInitializationTest.java   
@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));
}
项目:PerWorldInventory    文件:PerworldInventoryCommandHandlingTest.java   
@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);
}
项目:autojailer    文件:main.java   
@Override
public void onEnable() {
    PluginDescriptionFile pdfFile = this.getDescription();
    this.logger.info("[" + pdfFile.getName() + "] v."
            + pdfFile.getVersion() + " has been Enabled");
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new autojailerListener(this), this);
    this.folderVerify();

    getCommand("setJailMessage").setExecutor(this);
    getCommand("setfreedomMessage").setExecutor(this);
    getCommand("setFreedomLocation").setExecutor(this);
    getCommand("setvouchThreshold").setExecutor(this);
    getCommand("vouch").setExecutor(this);
    getCommand("free").setExecutor(this);
    getCommand("jailertoggle").setExecutor(this);
}
项目:FFoKC    文件:CraftCrashReport.java   
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();
}
项目:CraftBukkit    文件:CraftCrashReport.java   
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.getServer().getOnlineMode()));
        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();
}
项目:SimpleORM    文件:EbeanHandler.java   
public void reflect() {
    validInitialized();
    if (!managed) {
        plugin.getLogger().warning("自定义连接不能注入到端");
        return;
    }
    try {
        PluginDescriptionFile desc = plugin.getDescription();
        if (!((boolean) desc.getClass().getMethod("isDatabaseEnabled").invoke(desc))) {
            desc.getClass().getMethod("setDatabaseEnabled", boolean.class).invoke(desc, true);
        }
        Reflect.replace(plugin, server);
    } catch (Exception e) {
        plugin.getLogger().log(Level.WARNING, "注入失败了,1.12服务端不再支持注入方式|" + e.toString());
    }
}
项目:Craftbukkit    文件:CraftCrashReport.java   
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.getServer().getOnlineMode()));
        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.getServer().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();
}
项目:pploader    文件:PythonPlugin.java   
/**
 * Initializes this plugin with the given variables.
 *
 * This method should never be called manually.
 *
 * @param loader PluginLoader that is responsible for this plugin
 * @param server Server instance that is running this plugin
 * @param description PluginDescriptionFile containing metadata on this plugin
 * @param dataFolder Folder containing the plugin's data
 * @param file File containing this plugin
 * @param classLoader ClassLoader which holds this plugin
 */
protected final void initialize(PluginLoader loader, Server server,
        PluginDescriptionFile description, File dataFolder, File file ) { //,
        //ClassLoader classLoader) {
    if (!initialized) {
        this.initialized = true;
        this.loader = loader;
        this.server = server;
        this.file = file;
        this.description = description;
        this.dataFolder = dataFolder;
        //this.classLoader = classLoader;
        this.config = YamlConfiguration.loadConfiguration(new File(dataFolder, "config.yml"));

    }
}
项目:Cauldron    文件:VersionCommand.java   
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));
        }
    }
}
项目:Almura-Server    文件:CraftCrashReport.java   
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.getServer().getOnlineMode()));
        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();
}
项目:LapisPortals    文件:EnderPortals.java   
public void onEnable() {
    loadConfig();
    VaultHook.enable(this);
    EnderPortal.initialize(this);
    Messenger.init(this);

    setFileHandler(new FileHandler(this));
    PluginDescriptionFile pdfFile = getDescription();
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(this.playerListener, this);
    getServer().getScheduler().scheduleSyncRepeatingTask(this,
            new Runnable() {
                public void run() {
                    EnderPortals.getFileHandler().save();
                }
            }, 600L, 600L);
    Messenger.info(pdfFile.getName() + " " + pdfFile.getVersion()
            + " is now enabled.");
}
项目:pluginframework    文件:FrameworkJavaPluginTest.java   
@Test
public void test_default_modules() throws Exception
{
    PluginLoader loader = mock(PluginLoader.class);
    Server server = mock(Server.class);
    PluginDescriptionFile pdf = mock(PluginDescriptionFile.class);
    File file1 = new File("target" + File.separator + "testdatafolder");

    PluginLogger logger = mock(PluginLogger.class);
    when(server.getLogger()).thenReturn(logger);

    TestPluginDefaultModules plugin = new TestPluginDefaultModules(loader, server, pdf, file1, file1);
    assertThat(plugin.injectedPlugin).isNull();

    plugin.onLoad();
    assertThat(plugin.injectedPlugin).isNull();

    plugin.onEnable();
    assertThat(plugin.injectedPlugin).isSameAs(plugin);
}