Generic cleanup

By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
Bukkit/Spigot 2011-06-12 01:18:17 +02:00
parent da51cfa4b1
commit c5408f1030
9 changed files with 142 additions and 134 deletions

View file

@ -212,7 +212,7 @@ public class Location implements Cloneable {
return vector;
}
/**
* Adds the location by another.
*
@ -225,13 +225,13 @@ public class Location implements Cloneable {
if (vec == null || vec.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
}
x += vec.x;
y += vec.y;
z += vec.z;
return this;
}
/**
* Adds the location by another. Not world-aware.
*
@ -260,7 +260,7 @@ public class Location implements Cloneable {
if (vec == null || vec.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
}
x -= vec.x;
y -= vec.y;
z -= vec.z;
@ -318,7 +318,7 @@ public class Location implements Cloneable {
* which will be caused if the distance is too long.
*
* @see Vector
* @param o
* @param o
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
@ -326,7 +326,7 @@ public class Location implements Cloneable {
if (o == null || o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
}
return Math.sqrt(Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2));
}
@ -334,7 +334,7 @@ public class Location implements Cloneable {
* Get the squared distance between this location and another.
*
* @see Vector
* @param o
* @param o
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
@ -342,7 +342,7 @@ public class Location implements Cloneable {
if (o == null || o.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
}
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2);
}

View file

@ -374,10 +374,10 @@ public interface World {
/**
* Sets the spawn location of the world
*
* @param x
* @param y
* @param z
*
* @param x
* @param y
* @param z
* @return True if it was successfully set.
*/
public boolean setSpawnLocation(int x, int y, int z);
@ -484,10 +484,10 @@ public interface World {
/**
* Creates explosion at given coordinates with given power
*
* @param x
* @param y
* @param z
*
* @param x
* @param y
* @param z
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
*/
@ -495,7 +495,7 @@ public interface World {
/**
* Creates explosion at given coordinates with given power
*
*
* @param loc
* @param power The power of explosion, where 4F is TNT
* @return false if explosion was canceled, otherwise true
@ -546,26 +546,26 @@ public interface World {
* @return List containing any or none BlockPopulators
*/
public List<BlockPopulator> getPopulators();
/**
* Plays an effect to all players within a default radius around a given location.
*
*
* @param location the {@link Location} around which players must be to hear the sound
* @param effect the {@link Effect}
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
*/
public void playEffect(Location location, Effect effect, int data);
/**
* Plays an effect to all players within a given radius around a location.
*
*
* @param location the {@link Location} around which players must be to hear the effect
* @param effect the {@link Effect}
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP effects
* @param radius the radius around the location
*/
public void playEffect(Location location, Effect effect, int data, int radius);
/**
* Represents various map environment types that a world may be
*/

View file

@ -137,7 +137,7 @@ public final class SimpleCommandMap implements CommandMap {
}
public synchronized void clearCommands() {
for (Map.Entry<String,Command> entry : knownCommands.entrySet()) {
for (Map.Entry<String, Command> entry : knownCommands.entrySet()) {
entry.getValue().unregister(this);
}
knownCommands.clear();

View file

@ -26,7 +26,7 @@ public interface Player extends HumanEntity, CommandSender {
*
* Note that this name will not be displayed in game, only in chat and places
* defined by plugins
*
*
* @return the friendly name
*/
public String getDisplayName();
@ -36,8 +36,8 @@ public interface Player extends HumanEntity, CommandSender {
*
* Note that this name will not be displayed in game, only in chat and places
* defined by plugins
*
* @param name
*
* @param name
*/
public void setDisplayName(String name);
@ -70,7 +70,7 @@ public interface Player extends HumanEntity, CommandSender {
/**
* Kicks player with custom kick message.
*
*
* @param message kick message
*/
public void kickPlayer(String message);
@ -141,10 +141,10 @@ public interface Player extends HumanEntity, CommandSender {
* @param note
*/
public void playNote(Location loc, byte instrument, byte note);
/**
* Plays an effect to just this player.
*
*
* @param loc the player to play the effect for
* @param effect the {@link Effect}
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds

View file

@ -1,26 +1,28 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
/**
* Stores data for entities standing inside a portal block
*/
public class EntityPortalEnterEvent extends EntityEvent {
private Location location;
public EntityPortalEnterEvent(Entity entity, Location location) {
super(Type.ENTITY_PORTAL_ENTER, entity);
this.location = location;
}
/*
* Gets the portal block the entity is touching
* @return The portal block the entity is touching
*/
public Location getLocation() {
return location;
}
}
package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
/**
* Stores data for entities standing inside a portal block
*/
public class EntityPortalEnterEvent extends EntityEvent {
private Location location;
public EntityPortalEnterEvent(Entity entity, Location location) {
super(Type.ENTITY_PORTAL_ENTER, entity);
this.location = location;
}
/*
* Gets the portal block the entity is touching
* @return The portal block the entity is touching
*/
public Location getLocation() {
return location;
}
}

View file

@ -1,22 +1,25 @@
package org.bukkit.event.player;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.block.Block;
/**
* Called when a player completes the portaling process by standing in a portal
*/
public class PlayerPortalEvent extends PlayerTeleportEvent {
private boolean useTravelAgent = true;
public PlayerPortalEvent(Player player, Location from, Location to) {
super(Type.PLAYER_PORTAL, player, from, to);
}
public void useTravelAgent(boolean useTravelAgent){
this.useTravelAgent = useTravelAgent;
}
public boolean useTravelAgent(){
return useTravelAgent;
}
}
package org.bukkit.event.player;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.block.Block;
/**
* Called when a player completes the portaling process by standing in a portal
*/
public class PlayerPortalEvent extends PlayerTeleportEvent {
private boolean useTravelAgent = true;
public PlayerPortalEvent(Player player, Location from, Location to) {
super(Type.PLAYER_PORTAL, player, from, to);
}
public void useTravelAgent(boolean useTravelAgent) {
this.useTravelAgent = useTravelAgent;
}
public boolean useTravelAgent() {
return useTravelAgent;
}
}

View file

@ -1,43 +1,45 @@
package org.bukkit.event.world;
import org.bukkit.block.Block;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import java.util.ArrayList;
/**
* Called when the world attempts to create a matching end to a portal
*/
public class PortalCreateEvent extends WorldEvent implements Cancellable {
private boolean cancel = false;
private ArrayList<Block> blocks = new ArrayList<Block>();
public PortalCreateEvent(final ArrayList<Block> blocks, final World world) {
super(Type.PORTAL_CREATE, world);
this.blocks = blocks;
}
public ArrayList<Block> getBlocks(){
return this.blocks;
}
/**
* Gets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is canceled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}
package org.bukkit.event.world;
import org.bukkit.block.Block;
import org.bukkit.World;
import org.bukkit.event.Cancellable;
import java.util.ArrayList;
/**
* Called when the world attempts to create a matching end to a portal
*/
public class PortalCreateEvent extends WorldEvent implements Cancellable {
private boolean cancel = false;
private ArrayList<Block> blocks = new ArrayList<Block>();
public PortalCreateEvent(final ArrayList<Block> blocks, final World world) {
super(Type.PORTAL_CREATE, world);
this.blocks = blocks;
}
public ArrayList<Block> getBlocks() {
return this.blocks;
}
/**
* Gets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @return true if this event is canceled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Sets the cancellation state of this event. A canceled event will not
* be executed in the server, but will still pass to other plugins
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}

View file

@ -93,8 +93,9 @@ public class MaterialData {
@Override
public boolean equals(Object obj) {
if(obj != null && obj instanceof MaterialData) {
MaterialData md = (MaterialData)obj;
if (obj != null && obj instanceof MaterialData) {
MaterialData md = (MaterialData) obj;
return (md.getItemTypeId() == getItemTypeId() && md.getData() == getData());
} else {
return false;

View file

@ -96,37 +96,37 @@ public class Configuration extends ConfigurationNode {
/**
* Set the header for the file as a series of lines that are terminated
* by a new line sequence.
*
*
* @param headerLines header lines to prepend
*/
public void setHeader(String ... headerLines) {
public void setHeader(String... headerLines) {
StringBuilder header = new StringBuilder();
for (String line : headerLines) {
if (header.length() > 0) {
header.append("\r\n");
}
header.append(line);
}
setHeader(header.toString());
}
/**
* Set the header for the file. A header can be provided to prepend the
* YAML data output on configuration save. The header is
* YAML data output on configuration save. The header is
* printed raw and so must be manually commented if used. A new line will
* be appended after the header, however, if a header is provided.
*
*
* @param header header to prepend
*/
public void setHeader(String header) {
this.header = header;
}
/**
* Return the set header.
*
*
* @return
*/
public String getHeader() {
@ -134,8 +134,8 @@ public class Configuration extends ConfigurationNode {
}
/**
* Saves the configuration to disk. All errors are clobbered.
*
* Saves the configuration to disk. All errors are clobbered.
*
* @param header header to prepend
* @return true if it was successful
*/
@ -227,4 +227,4 @@ class EmptyNullRepresenter extends Representer {
return tuple;
}
// End of borrowed code
}
}