From a0b31825391355b962497a80c8790029feecd63d Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Thu, 16 May 2013 04:41:09 -0500 Subject: Pulling all pending Bukkit-JavaDoc changes --- src/main/java/org/bukkit/Bukkit.java | 252 ++++++++ src/main/java/org/bukkit/command/Command.java | 27 +- src/main/java/org/bukkit/entity/Player.java | 2 +- src/main/java/org/bukkit/entity/ThrownPotion.java | 8 +- src/main/java/org/bukkit/event/Event.java | 68 +- src/main/java/org/bukkit/plugin/Plugin.java | 15 +- .../org/bukkit/plugin/PluginDescriptionFile.java | 707 +++++++++++++++++++-- .../java/org/bukkit/plugin/java/JavaPlugin.java | 8 +- src/main/java/org/bukkit/scoreboard/Objective.java | 1 - src/main/java/org/bukkit/scoreboard/Team.java | 1 - .../doc-files/permissions-example_plugin.yml | 64 ++ 11 files changed, 1057 insertions(+), 96 deletions(-) create mode 100644 src/main/javadoc/org/bukkit/plugin/doc-files/permissions-example_plugin.yml (limited to 'src/main') diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 005085a9..f389fc0c 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -65,338 +65,590 @@ public final class Bukkit { server.getLogger().info("This server is running " + getName() + " version " + getVersion() + " (Implementing API version " + getBukkitVersion() + ")"); } + /** + * @see Server#getName() + */ public static String getName() { return server.getName(); } + /** + * @see Server#getVersion() + */ public static String getVersion() { return server.getVersion(); } + /** + * @see Server#getBukkitVersion() + */ public static String getBukkitVersion() { return server.getBukkitVersion(); } + /** + * @see Server#getOnlinePlayers() + */ public static Player[] getOnlinePlayers() { return server.getOnlinePlayers(); } + /** + * @see Server#getMaxPlayers() + */ public static int getMaxPlayers() { return server.getMaxPlayers(); } + /** + * @see Server#getPort() + */ public static int getPort() { return server.getPort(); } + /** + * @see Server#getViewDistance() + */ public static int getViewDistance() { return server.getViewDistance(); } + /** + * @see Server#getIp() + */ public static String getIp() { return server.getIp(); } + /** + * @see Server#getServerName() + */ public static String getServerName() { return server.getServerName(); } + /** + * @see Server#getServerId() + */ public static String getServerId() { return server.getServerId(); } + /** + * @see Server#getWorldType() + */ public static String getWorldType() { return server.getWorldType(); } + /** + * @see Server#getGenerateStructures() + */ public static boolean getGenerateStructures() { return server.getGenerateStructures(); } + /** + * @see Server#getAllowNether() + */ public static boolean getAllowNether() { return server.getAllowNether(); } + /** + * @see Server#hasWhitelist() + */ public static boolean hasWhitelist() { return server.hasWhitelist(); } + /** + * @see Server#broadcastMessage(String message) + */ public static int broadcastMessage(String message) { return server.broadcastMessage(message); } + /** + * @see Server#getUpdateFolder() + */ public static String getUpdateFolder() { return server.getUpdateFolder(); } + /** + * @see Server#getPlayer(String name) + */ public static Player getPlayer(String name) { return server.getPlayer(name); } + /** + * @see Server#matchPlayer(String name) + */ public static List matchPlayer(String name) { return server.matchPlayer(name); } + /** + * @see Server#getPluginManager() + */ public static PluginManager getPluginManager() { return server.getPluginManager(); } + /** + * @see Server#getScheduler() + */ public static BukkitScheduler getScheduler() { return server.getScheduler(); } + /** + * @see Server#getServicesManager() + */ public static ServicesManager getServicesManager() { return server.getServicesManager(); } + /** + * @see Server#getWorlds() + */ public static List getWorlds() { return server.getWorlds(); } + /** + * @see Server#createWorld(WorldCreator options) + */ public static World createWorld(WorldCreator options) { return server.createWorld(options); } + /** + * @see Server#unloadWorld(String name, boolean save) + */ public static boolean unloadWorld(String name, boolean save) { return server.unloadWorld(name, save); } + /** + * @see Server#unloadWorld(World world, boolean save) + */ public static boolean unloadWorld(World world, boolean save) { return server.unloadWorld(world, save); } + /** + * @see Server#getWorld(String name) + */ public static World getWorld(String name) { return server.getWorld(name); } + /** + * @see Server#getWorld(UUID uid) + */ public static World getWorld(UUID uid) { return server.getWorld(uid); } + /** + * @see Server#getMap(short id) + */ public static MapView getMap(short id) { return server.getMap(id); } + /** + * @see Server#createMap(World world) + */ public static MapView createMap(World world) { return server.createMap(world); } + /** + * @see Server#reload() + */ public static void reload() { server.reload(); } + /** + * @see Server#getLogger() + */ public static Logger getLogger() { return server.getLogger(); } + /** + * @see Server#getPluginCommand(String name) + */ public static PluginCommand getPluginCommand(String name) { return server.getPluginCommand(name); } + /** + * @see Server#savePlayers() + */ public static void savePlayers() { server.savePlayers(); } + /** + * @see Server#dispatchCommand(CommandSender sender, String commandLine) + */ public static boolean dispatchCommand(CommandSender sender, String commandLine) { return server.dispatchCommand(sender, commandLine); } + /** + * @see Server#configureDbConfig(ServerConfig config) + */ public static void configureDbConfig(ServerConfig config) { server.configureDbConfig(config); } + /** + * @see Server#addRecipe(Recipe recipe) + */ public static boolean addRecipe(Recipe recipe) { return server.addRecipe(recipe); } + /** + * @see Server#getRecipesFor(ItemStack result) + */ public static List getRecipesFor(ItemStack result) { return server.getRecipesFor(result); } + /** + * @see Server#recipeIterator() + */ public static Iterator recipeIterator() { return server.recipeIterator(); } + /** + * @see Server#clearRecipes() + */ public static void clearRecipes() { server.clearRecipes(); } + /** + * @see Server#resetRecipes() + */ public static void resetRecipes() { server.resetRecipes(); } + /** + * @see Server#getCommandAliases() + */ public static Map getCommandAliases() { return server.getCommandAliases(); } + /** + * @see Server#getSpawnRadius() + */ public static int getSpawnRadius() { return server.getSpawnRadius(); } + /** + * @see Server#setSpawnRadius(int value) + */ public static void setSpawnRadius(int value) { server.setSpawnRadius(value); } + /** + * @see Server#getOnlineMode() + */ public static boolean getOnlineMode() { return server.getOnlineMode(); } + /** + * @see Server#getAllowFlight() + */ public static boolean getAllowFlight() { return server.getAllowFlight(); } + /** + * @see Server#isHardcore() + */ public static boolean isHardcore() { return server.isHardcore(); } + /** + * @see Server#shutdown() + */ public static void shutdown() { server.shutdown(); } + /** + * @see Server#broadcast(String message, String permission) + */ public static int broadcast(String message, String permission) { return server.broadcast(message, permission); } + /** + * @see Server#getOfflinePlayer(String name) + */ public static OfflinePlayer getOfflinePlayer(String name) { return server.getOfflinePlayer(name); } + /** + * @see Server#getPlayerExact(String name) + */ public static Player getPlayerExact(String name) { return server.getPlayerExact(name); } + /** + * @see Server#getIPBans() + */ public static Set getIPBans() { return server.getIPBans(); } + /** + * @see Server#banIP(String address) + */ public static void banIP(String address) { server.banIP(address); } + /** + * @see Server#unbanIP(String address) + */ public static void unbanIP(String address) { server.unbanIP(address); } + /** + * @see Server#getBannedPlayers() + */ public static Set getBannedPlayers() { return server.getBannedPlayers(); } + /** + * @see Server#setWhitelist(boolean value) + */ public static void setWhitelist(boolean value) { server.setWhitelist(value); } + /** + * @see Server#getWhitelistedPlayers() + */ public static Set getWhitelistedPlayers() { return server.getWhitelistedPlayers(); } + /** + * @see Server#reloadWhitelist() + */ public static void reloadWhitelist() { server.reloadWhitelist(); } + /** + * @see Server#getConsoleSender() + */ public static ConsoleCommandSender getConsoleSender() { return server.getConsoleSender(); } + /** + * @see Server#getOperators() + */ public static Set getOperators() { return server.getOperators(); } + /** + * @see Server#getWorldContainer() + */ public static File getWorldContainer() { return server.getWorldContainer(); } + /** + * @see Server#getMessenger() + */ public static Messenger getMessenger() { return server.getMessenger(); } + /** + * @see Server#getAllowEnd() + */ public static boolean getAllowEnd() { return server.getAllowEnd(); } + /** + * @see Server#getUpdateFolderFile() + */ public static File getUpdateFolderFile() { return server.getUpdateFolderFile(); } + /** + * @see Server#getConnectionThrottle() + */ public static long getConnectionThrottle() { return server.getConnectionThrottle(); } + /** + * @see Server#getTicksPerAnimalSpawns() + */ public static int getTicksPerAnimalSpawns() { return server.getTicksPerAnimalSpawns(); } + /** + * @see Server#getTicksPerMonsterSpawns() + */ public static int getTicksPerMonsterSpawns() { return server.getTicksPerMonsterSpawns(); } + /** + * @see Server#useExactLoginLocation() + */ public static boolean useExactLoginLocation() { return server.useExactLoginLocation(); } + /** + * @see Server#getDefaultGameMode() + */ public static GameMode getDefaultGameMode() { return server.getDefaultGameMode(); } + /** + * @see Server#setDefaultGameMode(GameMode mode) + */ public static void setDefaultGameMode(GameMode mode) { server.setDefaultGameMode(mode); } + /** + * @see Server#getOfflinePlayers() + */ public static OfflinePlayer[] getOfflinePlayers() { return server.getOfflinePlayers(); } + /** + * @see Server#createInventory(InventoryHolder owner, InventoryType type) + */ public static Inventory createInventory(InventoryHolder owner, InventoryType type) { return server.createInventory(owner, type); } + /** + * @see Server#createInventory(InventoryHolder owner, int size) + */ public static Inventory createInventory(InventoryHolder owner, int size) { return server.createInventory(owner, size); } + /** + * @see Server#createInventory(InventoryHolder owner, int size, String title) + */ public static Inventory createInventory(InventoryHolder owner, int size, String title) { return server.createInventory(owner, size, title); } + /** + * @see Server#getHelpMap() + */ public static HelpMap getHelpMap() { return server.getHelpMap(); } + /** + * @see Server#getMonsterSpawnLimit() + */ public static int getMonsterSpawnLimit() { return server.getMonsterSpawnLimit(); } + /** + * @see Server#getAnimalSpawnLimit() + */ public static int getAnimalSpawnLimit() { return server.getAnimalSpawnLimit(); } + /** + * @see Server#getWaterAnimalSpawnLimit() + */ public static int getWaterAnimalSpawnLimit() { return server.getWaterAnimalSpawnLimit(); } + /** + * @see Server#getAmbientSpawnLimit() + */ public static int getAmbientSpawnLimit() { return server.getAmbientSpawnLimit(); } + /** + * @see Server#isPrimaryThread() + */ public static boolean isPrimaryThread() { return server.isPrimaryThread(); } + /** + * @see Server#getMotd() + */ public static String getMotd() { return server.getMotd(); } + /** + * @see Server#getShutdownMessage() + */ public static String getShutdownMessage() { return server.getShutdownMessage(); } + /** + * @see Server#getWarningState() + */ public static WarningState getWarningState() { return server.getWarningState(); } + /** + * @see Server#getItemFactory() + */ public static ItemFactory getItemFactory() { return server.getItemFactory(); } + /** + * @see Server#getScoreboardManager() + */ public static ScoreboardManager getScoreboardManager() { return server.getScoreboardManager(); } diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java index 30a0060b..5416c71d 100644 --- a/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java @@ -11,6 +11,7 @@ import org.bukkit.ChatColor; import org.bukkit.Server; import org.bukkit.entity.Player; import org.bukkit.permissions.Permissible; +import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; import com.google.common.collect.ImmutableList; @@ -279,10 +280,13 @@ public abstract class Command { } /** - * Sets the list of aliases to request on registration for this command + * Sets the list of aliases to request on registration for this command. + * This is not effective outside of defining aliases in the {@link + * PluginDescriptionFile#getCommands()} (under the + * `aliases' node) is equivalent to this method. * - * @param aliases Aliases to register to this command - * @return This command object, for linking + * @param aliases aliases to register to this command + * @return this command object, for chaining */ public Command setAliases(List aliases) { this.aliases = aliases; @@ -293,10 +297,12 @@ public abstract class Command { } /** - * Sets a brief description of this command + * Sets a brief description of this command. Defining a description in the + * {@link PluginDescriptionFile#getCommands()} (under the + * `description' node) is equivalent to this method. * - * @param description New command description - * @return This command object, for linking + * @param description new command description + * @return this command object, for chaining */ public Command setDescription(String description) { this.description = description; @@ -306,8 +312,9 @@ public abstract class Command { /** * Sets the message sent when a permission check fails * - * @param permissionMessage New permission message, null to indicate default message, or an empty string to indicate no message - * @return This command object, for linking + * @param permissionMessage new permission message, null to indicate + * default message, or an empty string to indicate no message + * @return this command object, for chaining */ public Command setPermissionMessage(String permissionMessage) { this.permissionMessage = permissionMessage; @@ -317,8 +324,8 @@ public abstract class Command { /** * Sets the example usage of this command * - * @param usage New example usage - * @return This command object, for linking + * @param usage new example usage + * @return this command object, for chaining */ public Command setUsage(String usage) { this.usageMessage = usage; diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index dec22141..de42f2e8 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -560,7 +560,7 @@ public interface Player extends HumanEntity, Conversable, CommandSender, Offline * not be reliable, as it is a state provided by the client, and may therefore not be accurate. * * @return True if the player standing on a solid block, else false. - * @deprecated Inconsistent with {@link org.bukkit.craftbukkit.entity.Entity#isOnGround()} + * @deprecated Inconsistent with {@link org.bukkit.entity.Entity#isOnGround()} */ @Deprecated public boolean isOnGround(); diff --git a/src/main/java/org/bukkit/entity/ThrownPotion.java b/src/main/java/org/bukkit/entity/ThrownPotion.java index 4da1f1b9..8b382db3 100644 --- a/src/main/java/org/bukkit/entity/ThrownPotion.java +++ b/src/main/java/org/bukkit/entity/ThrownPotion.java @@ -9,8 +9,10 @@ import org.bukkit.potion.PotionEffect; * Represents a thrown potion bottle */ public interface ThrownPotion extends Projectile { + /** * Returns the effects that are applied by this potion. + * * @return The potion effects */ public Collection getEffects(); @@ -18,9 +20,9 @@ public interface ThrownPotion extends Projectile { /** * Returns a copy of the ItemStack for this thrown potion. *

- * Altering this copy will not alter the thrown potion directly. - * If you want to alter the thrown potion, you must use the - * {@link #setItemStack(ItemStack) setItemStack} method. + * Altering this copy will not alter the thrown potion directly. If you + * want to alter the thrown potion, you must use the {@link + * #setItem(ItemStack) setItemStack} method. * * @return A copy of the ItemStack for this thrown potion. */ diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java index d754d714..fa29c27e 100644 --- a/src/main/java/org/bukkit/event/Event.java +++ b/src/main/java/org/bukkit/event/Event.java @@ -1,31 +1,42 @@ package org.bukkit.event; +import org.bukkit.plugin.PluginManager; + /** - * Represents an event + * Represents an event. + * + * @see PluginManager#callEvent(Event) + * @see PluginManager#registerEvents(Listener,Plugin) */ public abstract class Event { private String name; private final boolean async; /** - * The default constructor is defined for cleaner code. - * This constructor assumes the event is synchronous. + * The default constructor is defined for cleaner code. This constructor + * assumes the event is synchronous. */ public Event() { this(false); } /** - * This constructor is used to explicitly declare an event as synchronous or asynchronous. + * This constructor is used to explicitly declare an event as synchronous + * or asynchronous. * - * @param isAsync true indicates the event will fire asynchronously. false by default + * @param isAsync true indicates the event will fire asynchronously, false + * by default from default constructor */ public Event(boolean isAsync) { this.async = isAsync; } /** - * @return Name of this event + * Convenience method for providing a user-friendly identifier. By + * default, it is the event's class's {@linkplain Class#getSimpleName() + * simple name}. + * + * @return name of this event */ public String getEventName() { if (name == null) { @@ -37,17 +48,24 @@ public abstract class Event { public abstract HandlerList getHandlers(); /** - * Any custom event that should not by synchronized with other events must use the specific constructor. - * These are the caveats of using an asynchronous event: - *

  • The event is never fired from inside code triggered by a synchronous event. - * Attempting to do so results in an {@link java.lang.IllegalStateException}.
  • - *
  • However, asynchronous event handlers may fire synchronous or asynchronous events
  • - *
  • The event may be fired multiple times simultaneously and in any order.
  • - *
  • Any newly registered or unregistered handler is ignored after an event starts execution.
  • - *
  • The handlers for this event may block for any length of time.
  • - *
  • Some implementations may selectively declare a specific event use as asynchronous. - * This behavior should be clearly defined.
  • - *
  • Asynchronous calls are not calculated in the plugin timing system.
  • + * Any custom event that should not by synchronized with other events must + * use the specific constructor. These are the caveats of using an + * asynchronous event: + *
      + *
    • The event is never fired from inside code triggered by a + * synchronous event. Attempting to do so results in an {@link + * java.lang.IllegalStateException}. + *
    • However, asynchronous event handlers may fire synchronous or + * asynchronous events + *
    • The event may be fired multiple times simultaneously and in any + * order. + *
    • Any newly registered or unregistered handler is ignored after an + * event starts execution. + *
    • The handlers for this event may block for any length of time. + *
    • Some implementations may selectively declare a specific event use + * as asynchronous. This behavior should be clearly defined. + *
    • Asynchronous calls are not calculated in the plugin timing system. + *
    * * @return false by default, true if the event fires asynchronously */ @@ -58,20 +76,20 @@ public abstract class Event { public enum Result { /** - * Deny the event. - * Depending on the event, the action indicated by the event will either not take place or will be reverted. - * Some actions may not be denied. + * Deny the event. Depending on the event, the action indicated by the + * event will either not take place or will be reverted. Some actions + * may not be denied. */ DENY, /** - * Neither deny nor allow the event. - * The server will proceed with its normal handling. + * Neither deny nor allow the event. The server will proceed with its + * normal handling. */ DEFAULT, /** - * Allow / Force the event. - * The action indicated by the event will take place if possible, even if the server would not normally allow the action. - * Some actions may not be allowed. + * Allow / Force the event. The action indicated by the event will + * take place if possible, even if the server would not normally allow + * the action. Some actions may not be allowed. */ ALLOW; } diff --git a/src/main/java/org/bukkit/plugin/Plugin.java b/src/main/java/org/bukkit/plugin/Plugin.java index 40cda891..5a91ecb3 100644 --- a/src/main/java/org/bukkit/plugin/Plugin.java +++ b/src/main/java/org/bukkit/plugin/Plugin.java @@ -130,9 +130,20 @@ public interface Plugin extends TabExecutor { public void setNaggable(boolean canNag); /** - * Gets the {@link EbeanServer} tied to this plugin + * Gets the {@link EbeanServer} tied to this plugin. This will only be + * available if enabled in the {@link + * PluginDescriptionFile#isDatabaseEnabled()} + *

    + * For more information on the use of + * Avaje Ebeans ORM, see Avaje Ebeans + * Documentation + *

    + * For an example using Ebeans ORM, see Bukkit's Homebukkit Plugin + * * - * @return Ebean server instance + * @return ebean server instance or null if not enabled */ public EbeanServer getDatabase(); diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java index 3a5f4e00..d2a59e40 100644 --- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java @@ -7,6 +7,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.PluginCommand; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; import org.yaml.snakeyaml.Yaml; @@ -16,7 +21,148 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; /** - * Provides access to a Plugins description file, plugin.yaml + * This type is the runtime-container for the information in the plugin.yml. + * All plugins must have a respective plugin.yml. For plugins written in java + * using the standard plugin loader, this file must be in the root of the jar + * file. + *

    + * When Bukkit loads a plugin, it needs to know some basic information about + * it. It reads this information from a YAML file, 'plugin.yml'. This file + * consists of a set of attributes, each defined on a new line and with no + * indentation. + *

    + * Every (almost* every) method corresponds with a specific entry in the + * plugin.yml. These are the required entries for every plugin.yml: + *

      + *
    • {@link #getName()} - name + *
    • {@link #getVersion()} - version + *
    • {@link #getMain()} - main + *
    + *

    + * Failing to include any of these items will throw an exception and cause the + * server to ignore your plugin. + *

    + * This is a list of the possible yaml keys, with specific details included in + * the respective method documentations: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    NodeMethodSummary
    name{@link #getName()}The unique name of plugin
    version{@link #getVersion()}A plugin revision identifier
    main{@link #getMain()}The plugin's initial class file
    author
    authors
    {@link #getAuthors()}The plugin contributors
    description{@link #getDescription()}Human readable plugin summary
    website{@link #getWebsite()}The URL to the plugin's site
    prefix{@link #getPrefix()}The token to prefix plugin log entries
    database{@link #isDatabaseEnabled()}Indicator to enable database support
    load{@link #getLoad()}The phase of server-startup this plugin will load during
    depend{@link #getDepend()}Other required plugins
    softdepend{@link #getSoftDepend()}Other plugins that add functionality
    loadbefore{@link #getLoadBefore()}The inverse softdepend
    commands{@link #getCommands()}The commands the plugin will register
    permissions{@link #getPermissions()}The permissions the plugin will register
    default-permission{@link #getPermissionDefault()}The default {@link Permission#getDefault() default} permission + * state for defined {@link #getPermissions() permissions} the plugin + * will register
    + *

    + * A plugin.yml example:

    + *name: Inferno
    + *version: 1.4.1
    + *description: This plugin is so 31337. You can set yourself on fire.
    + *# We could place every author in the authors list, but chose not to for illustrative purposes
    + *# Also, having an author distinguishes that person as the project lead, and ensures their
    + *# name is displayed first
    + *author: CaptainInflamo
    + *authors: [Cogito, verrier, EvilSeph]
    + *website: http://www.curse.com/server-mods/minecraft/myplugin
    + *
    + *main: com.captaininflamo.bukkit.inferno.Inferno
    + *database: false
    + *depend: [NewFire, FlameWire]
    + *
    + *commands:
    + *  flagrate:
    + *    description: Set yourself on fire.
    + *    aliases: [combust_me, combustMe]
    + *    permission: inferno.flagrate
    + *    usage: Syntax error! Simply type /<command> to ignite yourself.
    + *  burningdeaths:
    + *    description: List how many times you have died by fire.
    + *    aliases: [burning_deaths, burningDeaths]
    + *    permission: inferno.burningdeaths
    + *    usage: |
    + *      /<command> [player]
    + *      Example: /<command> - see how many times you have burned to death
    + *      Example: /<command> CaptainIce - see how many times CaptainIce has burned to death
    + *
    + *permissions:
    + *  inferno.*:
    + *    description: Gives access to all Inferno commands
    + *    children:
    + *      inferno.flagrate: true
    + *      inferno.burningdeaths: true
    + *      inferno.burningdeaths.others: true
    + *  inferno.flagrate:
    + *    description: Allows you to ignite yourself
    + *    default: true
    + *  inferno.burningdeaths:
    + *    description: Allows you to see how many times you have burned to death
    + *    default: true
    + *  inferno.burningdeaths.others:
    + *    description: Allows you to see how many times others have burned to death
    + *    default: op
    + *    children:
    + *      inferno.burningdeaths: true
    + *
    */ public final class PluginDescriptionFile { private static final Yaml yaml = new Yaml(new SafeConstructor()); @@ -46,7 +192,8 @@ public final class PluginDescriptionFile { * Loads a PluginDescriptionFile from the specified reader * * @param reader The reader - * @throws InvalidDescriptionException If the PluginDescriptionFile is invalid + * @throws InvalidDescriptionException If the PluginDescriptionFile is + * invalid */ public PluginDescriptionFile(final Reader reader) throws InvalidDescriptionException { loadMap(asMap(yaml.load(reader))); @@ -66,99 +213,522 @@ public final class PluginDescriptionFile { } /** - * Saves this PluginDescriptionFile to the given writer + * Gives the name of the plugin. This name is a unique identifier for + * plugins. + *
      + *
    • Must consist of all alphanumeric characters, underscores, hyphon, + * and period (a-z,A-Z,0-9, _.-). Any other character will cause the + * plugin.yml to fail loading. + *
    • Used to determine the name of the plugin's data folder. Data + * folders are placed in the ./plugins/ directory by default, but this + * behavior should not be relied on. {@link Plugin#getDataFolder()} + * should be used to reference the data folder. + *
    • It is good practice to name your jar the same as this, for example + * 'MyPlugin.jar'. + *
    • Case sensitive. + *
    • The is the token referenced in {@link #getDepend()}, {@link + * #getSoftDepend()}, and {@link #getLoadBefore()}. + *
    + *

    + * In the plugin.yml, this entry is named name. + *

    + * Example:

    name: MyPlugin
    * - * @param writer Writer to output this file to + * @return the name of the plugin */ - public void save(Writer writer) { - yaml.dump(saveMap(), writer); + public String getName() { + return name; } /** - * Returns the name of a plugin + * Gives the version of the plugin. + *
      + *
    • Version is an arbitrary string, however the most common format is + * MajorRelease.MinorRelease.Build (eg: 1.4.1). + *
    • Typically you will increment this every time you release a new + * feature or bug fix. + *
    • Displayed when a user types /version PluginName + *
    + *

    + * In the plugin.yml, this entry is named version. + *

    + * Example:

    version: 1.4.1
    * - * @return String name + * @return the version of the plugin */ - public String getName() { - return name; + public String getVersion() { + return version; } /** - * Returns the version of a plugin + * Gives the fully qualified name of the main class for a plugin. The + * format should follow the {@link ClassLoader#loadClass(String)} syntax + * to successfully be resolved at runtime. For most plugins, this is the + * class that extends {@link JavaPlugin}. + *
      + *
    • This must contain the full namespace including the class file + * itself. + *
    • If your namespace is org.bukkit.plugin, and your class + * file is called MyPlugin then this must be + * org.bukkit.plugin.MyPlugin + *
    • No plugin can use org.bukkit. as a base package for + * any class, including the main class. + *
    + *

    + * In the plugin.yml, this entry is named main. + *

    + * Example: + *

    main: org.bukkit.plugin.MyPlugin
    * - * @return String name + * @return the fully qualified main class for the plugin */ - public String getVersion() { - return version; + public String getMain() { + return main; } /** - * Returns the name of a plugin including the version + * Gives a human-friendly description of the functionality the plugin + * provides. + *
      + *
    • The description can have multiple lines. + *
    • Displayed when a user types /version PluginName + *
    + *

    + * In the plugin.yml, this entry is named description. + *

    + * Example: + *

    description: This plugin is so 31337. You can set yourself on fire.
    * - * @return String name + * @return description of this plugin, or null if not specified */ - public String getFullName() { - return name + " v" + version; + public String getDescription() { + return description; } /** - * Returns the main class for a plugin + * Gives the phase of server startup that the plugin should be loaded. + *
      + *
    • Possible values are in {@link PluginLoadOrder}. + *
    • Defaults to {@link PluginLoadOrder#POSTWORLD}. + *
    • Certain caveats apply to each phase. + *
    • When different, {@link #getDepend()}, {@link #getSoftDepend()}, and + * {@link #getLoadBefore()} become relative in order loaded per-phase. + * If a plugin loads at STARTUP, but a dependency loads + * at POSTWORLD, the dependency will not be loaded before + * the plugin is loaded. + *
    + *

    + * In the plugin.yml, this entry is named load. + *

    + * Example:

    load: STARTUP
    * - * @return Java classpath + * @return the phase when the plugin should be loaded */ - public String getMain() { - return main; + public PluginLoadOrder getLoad() { + return order; } - public Map> getCommands() { - return commands; + /** + * Gives the list of authors for the plugin. + *
      + *
    • Gives credit to the developer. + *
    • Used in some server error messages to provide helpful feedback on + * who to contact when an error occurs. + *
    • A bukkit.org forum handle or email address is recommended. + *
    • Is displayed when a user types /version PluginName + *
    • authors must be in YAML list + * format. + *
    + *

    + * In the plugin.yml, this has two entries, author and + * authors. + *

    + * Single author example: + *

    author: CaptainInflamo
    + * Multiple author example: + *
    authors: [Cogito, verrier, EvilSeph]
    + * When both are specified, author will be the first entry in the list, so + * this example: + *
    author: Grum
    +     *authors:
    +     *- feildmaster
    +     *- amaranth
    + * Is equivilant to this example: + *
    authors: [Grum, feildmaster, aramanth]
    + * + * @return an immutable list of the plugin's authors + */ + public List getAuthors() { + return authors; } + /** + * Gives the plugin's or plugin's author's website. + *
      + *
    • A link to the Curse page that includes documentation and downloads + * is highly recommended. + *
    • Displayed when a user types /version PluginName + *
    + *

    + * In the plugin.yml, this entry is named website. + *

    + * Example: + *

    website: http://www.curse.com/server-mods/minecraft/myplugin
    + * + * @return description of this plugin, or null if not specified + */ + public String getWebsite() { + return website; + } + + /** + * Gives if the plugin uses a database. + *
      + *
    • Using a database is non-trivial. + *
    • Valid values include true and false + *
    + *

    + * In the plugin.yml, this entry is named database. + *

    + * Example: + *

    database: false
    + * + * @return if this plugin requires a database + * @see Plugin#getDatabase() + */ + public boolean isDatabaseEnabled() { + return database; + } + + /** + * Gives a list of other plugins that the plugin requires. + *
      + *
    • Use the value in the {@link #getName()} of the target plugin to + * specify the dependency. + *
    • If any plugin listed here is not found, your plugin will fail to + * load at startup. + *
    • If multiple plugins list each other in depend, + * creating a network with no individual plugin does not list another + * plugin in the network, + * all plugins in that network will fail. + *
    • depend must be in must be in YAML list + * format. + *
    + *

    + * In the plugin.yml, this entry is named depend. + *

    + * Example: + *

    depend:
    +     *- OnePlugin
    +     *- AnotherPlugin
    + * + * @return immutable list of the plugin's dependencies + */ public List getDepend() { return depend; } + /** + * Gives a list of other plugins that the plugin requires for full + * functionality. The {@link PluginManager} will make best effort to treat + * all entries here as if they were a {@link #getDepend() dependency}, but + * will never fail because of one of these entries. + *
      + *
    • Use the value in the {@link #getName()} of the target plugin to + * specify the dependency. + *
    • When an unresolvable plugin is listed, it will be ignored and does + * not affect load order. + *
    • When a circular dependency occurs (a network of plugins depending + * or soft-dependending each other), it will arbitrarily choose a + * plugin that can be resolved when ignoring soft-dependencies. + *
    • softdepend must be in YAML list + * format. + *
    + *

    + * In the plugin.yml, this entry is named softdepend. + *

    + * Example: + *

    softdepend: [OnePlugin, AnotherPlugin]
    + * + * @return immutable list of the plugin's preferred dependencies + */ public List getSoftDepend() { return softDepend; } /** - * Gets the list of plugins that should consider this plugin a soft-dependency - * @return immutable list of plugins that should consider this plugin a soft-dependency + * Gets the list of plugins that should consider this plugin a + * soft-dependency. + *
      + *
    • Use the value in the {@link #getName()} of the target plugin to + * specify the dependency. + *
    • The plugin should load before any other plugins listed here. + *
    • Specifying another plugin here is strictly equivalent to having the + * specified plugin's {@link #getSoftDepend()} include {@link + * #getName() this plugin}. + *
    • loadbefore must be in YAML list + * format. + *
    + *

    + * In the plugin.yml, this entry is named loadbefore. + *

    + * Example: + *

    loadbefore:
    +     *- OnePlugin
    +     *- AnotherPlugin
    + * + * @return immutable list of plugins that should consider this plugin a + * soft-dependency */ public List getLoadBefore() { return loadBefore; } - public PluginLoadOrder getLoad() { - return order; - } - /** - * Gets the description of this plugin + * Gives the token to prefix plugin-specific logging messages with. + *
      + *
    • This includes all messages using {@link Plugin#getLogger()}. + *
    • If not specified, the server uses the plugin's {@link #getName() + * name}. + *
    • This should clearly indicate what plugin is being logged. + *
    + *

    + * In the plugin.yml, this entry is named prefix. + *

    + * Example:

    prefix: ex-why-zee
    * - * @return Description of this plugin + * @return the prefixed logging token, or null if not specified */ - public String getDescription() { - return description; - } - - public List getAuthors() { - return authors; - } - - public String getWebsite() { - return website; - } - - public boolean isDatabaseEnabled() { - return database; + public String getPrefix() { + return prefix; } - public void setDatabaseEnabled(boolean database) { - this.database = database; + /** + * Gives the map of command-name to command-properties. Each entry in this + * map corresponds to a single command and the respective values are the + * properties of the command. Each property, with the exception of + * aliases, can be defined at runtime using methods in {@link + * PluginCommand} and are defined here only as a convenience. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    NodeMethodTypeDescriptionExample
    description{@link PluginCommand#setDescription(String)}StringA user-friendly description for a command. It is useful for + * documentation purposes as well as in-game help.
    description: Set yourself on fire
    aliases{@link PluginCommand#setAliases(List)}String or List of + * stringsAlternative command names, with special usefulness for commands + * that are already registered. Aliases are not effective when + * defined at runtime, so the plugin description file is the + * only way to have them properly defined.Single alias format: + *
    aliases: combust_me
    or + * multiple alias format: + *
    aliases: [combust_me, combustMe]
    permission{@link PluginCommand#setPermission(String)}StringThe name of the {@link Permission} required to use the command. + * A user without the permission will receive the specified + * message (see {@linkplain + * PluginCommand#setPermissionMessage(String) below}), or a + * standard one if no specific message is defined. Without the + * permission node, no {@link + * PluginCommand#setExecutor(CommandExecutor) CommandExecutor} or + * {@link PluginCommand#setTabCompleter(TabCompleter) + * TabCompleter} will be called.
    permission: inferno.flagrate
    permission-message{@link PluginCommand#setPermissionMessage(String)}String
      + *
    • Displayed to a player that attempts to use a command, but + * does not have the required permission. See {@link + * PluginCommand#getPermission() above}. + *
    • <permission> is a macro that is replaced with the + * permission node required to use the command. + *
    • Using empty quotes is a valid way to indicate nothing + * should be displayed to a player. + *
    permission-message: You do not have /<permission>
    usage{@link PluginCommand#setUsage(String)}StringThis message is displayed to a player when the {@link + * PluginCommand#setExecutor(CommandExecutor)} {@linkplain + * CommandExecutor#onCommand(CommandSender,Command,String,String[]) + * returns false}. <command> is a macro that is replaced + * the command issued.
    usage: Syntax error! Perhaps you meant /<command> PlayerName?
    + * It is worth noting that to use a colon in a yaml, like + * `usage: Usage: /god [player]', you need to + * surround + * the message with double-quote: + *
    usage: "Usage: /god [player]"
    + * The commands are structured as a hiearchy of nested mappings. + * The primary (top-level, no intendentation) node is + * `commands', while each individual command name is + * indented, indicating it maps to some value (in our case, the + * properties of the table above). + *

    + * Here is an example bringing together the piecemeal examples above, as + * well as few more definitions:

    +     *commands:
    +     *  flagrate:
    +     *    description: Set yourself on fire.
    +     *    aliases: [combust_me, combustMe]
    +     *    permission: inferno.flagrate
    +     *    permission-message: You do not have /<permission>
    +     *    usage: Syntax error! Perhaps you meant /<command> PlayerName?
    +     *  burningdeaths:
    +     *    description: List how many times you have died by fire.
    +     *    aliases:
    +     *    - burning_deaths
    +     *    - burningDeaths
    +     *    permission: inferno.burningdeaths
    +     *    usage: |
    +     *      /<command> [player]
    +     *      Example: /<command> - see how many times you have burned to death
    +     *      Example: /<command> CaptainIce - see how many times CaptainIce has burned to death
    +     *  # The next command has no description, aliases, etc. defined, but is still valid
    +     *  # Having an empty declaration is useful for defining the description, permission, and messages from a configuration dynamically
    +     *  apocalypse:
    +     *
    + * + * @return the commands this plugin will register + */ + public Map> getCommands() { + return commands; } + /** + * Gives the list of permissions the plugin will register at runtime, + * immediately proceding enabling. The format for defining permissions is + * a map from permission name to properties. To represent a map without + * any specific property, empty curly-braces ( + * {} ) may be used (as a null value is not + * accepted, unlike the {@link #getCommands() commands} above). + *

    + * A list of optional properties for permissions: + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
    NodeDescriptionExample
    descriptionPlaintext (user-friendly) description of what the permission + * is for.
    description: Allows you to set yourself on fire
    defaultThe default state for the permission, as defined by {@link + * Permission#getDefault()}. If not defined, it will be set to + * the value of {@link PluginDescriptionFile#getPermissionDefault()}. + *

    + * For reference:

      + *
    • true - Represents a positive assignment to + * {@link Permissible permissibles}. + *
    • false - Represents no assignment to {@link + * Permissible permissibles}. + *
    • op - Represents a positive assignment to + * {@link Permissible#isOp() operator permissibles}. + *
    • notop - Represents a positive assignment to + * {@link Permissible#isOp() non-operator permissibiles}. + *
    default: true
    childrenAllows other permissions to be set as a {@linkplain + * Permission#getChildren() relation} to the parent permission. + * When a parent permissions is assigned, child permissions are + * respectively assigned as well. + *
      + *
    • When a parent permission is assigned negatively, child + * permissions are assigned based on an inversion of their + * association. + *
    • When a parent permission is assigned positively, child + * permissions are assigned based on their association. + *
    + *

    + * Child permissions may be defined in a number of ways:

      + *
    • Children may be defined as a list of + * names. Using a list will treat all children associated + * positively to their parent. + *
    • Children may be defined as a map. Each permission name maps + * to either a boolean (representing the association), or a + * nested permission definition (just as another permission). + * Using a nested definition treats the child as a positive + * association. + *
    • A nested permission definition must be a map of these same + * properties. To define a valid nested permission without + * defining any specific property, empty curly-braces ( + * {} ) must be used. + *
    • A nested permission may carry it's own nested permissions + * as children, as they may also have nested permissions, and + * so forth. There is no direct limit to how deep the + * permission tree is defined. + *
    As a list: + *
    children: [inferno.flagrate, inferno.burningdeaths]
    + * Or as a mapping: + *
    children:
    +     *  inferno.flagrate: true
    +     *  inferno.burningdeaths: true
    + * An additional example showing basic nested values can be seen + * here. + *
    + * The permissions are structured as a hiearchy of nested mappings. + * The primary (top-level, no intendentation) node is + * `permissions', while each individual permission name is + * indented, indicating it maps to some value (in our case, the + * properties of the table above). + *

    + * Here is an example using some of the properties:

    +     *permissions:
    +     *  inferno.*:
    +     *    description: Gives access to all Inferno commands
    +     *    children:
    +     *      inferno.flagrate: true
    +     *      inferno.burningdeaths: true
    +     *  inferno.flagate:
    +     *    description: Allows you to ignite yourself
    +     *    default: true
    +     *  inferno.burningdeaths:
    +     *    description: Allows you to see how many times you have burned to death
    +     *    default: true
    +     *
    + * Another example, with nested definitions, can be found here. + */ public List getPermissions() { if (permissions == null) { if (lazyPermissions == null) { @@ -171,16 +741,53 @@ public final class PluginDescriptionFile { return permissions; } + /** + * Gives the default {@link Permission#getDefault() default} state of + * {@link #getPermissions() permissions} registered for the plugin. + *
      + *
    • If not specified, it will be {@link PermissionDefault#OP}. + *
    • It is matched using {@link PermissionDefault#getByName(String)} + *
    • It only affects permissions that do not define the + * default node. + *
    • It may be any value in {@link PermissionDefault}. + *
    + *

    + * In the plugin.yml, this entry is named default-permission. + *

    + * Example:

    default-permission: NOT_OP
    + * + * @return the default value for the plugin's permissions + */ public PermissionDefault getPermissionDefault() { return defaultPerm; } + /** + * Returns the name of a plugin, including the version. This method is + * provided for convenience; it uses the {@link #getName()} and {@link + * #getVersion()} entries. + * + * @return a descriptive name of the plugin and respective version + */ + public String getFullName() { + return name + " v" + version; + } + public String getClassLoaderOf() { return classLoaderOf; } - public String getPrefix() { - return prefix; + public void setDatabaseEnabled(boolean database) { + this.database = database; + } + + /** + * Saves this PluginDescriptionFile to the given writer + * + * @param writer Writer to output this file to + */ + public void save(Writer writer) { + yaml.dump(saveMap(), writer); } private void loadMap(Map map) throws InvalidDescriptionException { diff --git a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index 58baf478..49d39893 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -307,10 +307,12 @@ public abstract class JavaPlugin extends PluginBase { } /** - * Gets the command with the given name, specific to this plugin + * Gets the command with the given name, specific to this plugin. Commands + * need to be registered in the {@link PluginDescriptionFile#getCommands() + * PluginDescriptionFile} to exist at runtime. * - * @param name Name or alias of the command - * @return PluginCommand if found, otherwise null + * @param name name or alias of the command + * @return the plugin command if found, otherwise null */ public PluginCommand getCommand(String name) { String alias = name.toLowerCase(); diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java index 5c09a0e9..fd307ebc 100644 --- a/src/main/java/org/bukkit/scoreboard/Objective.java +++ b/src/main/java/org/bukkit/scoreboard/Objective.java @@ -88,7 +88,6 @@ public interface Objective { /** * Gets a player's Score for an Objective on this Scoreboard * - * @param objective Objective for the Score * @param player Player for the Score * @return Score tracking the Objective and player specified * @throws IllegalArgumentException if player is null diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java index c0773e39..b3269618 100644 --- a/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java @@ -158,7 +158,6 @@ public interface Team { /** * Unregisters this team from the Scoreboard * - * @param team Team to unregister * @throws IllegalStateException if this team has been unregistered */ void unregister() throws IllegalStateException; diff --git a/src/main/javadoc/org/bukkit/plugin/doc-files/permissions-example_plugin.yml b/src/main/javadoc/org/bukkit/plugin/doc-files/permissions-example_plugin.yml new file mode 100644 index 00000000..34d0381a --- /dev/null +++ b/src/main/javadoc/org/bukkit/plugin/doc-files/permissions-example_plugin.yml @@ -0,0 +1,64 @@ +name: ScrapBukkit +main: com.dinnerbone.bukkit.scrap.ScrapBukkit +version: 1.0.0 +website: http://www.bukkit.org +author: The Bukkit Team +description: > + Miscellaneous administrative commands for Bukkit. + This plugin is one of the default plugins shipped with Bukkit. +# commands: snipped + +permissions: + scrapbukkit.*: + description: Gives all permissions for Scrapbukkit + default: op + children: + scrapbukkit.remove: + description: Allows the player to remove items from anyones inventory + children: + scrapbukkit.remove.self: + description: Allows the player to remove items from their own inventory + scrapbukkit.remove.other: + description: Allows the player to remove items from other peoples inventory + + scrapbukkit.time: + description: Allows the player to view and change the time + children: + scrapbukkit.time.view: + description: Allows the player to view the time + default: true + scrapbukkit.time.change: + description: Allows the player to change the time + + scrapbukkit.tp: + description: Allows the player to teleport anyone to anyone else + children: + scrapbukkit.tp.here: + description: Allows the player to teleport other players to themselves + scrapbukkit.tp.self: + description: Allows the player to teleport themselves to another player + scrapbukkit.tp.other: + description: Allows the player to teleport anyone to another player + + scrapbukkit.give: + description: Allows the player to give items + children: + scrapbukkit.give.self: + description: Allows the player to give themselves items + scrapbukkit.give.other: + description: Allows the player to give other players items + + scrapbukkit.clear: + description: Allows the player to clear inventories + children: + scrapbukkit.clear.self: + description: Allows the player to clear their own inventory + scrapbukkit.clear.other: + description: Allows the player to clear other players inventory + + scrapbukkit.some.standard.perm: {} + scrapbukkit.some.other.perm: true + scrapbukkit.some.bad.perm: false + # This is defined here individually, as simply giving it an association will not cause it to exist at runtime + scrapbukkit.some.bad.perm: {} + scrapbukkit.some.other.perm: {} -- cgit v1.2.3