Add Block, javadoc cleanup
Add ignoresCancelled to SpongeEventHandler Signed-off-by: Chris Sanders <zidane@outlook.com>
This commit is contained in:
1 parent
c34d11d05f
commit
6b20cce9f1
6 files changed
+99
-86
No files matched your search
@@ -25,24 +25,24 @@ package org.spongepowered.api.event;
|
||||
|
||||
public interface EventManager {
|
||||
/**
|
||||
* Registers an object to receive {@link org.spongepowered.api.event.SpongeEvent}s.
|
||||
* Registers an object to receive {@link SpongeEvent}s.
|
||||
*
|
||||
* @param obj The object
|
||||
*/
|
||||
public void register(Object obj);
|
||||
|
||||
/**
|
||||
* Un-registers an object from receiving {@link org.spongepowered.api.event.SpongeEvent}s.
|
||||
* Un-registers an object from receiving {@link SpongeEvent}s.
|
||||
*
|
||||
* @param obj The object
|
||||
*/
|
||||
public void unregister(Object obj);
|
||||
|
||||
/**
|
||||
* Fires an {@link org.spongepowered.api.event.SpongeEvent} to all objects that handle it.
|
||||
* Calls a {@link SpongeEvent} to all objects that handle it.
|
||||
*
|
||||
* @param event The event
|
||||
* @return True if canceled, false if not
|
||||
*/
|
||||
public boolean fire(SpongeEvent event);
|
||||
public boolean call(SpongeEvent event);
|
||||
}
|
||||
@@ -24,77 +24,31 @@
|
||||
package org.spongepowered.api.event;
|
||||
|
||||
/**
|
||||
* Order that a {@link org.spongepowered.api.event.SpongeEventHandler} may be registered at.
|
||||
* Order that a {@link SpongeEventHandler} may be registered at.<br>
|
||||
* <br>
|
||||
* Event handlers are called the order given in the following table.<br>
|
||||
* <br>
|
||||
* <table summary="Order Recommendations">
|
||||
* <tr><td>Order</td> <td>Read Only</td><td>Cancellation Allowed</td><td>Recommendation</td></tr>
|
||||
* <tr><td>PRE</td> <td>YES</td> <td>NO</td> <td>Initialisation and registration actions</td></tr>
|
||||
* <tr><td>AFTER_PRE</td> <td>YES</td> <td>NO</td> <td>Immediate responses to actions in PRE</td></tr>
|
||||
* <tr><td>FIRST</td> <td>YES</td> <td>YES</td> <td>Cancellation by protection plugins for informational purposes</td></tr>
|
||||
* <tr><td>EARLY</td> <td>NO</td> <td>YES</td> <td>Standard actions that should happen before other plugins react to the event</td></tr>
|
||||
* <tr><td>DEFAULT</td> <td>NO</td> <td>YES</td> <td>The default action order</td></tr>
|
||||
* <tr><td>LATE</td> <td>NO</td> <td>YES</td> <td>Standard actions that should happen after other plugins react to the event</td></tr>
|
||||
* <tr><td>LAST</td> <td>YES</td> <td>YES</td> <td>Final cancellation by protection plugins</td></tr>
|
||||
* <tr><td>BEFORE_POST</td> <td>YES</td> <td>YES</td> <td>Actions that need to respond to cancelled events before POST</td></tr>
|
||||
* <tr><td>POST</td> <td>YES</td> <td>YES</td> <td>Actions that need to react to the final and stable effects of event</td></tr>
|
||||
* </table>
|
||||
*/
|
||||
public enum Order {
|
||||
/**
|
||||
* Called before all other handlers. Should be used for high-priority event cancelling. Should not be used to make changes to any implementation core objects.
|
||||
*/
|
||||
PRE(0, false),
|
||||
/**
|
||||
* Called after "Pre". Should be used for high-priority event cancelling.
|
||||
*/
|
||||
FIRST(1, false),
|
||||
/**
|
||||
* Called after "First" handlers and before "Early" handlers.<br> Is called even when event has been cancelled.<br> Should generally be used to un-cancel events cancelled in First.<br>
|
||||
*/
|
||||
FIRST_IGNORE_CANCELLED(2, true),
|
||||
/**
|
||||
* Called after "First" handlers. Should generally be used for low priority event cancelling.
|
||||
*/
|
||||
EARLY(3, false),
|
||||
/**
|
||||
* Called after "Early" handlers and before "Default" handlers.<br> Called even when event has been cancelled.<br> This is for general-purpose always-run events.<br>
|
||||
*/
|
||||
EARLY_IGNORE_CANCELLED(4, true),
|
||||
/**
|
||||
* Default call, for general purpose handlers.
|
||||
*/
|
||||
DEFAULT(5, false),
|
||||
/**
|
||||
* Called after "Default" handlers and before "Late" handlers.<br> Called even when the event has been canceled.<br> This is for general-purpose always-run events.<br>
|
||||
*/
|
||||
DEFAULT_IGNORE_CANCELLED(6, true),
|
||||
/**
|
||||
* Called after "Default" handlers.
|
||||
*/
|
||||
LATE(7, false),
|
||||
/**
|
||||
* Called after "Late" handlers and before "Last" handlers.<br> Called even when the event has been cancelled.<br>
|
||||
*/
|
||||
LATE_IGNORE_CANCELLED(8, true),
|
||||
/**
|
||||
* Called after "Late" handlers.<br> No changes to the event should be made in this order slot (may be enforced by implementation).<br>
|
||||
*/
|
||||
LAST(9, false),
|
||||
/**
|
||||
* Called after "Last" handlers and before "Post" handlers.<br> No changes to the event should be made in this order slot (may be enforced by implementation).<br> This is called even when event has been cancelled.<br>
|
||||
*/
|
||||
LAST_IGNORE_CANCELLED(10, true),
|
||||
/**
|
||||
* Called after all other handlers. Should not be used to make changes to the event or any implementation core objects.
|
||||
*/
|
||||
POST(11, false);
|
||||
|
||||
private final int index;
|
||||
private final boolean ignoreCancelled;
|
||||
|
||||
Order(int index, boolean ignoreCancelled) {
|
||||
this.index = index;
|
||||
this.ignoreCancelled = ignoreCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the index
|
||||
*/
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether this Order ignores cancellation status
|
||||
*/
|
||||
public boolean ignoresCancelled() {
|
||||
return ignoreCancelled;
|
||||
}
|
||||
}
|
||||
PRE,
|
||||
AFTER_PRE,
|
||||
FIRST,
|
||||
EARLY,
|
||||
DEFAULT,
|
||||
LATE,
|
||||
LAST,
|
||||
BEFORE_POST,
|
||||
POST
|
||||
}
|
||||
@@ -33,4 +33,5 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
@Target(value = METHOD)
|
||||
public @interface SpongeEventHandler {
|
||||
public Order order() default Order.DEFAULT;
|
||||
public boolean ignoreCancelled() default false;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.world;
|
||||
|
||||
/**
|
||||
* Describes a voxel. Child classes define specific functionality.
|
||||
*/
|
||||
public interface Block {
|
||||
/**
|
||||
* Gets the id of this block.
|
||||
*
|
||||
* Ex. Minecraft registers stone as "minecraft:stone"
|
||||
* @return The id
|
||||
*/
|
||||
public String getID();
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public interface Chunk {
|
||||
* Gets the x chunk coordinate of this chunk as it appears in the
|
||||
* {@link World}.
|
||||
*
|
||||
* @return x coordinate
|
||||
* @return X chunk coordinate
|
||||
*/
|
||||
public int getX();
|
||||
|
||||
@@ -42,7 +42,18 @@ public interface Chunk {
|
||||
* Gets the z chunk coordinate of this chunk as it appears in the
|
||||
* {@link World}.
|
||||
*
|
||||
* @return z coordinate
|
||||
* @return Z chunk coordinate
|
||||
*/
|
||||
public int getZ();
|
||||
|
||||
/**
|
||||
* Gets the {@link org.spongepowered.api.world.Block} at the block coordinate x/y/z.
|
||||
*
|
||||
* @param x X block coordinate
|
||||
* @param y Y block coordinate
|
||||
* @param z Z block coordinate
|
||||
* @throws IllegalArgumentException If coordinates given are outside the chunk's bounds
|
||||
* @return The block
|
||||
*/
|
||||
public Block getBlock(int x, int y, int z);
|
||||
}
|
||||
@@ -31,24 +31,34 @@ import java.util.UUID;
|
||||
public interface World {
|
||||
|
||||
/**
|
||||
* Gets the unique id for this world
|
||||
* Gets the unique id ({@link java.util.UUID} for this world.
|
||||
*
|
||||
* @return a unique id
|
||||
* @return The unique id or UUID
|
||||
*/
|
||||
public UUID getUniqueID();
|
||||
|
||||
/**
|
||||
* Gets the name of the world
|
||||
* Gets the name of the world.
|
||||
*
|
||||
* @return the world name
|
||||
* @return The world name
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Gets a specific {@link Chunk} by the x/z chunk coordinates in the world.
|
||||
* @param x
|
||||
* @param z
|
||||
* @return a chunk
|
||||
* Gets a specific {@link Chunk} by its x/z chunk coordinate.
|
||||
*
|
||||
* @param x X chunk coordinate
|
||||
* @param z Z chunk coordinate
|
||||
* @return The chunk
|
||||
*/
|
||||
public Chunk getChunk(int x, int z);
|
||||
|
||||
/**
|
||||
* Gets a specific {@link org.spongepowered.api.world.Block} by its x/y/z block coordinate.
|
||||
* @param x X block coordinate
|
||||
* @param y Y block coordinate
|
||||
* @param z Z block coordinate
|
||||
* @return The block
|
||||
*/
|
||||
public Block getBlock(int x, int y, int z);
|
||||
}
|
||||
Reference in new issue
Block a user