mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Generic cleanup
By: Erik Broes <erikbroes@grum.nl>
This commit is contained in:
parent
da51cfa4b1
commit
c5408f1030
9 changed files with 142 additions and 134 deletions
|
@ -212,7 +212,7 @@ public class Location implements Cloneable {
|
||||||
|
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the location by another.
|
* Adds the location by another.
|
||||||
*
|
*
|
||||||
|
@ -225,13 +225,13 @@ public class Location implements Cloneable {
|
||||||
if (vec == null || vec.getWorld() != getWorld()) {
|
if (vec == null || vec.getWorld() != getWorld()) {
|
||||||
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
|
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
|
||||||
}
|
}
|
||||||
|
|
||||||
x += vec.x;
|
x += vec.x;
|
||||||
y += vec.y;
|
y += vec.y;
|
||||||
z += vec.z;
|
z += vec.z;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the location by another. Not world-aware.
|
* Adds the location by another. Not world-aware.
|
||||||
*
|
*
|
||||||
|
@ -260,7 +260,7 @@ public class Location implements Cloneable {
|
||||||
if (vec == null || vec.getWorld() != getWorld()) {
|
if (vec == null || vec.getWorld() != getWorld()) {
|
||||||
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
|
throw new IllegalArgumentException("Cannot add Locations of differing worlds");
|
||||||
}
|
}
|
||||||
|
|
||||||
x -= vec.x;
|
x -= vec.x;
|
||||||
y -= vec.y;
|
y -= vec.y;
|
||||||
z -= vec.z;
|
z -= vec.z;
|
||||||
|
@ -318,7 +318,7 @@ public class Location implements Cloneable {
|
||||||
* which will be caused if the distance is too long.
|
* which will be caused if the distance is too long.
|
||||||
*
|
*
|
||||||
* @see Vector
|
* @see Vector
|
||||||
* @param o
|
* @param o
|
||||||
* @return the distance
|
* @return the distance
|
||||||
* @throws IllegalArgumentException for differing worlds
|
* @throws IllegalArgumentException for differing worlds
|
||||||
*/
|
*/
|
||||||
|
@ -326,7 +326,7 @@ public class Location implements Cloneable {
|
||||||
if (o == null || o.getWorld() != getWorld()) {
|
if (o == null || o.getWorld() != getWorld()) {
|
||||||
throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
|
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));
|
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.
|
* Get the squared distance between this location and another.
|
||||||
*
|
*
|
||||||
* @see Vector
|
* @see Vector
|
||||||
* @param o
|
* @param o
|
||||||
* @return the distance
|
* @return the distance
|
||||||
* @throws IllegalArgumentException for differing worlds
|
* @throws IllegalArgumentException for differing worlds
|
||||||
*/
|
*/
|
||||||
|
@ -342,7 +342,7 @@ public class Location implements Cloneable {
|
||||||
if (o == null || o.getWorld() != getWorld()) {
|
if (o == null || o.getWorld() != getWorld()) {
|
||||||
throw new IllegalArgumentException("Cannot measure distance between worlds or to null");
|
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);
|
return Math.pow(x - o.x, 2) + Math.pow(y - o.y, 2) + Math.pow(z - o.z, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,10 +374,10 @@ public interface World {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the spawn location of the world
|
* Sets the spawn location of the world
|
||||||
*
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param z
|
* @param z
|
||||||
* @return True if it was successfully set.
|
* @return True if it was successfully set.
|
||||||
*/
|
*/
|
||||||
public boolean setSpawnLocation(int x, int y, int z);
|
public boolean setSpawnLocation(int x, int y, int z);
|
||||||
|
@ -484,10 +484,10 @@ public interface World {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates explosion at given coordinates with given power
|
* Creates explosion at given coordinates with given power
|
||||||
*
|
*
|
||||||
* @param x
|
* @param x
|
||||||
* @param y
|
* @param y
|
||||||
* @param z
|
* @param z
|
||||||
* @param power The power of explosion, where 4F is TNT
|
* @param power The power of explosion, where 4F is TNT
|
||||||
* @return false if explosion was canceled, otherwise true
|
* @return false if explosion was canceled, otherwise true
|
||||||
*/
|
*/
|
||||||
|
@ -495,7 +495,7 @@ public interface World {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates explosion at given coordinates with given power
|
* Creates explosion at given coordinates with given power
|
||||||
*
|
*
|
||||||
* @param loc
|
* @param loc
|
||||||
* @param power The power of explosion, where 4F is TNT
|
* @param power The power of explosion, where 4F is TNT
|
||||||
* @return false if explosion was canceled, otherwise true
|
* @return false if explosion was canceled, otherwise true
|
||||||
|
@ -546,26 +546,26 @@ public interface World {
|
||||||
* @return List containing any or none BlockPopulators
|
* @return List containing any or none BlockPopulators
|
||||||
*/
|
*/
|
||||||
public List<BlockPopulator> getPopulators();
|
public List<BlockPopulator> getPopulators();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays an effect to all players within a default radius around a given location.
|
* 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 location the {@link Location} around which players must be to hear the sound
|
||||||
* @param effect the {@link Effect}
|
* @param effect the {@link Effect}
|
||||||
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
|
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
|
||||||
*/
|
*/
|
||||||
public void playEffect(Location location, Effect effect, int data);
|
public void playEffect(Location location, Effect effect, int data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays an effect to all players within a given radius around a location.
|
* 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 location the {@link Location} around which players must be to hear the effect
|
||||||
* @param effect the {@link Effect}
|
* @param effect the {@link Effect}
|
||||||
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP effects
|
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP effects
|
||||||
* @param radius the radius around the location
|
* @param radius the radius around the location
|
||||||
*/
|
*/
|
||||||
public void playEffect(Location location, Effect effect, int data, int radius);
|
public void playEffect(Location location, Effect effect, int data, int radius);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents various map environment types that a world may be
|
* Represents various map environment types that a world may be
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,7 +137,7 @@ public final class SimpleCommandMap implements CommandMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void clearCommands() {
|
public synchronized void clearCommands() {
|
||||||
for (Map.Entry<String,Command> entry : knownCommands.entrySet()) {
|
for (Map.Entry<String, Command> entry : knownCommands.entrySet()) {
|
||||||
entry.getValue().unregister(this);
|
entry.getValue().unregister(this);
|
||||||
}
|
}
|
||||||
knownCommands.clear();
|
knownCommands.clear();
|
||||||
|
|
|
@ -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
|
* Note that this name will not be displayed in game, only in chat and places
|
||||||
* defined by plugins
|
* defined by plugins
|
||||||
*
|
*
|
||||||
* @return the friendly name
|
* @return the friendly name
|
||||||
*/
|
*/
|
||||||
public String getDisplayName();
|
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
|
* Note that this name will not be displayed in game, only in chat and places
|
||||||
* defined by plugins
|
* defined by plugins
|
||||||
*
|
*
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public void setDisplayName(String name);
|
public void setDisplayName(String name);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public interface Player extends HumanEntity, CommandSender {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kicks player with custom kick message.
|
* Kicks player with custom kick message.
|
||||||
*
|
*
|
||||||
* @param message kick message
|
* @param message kick message
|
||||||
*/
|
*/
|
||||||
public void kickPlayer(String message);
|
public void kickPlayer(String message);
|
||||||
|
@ -141,10 +141,10 @@ public interface Player extends HumanEntity, CommandSender {
|
||||||
* @param note
|
* @param note
|
||||||
*/
|
*/
|
||||||
public void playNote(Location loc, byte instrument, byte note);
|
public void playNote(Location loc, byte instrument, byte note);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plays an effect to just this player.
|
* Plays an effect to just this player.
|
||||||
*
|
*
|
||||||
* @param loc the player to play the effect for
|
* @param loc the player to play the effect for
|
||||||
* @param effect the {@link Effect}
|
* @param effect the {@link Effect}
|
||||||
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
|
* @param data a data bit needed for the RECORD_PLAY, SMOKE, and STEP_SOUND sounds
|
||||||
|
|
|
@ -1,26 +1,28 @@
|
||||||
package org.bukkit.event.entity;
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
/**
|
|
||||||
* Stores data for entities standing inside a portal block
|
|
||||||
*/
|
/**
|
||||||
public class EntityPortalEnterEvent extends EntityEvent {
|
* Stores data for entities standing inside a portal block
|
||||||
|
*/
|
||||||
private Location location;
|
public class EntityPortalEnterEvent extends EntityEvent {
|
||||||
|
|
||||||
public EntityPortalEnterEvent(Entity entity, Location location) {
|
private Location location;
|
||||||
super(Type.ENTITY_PORTAL_ENTER, entity);
|
|
||||||
this.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
|
/*
|
||||||
*/
|
* Gets the portal block the entity is touching
|
||||||
public Location getLocation() {
|
* @return The portal block the entity is touching
|
||||||
return location;
|
*/
|
||||||
}
|
public Location getLocation() {
|
||||||
}
|
return location;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
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 {
|
* Called when a player completes the portaling process by standing in a portal
|
||||||
private boolean useTravelAgent = true;
|
*/
|
||||||
public PlayerPortalEvent(Player player, Location from, Location to) {
|
public class PlayerPortalEvent extends PlayerTeleportEvent {
|
||||||
super(Type.PLAYER_PORTAL, player, from, to);
|
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 void useTravelAgent(boolean useTravelAgent) {
|
||||||
public boolean useTravelAgent(){
|
this.useTravelAgent = useTravelAgent;
|
||||||
return useTravelAgent;
|
}
|
||||||
}
|
|
||||||
}
|
public boolean useTravelAgent() {
|
||||||
|
return useTravelAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,43 +1,45 @@
|
||||||
package org.bukkit.event.world;
|
package org.bukkit.event.world;
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.World;
|
||||||
import java.util.ArrayList;
|
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 {
|
* Called when the world attempts to create a matching end to a portal
|
||||||
private boolean cancel = false;
|
*/
|
||||||
private ArrayList<Block> blocks = new ArrayList<Block>();
|
public class PortalCreateEvent extends WorldEvent implements Cancellable {
|
||||||
|
private boolean cancel = false;
|
||||||
public PortalCreateEvent(final ArrayList<Block> blocks, final World world) {
|
private ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
super(Type.PORTAL_CREATE, world);
|
|
||||||
this.blocks = blocks;
|
public PortalCreateEvent(final ArrayList<Block> blocks, final World world) {
|
||||||
}
|
super(Type.PORTAL_CREATE, world);
|
||||||
|
this.blocks = blocks;
|
||||||
public ArrayList<Block> getBlocks(){
|
}
|
||||||
return this.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
|
/**
|
||||||
*
|
* Gets the cancellation state of this event. A canceled event will not
|
||||||
* @return true if this event is canceled
|
* be executed in the server, but will still pass to other plugins
|
||||||
*/
|
*
|
||||||
public boolean isCancelled() {
|
* @return true if this event is canceled
|
||||||
return cancel;
|
*/
|
||||||
}
|
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
|
/**
|
||||||
*
|
* Sets the cancellation state of this event. A canceled event will not
|
||||||
* @param cancel true if you wish to cancel this event
|
* be executed in the server, but will still pass to other plugins
|
||||||
*/
|
*
|
||||||
public void setCancelled(boolean cancel) {
|
* @param cancel true if you wish to cancel this event
|
||||||
this.cancel = cancel;
|
*/
|
||||||
}
|
public void setCancelled(boolean cancel) {
|
||||||
}
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -93,8 +93,9 @@ public class MaterialData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj != null && obj instanceof MaterialData) {
|
if (obj != null && obj instanceof MaterialData) {
|
||||||
MaterialData md = (MaterialData)obj;
|
MaterialData md = (MaterialData) obj;
|
||||||
|
|
||||||
return (md.getItemTypeId() == getItemTypeId() && md.getData() == getData());
|
return (md.getItemTypeId() == getItemTypeId() && md.getData() == getData());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -96,37 +96,37 @@ public class Configuration extends ConfigurationNode {
|
||||||
/**
|
/**
|
||||||
* Set the header for the file as a series of lines that are terminated
|
* Set the header for the file as a series of lines that are terminated
|
||||||
* by a new line sequence.
|
* by a new line sequence.
|
||||||
*
|
*
|
||||||
* @param headerLines header lines to prepend
|
* @param headerLines header lines to prepend
|
||||||
*/
|
*/
|
||||||
public void setHeader(String ... headerLines) {
|
public void setHeader(String... headerLines) {
|
||||||
StringBuilder header = new StringBuilder();
|
StringBuilder header = new StringBuilder();
|
||||||
|
|
||||||
for (String line : headerLines) {
|
for (String line : headerLines) {
|
||||||
if (header.length() > 0) {
|
if (header.length() > 0) {
|
||||||
header.append("\r\n");
|
header.append("\r\n");
|
||||||
}
|
}
|
||||||
header.append(line);
|
header.append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
setHeader(header.toString());
|
setHeader(header.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the header for the file. A header can be provided to prepend the
|
* 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
|
* 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.
|
* be appended after the header, however, if a header is provided.
|
||||||
*
|
*
|
||||||
* @param header header to prepend
|
* @param header header to prepend
|
||||||
*/
|
*/
|
||||||
public void setHeader(String header) {
|
public void setHeader(String header) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the set header.
|
* Return the set header.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getHeader() {
|
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
|
* @param header header to prepend
|
||||||
* @return true if it was successful
|
* @return true if it was successful
|
||||||
*/
|
*/
|
||||||
|
@ -227,4 +227,4 @@ class EmptyNullRepresenter extends Representer {
|
||||||
return tuple;
|
return tuple;
|
||||||
}
|
}
|
||||||
// End of borrowed code
|
// End of borrowed code
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue