Adding/expanding documentation

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
Bukkit/Spigot 2012-02-26 12:13:30 -05:00
parent 795a61bbeb
commit 15e2f69fa6
20 changed files with 162 additions and 16 deletions

View file

@ -80,6 +80,10 @@ public enum ChatColor {
*/ */
MAGIC('k', 0x10); MAGIC('k', 0x10);
/**
* The special character which prefixes all chat colour codes. Use this if you need to dynamically
* convert colour codes from your custom format.
*/
public static final char COLOR_CHAR = '\u00A7'; public static final char COLOR_CHAR = '\u00A7';
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK]"); private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)" + String.valueOf(COLOR_CHAR) + "[0-9A-FK]");

View file

@ -11,19 +11,61 @@ import org.bukkit.potion.Potion;
* A list of effects that the server is able to send to players. * A list of effects that the server is able to send to players.
*/ */
public enum Effect { public enum Effect {
/**
* An alternate click sound.
*/
CLICK2(1000, Type.SOUND), CLICK2(1000, Type.SOUND),
/**
* A click sound.
*/
CLICK1(1001, Type.SOUND), CLICK1(1001, Type.SOUND),
/**
* Sound of a bow firing.
*/
BOW_FIRE(1002, Type.SOUND), BOW_FIRE(1002, Type.SOUND),
/**
* Sound of a door opening/closing.
*/
DOOR_TOGGLE(1003, Type.SOUND), DOOR_TOGGLE(1003, Type.SOUND),
/**
* Sound of fire being extinguished.
*/
EXTINGUISH(1004, Type.SOUND), EXTINGUISH(1004, Type.SOUND),
/**
* A song from a record. Needs the record item ID as additional info
*/
RECORD_PLAY(1005, Type.SOUND, Material.class), RECORD_PLAY(1005, Type.SOUND, Material.class),
/**
* Sound of ghast shrieking.
*/
GHAST_SHRIEK(1007, Type.SOUND), GHAST_SHRIEK(1007, Type.SOUND),
/**
* Sound of ghast firing.
*/
GHAST_SHOOT(1008, Type.SOUND), GHAST_SHOOT(1008, Type.SOUND),
/**
* Sound of blaze firing.
*/
BLAZE_SHOOT(1009, Type.SOUND), BLAZE_SHOOT(1009, Type.SOUND),
/**
* A visual smoke effect. Needs direction as additional info.
*/
SMOKE(2000, Type.VISUAL, BlockFace.class), SMOKE(2000, Type.VISUAL, BlockFace.class),
/**
* Visual effect of a block breaking. Needs block ID as additional info.
*/
STEP_SOUND(2001, Type.SOUND, Material.class), STEP_SOUND(2001, Type.SOUND, Material.class),
/**
* Visual effect of a splash potion breaking. Needs potion data value as additional info.
*/
POTION_BREAK(2002, Type.VISUAL, Potion.class), POTION_BREAK(2002, Type.VISUAL, Potion.class),
/**
* An ender eye signal; a visual effect.
*/
ENDER_SIGNAL(2003, Type.VISUAL), ENDER_SIGNAL(2003, Type.VISUAL),
/**
* The flames seen on a mobspawner; a visual effect.
*/
MOBSPAWNER_FLAMES(2004, Type.VISUAL); MOBSPAWNER_FLAMES(2004, Type.VISUAL);
private final int id; private final int id;

View file

@ -6,11 +6,26 @@ import com.google.common.collect.Maps;
public enum Instrument { public enum Instrument {
PIANO(0x0), // All other /**
BASS_DRUM(0x1), // Stone * Piano is the standard instrument for a note block.
SNARE_DRUM(0x2), // Sand */
STICKS(0x3), // Glass PIANO(0x0),
BASS_GUITAR(0x4); // Wood /**
* Bass drum is normally played when a note block is on top of a stone-like block
*/
BASS_DRUM(0x1),
/**
* Snare drum is normally played when a note block is on top of a sandy block.
*/
SNARE_DRUM(0x2),
/**
* Sticks are normally played when a note block is on top of a glass block.
*/
STICKS(0x3),
/**
* Bass guitar is normally played when a note block is on top of a wooden block.
*/
BASS_GUITAR(0x4);
private final byte type; private final byte type;
private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap(); private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
@ -19,10 +34,18 @@ public enum Instrument {
this.type = (byte) type; this.type = (byte) type;
} }
/**
* @return The type ID of this instrument.
*/
public byte getType() { public byte getType() {
return this.type; return this.type;
} }
/**
* Get an instrument by its type ID.
* @param type The type ID
* @return The instrument
*/
public static Instrument getByType(final byte type) { public static Instrument getByType(final byte type) {
return BY_DATA.get(type); return BY_DATA.get(type);
} }

View file

@ -4,11 +4,32 @@ package org.bukkit;
* Tree and organic structure types. * Tree and organic structure types.
*/ */
public enum TreeType { public enum TreeType {
/**
* Regular tree, no branches
*/
TREE, TREE,
/**
* Regular tree, extra tall with branches
*/
BIG_TREE, BIG_TREE,
/**
* Redwood tree, shaped like a pine tree
*/
REDWOOD, REDWOOD,
/**
* Tall redwood tree with just a few leaves at the top
*/
TALL_REDWOOD, TALL_REDWOOD,
/**
* Birch tree
*/
BIRCH, BIRCH,
/**
* Big red mushroom; short and fat
*/
RED_MUSHROOM, RED_MUSHROOM,
/**
* Big brown mushroom; tall and umbrella-like
*/
BROWN_MUSHROOM BROWN_MUSHROOM
} }

View file

@ -921,6 +921,11 @@ public interface World extends PluginMessageRecipient, Metadatable {
return id; return id;
} }
/**
* Get an environment by ID
* @param id The ID of the environment
* @return The environment
*/
public static Environment getEnvironment(int id) { public static Environment getEnvironment(int id) {
return lookup.get(id); return lookup.get(id);
} }

View file

@ -151,6 +151,12 @@ public interface Block extends Metadatable {
*/ */
void setData(byte data); void setData(byte data);
/**
* Sets the metadata for this block
*
* @param data New block specific metadata
* @param applyPhysics False to cancel physics from the changed block.
*/
void setData(byte data, boolean applyPhysics); void setData(byte data, boolean applyPhysics);
/** /**
@ -168,8 +174,23 @@ public interface Block extends Metadatable {
*/ */
boolean setTypeId(int type); boolean setTypeId(int type);
/**
* Sets the type-id of this block
*
* @param type Type-Id to change this block to
* @param applyPhysics False to cancel physics on the changed block.
* @return whether the block was changed
*/
boolean setTypeId(int type, boolean applyPhysics); boolean setTypeId(int type, boolean applyPhysics);
/**
* Sets the type-id of this block
*
* @param type Type-Id to change this block to
* @param data The data value to change this block to
* @param applyPhysics False to cancel physics on the changed block
* @return whether the block was changed
*/
boolean setTypeIdAndData(int type, byte data, boolean applyPhysics); boolean setTypeIdAndData(int type, byte data, boolean applyPhysics);
/** /**

View file

@ -146,7 +146,13 @@ public interface BlockState extends Metadatable {
*/ */
boolean update(boolean force); boolean update(boolean force);
/**
* @return The data as a raw byte.
*/
public byte getRawData(); public byte getRawData();
/**
* @param data The new data value for the block.
*/
public void setRawData(byte data); public void setRawData(byte data);
} }

View file

@ -4,8 +4,17 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
public enum PistonMoveReaction { public enum PistonMoveReaction {
/**
* Indicates that the block can be pushed or pulled.
*/
MOVE(0), MOVE(0),
/**
* Indicates the block is fragile and will break if pushed on.
*/
BREAK(1), BREAK(1),
/**
* Indicates that the block will resist being pushed or pulled.
*/
BLOCK(2); BLOCK(2);
private int id; private int id;
@ -20,10 +29,17 @@ public enum PistonMoveReaction {
this.id = id; this.id = id;
} }
/**
* @return The ID of the move reaction
*/
public int getId() { public int getId() {
return this.id; return this.id;
} }
/**
* @param id An ID
* @return The move reaction with that ID
*/
public static PistonMoveReaction getById(int id) { public static PistonMoveReaction getById(int id) {
return byId.get(id); return byId.get(id);
} }

View file

@ -14,6 +14,10 @@ import java.util.Map;
* and returns the class.</li> * and returns the class.</li>
* <li>A constructor that accepts a single {@link Map}&lt;{@link String}, {@link Object}>.</li> * <li>A constructor that accepts a single {@link Map}&lt;{@link String}, {@link Object}>.</li>
* </ul> * </ul>
* In addition to implementing this interface, you must register the class with
* {@link ConfigurationSerialization#registerClass(Class)}.
* @see DelegateDeserialization
* @see SerializableAs
*/ */
public interface ConfigurationSerializable { public interface ConfigurationSerializable {
/** /**

View file

@ -199,6 +199,7 @@ public class ConfigurationSerialization {
* *
* @param clazz Class to register * @param clazz Class to register
* @param alias Alias to register as * @param alias Alias to register as
* @see SerializableAs
*/ */
public static void registerClass(Class<? extends ConfigurationSerializable> clazz, String alias) { public static void registerClass(Class<? extends ConfigurationSerializable> clazz, String alias) {
aliases.put(alias, clazz); aliases.put(alias, clazz);

View file

@ -6,8 +6,8 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
/** /**
* Represents a {@link ConfigurationSerializable} that will delegate all deserialization to another * Applies to a {@link ConfigurationSerializable} that will delegate all deserialization to another
* {@link ConfigurationSerializable} * {@link ConfigurationSerializable}.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE) @Target(ElementType.TYPE)

View file

@ -10,8 +10,12 @@ import java.lang.annotation.Target;
* If this is not present on a {@link ConfigurationSerializable} class, it will use the * If this is not present on a {@link ConfigurationSerializable} class, it will use the
* fully qualified name of the class. * fully qualified name of the class.
* <p> * <p>
* This value will be stored in the configuration so that the configuration deserialization
* can determine what type it is.
* <p>
* Using this annotation on any other class than a {@link ConfigurationSerializable} will * Using this annotation on any other class than a {@link ConfigurationSerializable} will
* have no effect. * have no effect.
* @see ConfigurationSerialization#registerClass(Class, String)
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE) @Target(ElementType.TYPE)

View file

@ -1,6 +1,6 @@
package org.bukkit.entity; package org.bukkit.entity;
/** /**
* Represents an egg. * Represents a thrown egg.
*/ */
public interface Egg extends Projectile {} public interface Egg extends Projectile {}

View file

@ -1,7 +1,7 @@
package org.bukkit.entity; package org.bukkit.entity;
/** /**
* Represents an Ender Pearl entity * Represents a thrown Ender Pearl entity
*/ */
public interface EnderPearl extends Projectile { public interface EnderPearl extends Projectile {

View file

@ -18,7 +18,7 @@ public enum EntityType {
ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14), ENDER_PEARL("ThrownEnderpearl", EnderPearl.class, 14),
ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15), ENDER_SIGNAL("EyeOfEnderSignal", EnderSignal.class, 15),
PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20), PRIMED_TNT("PrimedTnt", TNTPrimed.class, 20),
FALLING_BLOCK("FallingBlock", FallingSand.class, 21, false), FALLING_BLOCK("FallingSand", FallingSand.class, 21, false),
MINECART("Minecart", Minecart.class, 40), MINECART("Minecart", Minecart.class, 40),
BOAT("Boat", Boat.class, 41), BOAT("Boat", Boat.class, 41),
CREEPER("Creeper", Creeper.class, 50), CREEPER("Creeper", Creeper.class, 50),

View file

@ -1,6 +1,6 @@
package org.bukkit.entity; package org.bukkit.entity;
/** /**
* Represents Falling Sand. * Represents a falling block.
*/ */
public interface FallingSand extends Entity {} public interface FallingSand extends Entity {}

View file

@ -1,6 +1,6 @@
package org.bukkit.entity; package org.bukkit.entity;
/** /**
* Represents a Fish. * Represents a fishing hook.
*/ */
public interface Fish extends Projectile {} public interface Fish extends Projectile {}

View file

@ -2,6 +2,7 @@ package org.bukkit.entity;
import org.bukkit.Art; import org.bukkit.Art;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.event.painting.PaintingBreakEvent;
import org.bukkit.material.Attachable; import org.bukkit.material.Attachable;
/** /**
@ -29,7 +30,7 @@ public interface Painting extends Entity, Attachable {
* @param art The new art * @param art The new art
* @param force If true, force the new art regardless of whether it fits at the current location * @param force If true, force the new art regardless of whether it fits at the current location
* Note that forcing it where it can't fit normally causes it to drop as an item unless you override * Note that forcing it where it can't fit normally causes it to drop as an item unless you override
* this by catching the PAINTING_BREAK event. * this by catching the {@link PaintingBreakEvent}.
* @return False if force was false and the new art won't fit at the painting's current location * @return False if force was false and the new art won't fit at the painting's current location
*/ */
public boolean setArt(Art art, boolean force); public boolean setArt(Art art, boolean force);

View file

@ -6,13 +6,11 @@ package org.bukkit.entity;
public interface Slime extends LivingEntity { public interface Slime extends LivingEntity {
/** /**
* @author Celtic Minstrel
* @return The size of the slime * @return The size of the slime
*/ */
public int getSize(); public int getSize();
/** /**
* @author Celtic Minstrel
* @param sz The new size of the slime. * @param sz The new size of the slime.
*/ */
public void setSize(int sz); public void setSize(int sz);

View file

@ -1,6 +1,6 @@
package org.bukkit.entity; package org.bukkit.entity;
/** /**
* Implements a snowball. * Represents a snowball.
*/ */
public interface Snowball extends Projectile {} public interface Snowball extends Projectile {}