本文整理汇总了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();
}
示例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();
}
示例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());
}
示例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));
}
}
}
示例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();
}
示例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);
}
示例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();
}
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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());
}
}
示例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"));
}
示例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);
}
示例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));
}