Skip to content

Commit

Permalink
Generic cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
grum committed Jun 12, 2011
1 parent 9ca2688 commit c54ec09
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 134 deletions.
16 changes: 8 additions & 8 deletions src/main/java/org/bukkit/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public Vector getDirection() {

return vector;
}

/**
* Adds the location by another.
*
Expand All @@ -225,13 +225,13 @@ public Location add(Location vec) {
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.
*
Expand Down Expand Up @@ -260,7 +260,7 @@ public Location subtract(Location vec) {
if (vec == null || vec.getWorld() != getWorld()) {
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
}

x -= vec.x;
y -= vec.y;
z -= vec.z;
Expand Down Expand Up @@ -318,31 +318,31 @@ public double lengthSquared() {
* which will be caused if the distance is too long.
*
* @see Vector
* @param o
* @param o
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distance(Location o) {
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));
}

/**
* Get the squared distance between this location and another.
*
* @see Vector
* @param o
* @param o
* @return the distance
* @throws IllegalArgumentException for differing worlds
*/
public double distanceSquared(Location o) {
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);
}

Expand Down
28 changes: 14 additions & 14 deletions src/main/java/org/bukkit/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -484,18 +484,18 @@ 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
*/
public boolean createExplosion(double x, double y, double z, float power);

/**
* 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
Expand Down Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bukkit/command/SimpleCommandMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public boolean dispatch(CommandSender sender, String commandLine) throws Command
}

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();
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/bukkit/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
54 changes: 28 additions & 26 deletions src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
47 changes: 25 additions & 22 deletions src/main/java/org/bukkit/event/player/PlayerPortalEvent.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
88 changes: 45 additions & 43 deletions src/main/java/org/bukkit/event/world/PortalCreateEvent.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
5 changes: 3 additions & 2 deletions src/main/java/org/bukkit/material/MaterialData.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public int hashCode() {

@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;
Expand Down
Loading

0 comments on commit c54ec09

Please sign in to comment.