From c5408f103061d3bd136aacbb80903180698efbfa Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sun, 12 Jun 2011 01:18:17 +0200 Subject: [PATCH] Generic cleanup By: Erik Broes --- .../src/main/java/org/bukkit/Location.java | 16 ++-- paper-api/src/main/java/org/bukkit/World.java | 28 +++--- .../org/bukkit/command/SimpleCommandMap.java | 2 +- .../main/java/org/bukkit/entity/Player.java | 12 +-- .../event/entity/EntityPortalEnterEvent.java | 54 ++++++------ .../event/player/PlayerPortalEvent.java | 47 +++++----- .../bukkit/event/world/PortalCreateEvent.java | 88 ++++++++++--------- .../org/bukkit/material/MaterialData.java | 5 +- .../org/bukkit/util/config/Configuration.java | 24 ++--- 9 files changed, 142 insertions(+), 134 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/Location.java b/paper-api/src/main/java/org/bukkit/Location.java index 6fc298006a..9b9f475f53 100644 --- a/paper-api/src/main/java/org/bukkit/Location.java +++ b/paper-api/src/main/java/org/bukkit/Location.java @@ -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); } diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index 149913f7a8..eb0315cb37 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -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 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 */ diff --git a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java index 3d868f79f6..589d962c36 100644 --- a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -137,7 +137,7 @@ public final class SimpleCommandMap implements CommandMap { } public synchronized void clearCommands() { - for (Map.Entry entry : knownCommands.entrySet()) { + for (Map.Entry entry : knownCommands.entrySet()) { entry.getValue().unregister(this); } knownCommands.clear(); diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index d4dd0884ea..2346aa0344 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -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 diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index 74caf0f7c7..f0c0193650 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -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; - } -} \ No newline at end of file +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; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index 9943cebe91..23b966adf0 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -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; + } +} diff --git a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index 9f75f4c26c..3e0314f16f 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -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 blocks = new ArrayList(); - - public PortalCreateEvent(final ArrayList blocks, final World world) { - super(Type.PORTAL_CREATE, world); - this.blocks = blocks; - } - - public ArrayList 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; - } -} \ No newline at end of file +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 blocks = new ArrayList(); + + public PortalCreateEvent(final ArrayList blocks, final World world) { + super(Type.PORTAL_CREATE, world); + this.blocks = blocks; + } + + public ArrayList 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; + } +} diff --git a/paper-api/src/main/java/org/bukkit/material/MaterialData.java b/paper-api/src/main/java/org/bukkit/material/MaterialData.java index 0f31244792..7143228796 100644 --- a/paper-api/src/main/java/org/bukkit/material/MaterialData.java +++ b/paper-api/src/main/java/org/bukkit/material/MaterialData.java @@ -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; diff --git a/paper-api/src/main/java/org/bukkit/util/config/Configuration.java b/paper-api/src/main/java/org/bukkit/util/config/Configuration.java index 95f962206b..81226c3f7c 100644 --- a/paper-api/src/main/java/org/bukkit/util/config/Configuration.java +++ b/paper-api/src/main/java/org/bukkit/util/config/Configuration.java @@ -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 -} \ No newline at end of file +}