当前位置: 首页>>代码示例>>Java>>正文


Java PluginDescriptionFile类代码示例

本文整理汇总了Java中org.bukkit.plugin.PluginDescriptionFile的典型用法代码示例。如果您正苦于以下问题:Java PluginDescriptionFile类的具体用法?Java PluginDescriptionFile怎么用?Java PluginDescriptionFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PluginDescriptionFile类属于org.bukkit.plugin包,在下文中一共展示了PluginDescriptionFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:24,代码来源:CraftCrashReport.java

示例2: InfoCommand

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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();
}
 
开发者ID:MrBlobman,项目名称:NBTProxy,代码行数:17,代码来源:InfoCommand.java

示例3: onEnable

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
@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());
}
 
开发者ID:GamerKing195,项目名称:Thirst,代码行数:19,代码来源:Thirst.java

示例4: describeToSender

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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));
        }
    }
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:21,代码来源:VersionCommand.java

示例5: getAuthors

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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();
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:22,代码来源:VersionCommand.java

示例6: loadPlugin

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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);
}
 
开发者ID:caoli5288,项目名称:economy,代码行数:23,代码来源:SubPluginLoader.java

示例7: CheckForConfig

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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();
		}
}
 
开发者ID:JoelGodOfwar,项目名称:SinglePlayerSleep,代码行数:24,代码来源:ConfigAPI.java

示例8: onCommand

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
@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;
}
 
开发者ID:TechzoneMC,项目名称:SonarPet,代码行数:21,代码来源:EchoPetPlugin.java

示例9: TestPlugin

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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));
}
 
开发者ID:DevotedMC,项目名称:ExilePearl,代码行数:19,代码来源:TestPlugin.java

示例10: getPluginFileName

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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;
}
 
开发者ID:PhantomAPI,项目名称:Phantom,代码行数:27,代码来源:PluginUtil.java

示例11: getPluginFileNameUnsafe

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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;
}
 
开发者ID:PhantomAPI,项目名称:Phantom,代码行数:27,代码来源:PluginUtil.java

示例12: onCommand

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
@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());
    }
}
 
开发者ID:trainphreak,项目名称:Virgil,代码行数:17,代码来源:SubCommandHelp.java

示例13: prepareTestObjects

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
@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"));
}
 
开发者ID:GeorgH93,项目名称:Bukkit_Bungee_PluginLib,代码行数:21,代码来源:UpdaterTest.java

示例14: FakePlugin

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
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);
}
 
开发者ID:TechzoneMC,项目名称:TagTabAPI,代码行数:20,代码来源:FakePlugin.java

示例15: testRecentlyUpdated

import org.bukkit.plugin.PluginDescriptionFile; //导入依赖的package包/类
@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));
}
 
开发者ID:sciolizer,项目名称:craftinomicon,代码行数:17,代码来源:UpdateCheckerTest.java


注:本文中的org.bukkit.plugin.PluginDescriptionFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。