Skip to content

Commit

Permalink
Cleanup/Enforce Game object on Event
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Sanders <[email protected]>
  • Loading branch information
Chris Sanders committed Sep 10, 2014
1 parent ef4fbb8 commit 5d50dc4
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/spongepowered/api/block/Block.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
public interface Block {
/**
* Gets the id of this block.
*
* <p/>
* Ex. Minecraft registers stone as "minecraft:stone"
*
* @return The id
*/
String getID();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/spongepowered/api/event/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,17 @@
*/
package org.spongepowered.api.event;

import org.spongepowered.api.Game;

public interface Event {

/**
* Gets the {@link org.spongepowered.api.Game}.
*
* @return The game
*/
Game getGame();

/**
* Gets a simple name of the current class
*
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/org/spongepowered/api/event/Order.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@
* 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>
* <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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
@Target(value = METHOD)
public @interface SpongeEventHandler {
Order order() default Order.DEFAULT;

boolean ignoreCancelled() default false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public interface BlockEvent extends Event {

/**
* Get {@link Block} included in the event
* TODO: use voxel instead to provide the location and block at once?
* TODO: use voxel instead to provide the location and block at once?
*
* @return Event {@link Block}
*/
Block getBlock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
*/
package org.spongepowered.api.event.state;

import org.spongepowered.api.Game;
import org.spongepowered.api.GameState;
import org.spongepowered.api.event.Event;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.world;

import org.spongepowered.api.Game;
import org.spongepowered.api.world.Chunk;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.spongepowered.api.event.world;

import org.spongepowered.api.Game;
import org.spongepowered.api.world.Chunk;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public interface WorldEvent {

/**
* Gets the {@link World} involved in the event
*
* @return
*/
World getWorld();
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/spongepowered/api/item/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
public interface Item {
/**
* Gets the id of this item.
*
* <p/>
* Ex. Minecraft registers a golden carrot as "minecraft:golden_carrot"
*
* @return The id
*/
String getID();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/spongepowered/api/item/ItemBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
public interface ItemBlock extends Item {
/**
* Gets the {@link org.spongepowered.api.block.Block} this item places on interaction
*
* @return The block
*/
Block getBlock();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/spongepowered/api/plugin/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
@Retention(RUNTIME)
public @interface Plugin {
String id();

String name();

String version() default "unknown";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,30 @@
public interface PluginContainer {
/**
* Gets the id of the {@link org.spongepowered.api.plugin.Plugin} within this container.
*
* @return The id
*/
String getID();

/**
* Gets the name of the {@link org.spongepowered.api.plugin.Plugin} within this container.
*
* @return The name
*/
String getName();

/**
* Gets the version of the {@link org.spongepowered.api.plugin.Plugin} within this container.
*
* @return The name
*/
String getVersion();

/**
* Returns the created instance of {@link org.spongepowered.api.plugin.Plugin}
*
* <p/>
* TODO Provide a way to not dereference this back to Object
*
* @return The instance
*/
Object getInstance();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/spongepowered/api/world/Chunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public interface Chunk {
* @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
* @throws IllegalArgumentException If coordinates given are outside the chunk's bounds
*/
Block getBlock(int x, int y, int z);

Expand All @@ -65,8 +65,8 @@ public interface Chunk {
* @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 voxel
* @throws IllegalArgumentException If coordinates given are outside the chunk's bounds
*/
Voxel getVoxel(int x, int y, int z);
}
6 changes: 4 additions & 2 deletions src/main/java/org/spongepowered/api/world/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,16 @@ public interface World {
* Loads and returns a {@link Chunk}. If the chunk does not
* exist, it will be generated unless `shouldGenerate` is false.
*
* @param cx X chunk coordinate
* @param cz Z chunk coordinate
* @param cx X chunk coordinate
* @param cz Z chunk coordinate
* @param shouldGenerate Generate if new
* @return Chunk loaded/generated
*/
Chunk loadChunk(int cx, int cz, boolean shouldGenerate);

/**
* Gets a specific {@link org.spongepowered.api.block.Block} by its x/y/z block coordinate.
*
* @param x X block coordinate
* @param y Y block coordinate
* @param z Z block coordinate
Expand All @@ -78,6 +79,7 @@ public interface World {

/**
* Gets a specific {@link org.spongepowered.api.world.Voxel} by its x/y/z block coordinate.
*
* @param x X block coordinate
* @param y Y block coordinate
* @param z Z block coordinate
Expand Down

0 comments on commit 5d50dc4

Please sign in to comment.