Skip to content

Commit

Permalink
Add cancel based methods to event base interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphfrk committed Sep 10, 2014
1 parent 40c0778 commit 3668cdb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Expand Up @@ -9,11 +9,11 @@
public class ExamplePlugin {
@SpongeEventHandler
public void onInitialization(InitializationEvent event) {
event.game.getLogger().info("Hey folks, this is INITIALIZATION!");
event.getGame().getLogger().info("Hey folks, this is INITIALIZATION!");
}

@SpongeEventHandler
public void onServerStarting(ServerStartingEvent event) {
event.game.getLogger().info("Hey...my implementation's server is starting?");
event.getGame().getLogger().info("Hey...my implementation's server is starting?");
}
}
37 changes: 37 additions & 0 deletions src/main/java/org/spongepowered/api/event/Event.java
Expand Up @@ -40,5 +40,42 @@ public interface Event {
* @return String name
*/
String getSimpleName();

/**
* Gets if the {@link Event} can be cancelled
*
* @return
*/
boolean isCancellable();

/**
* Gets if the {@link Event} has been cancelled
*
* @return
*/
boolean isCancelled();

/**
* Sets the cancelled state of the {@link Event}
*
* @param cancel the new cancelled state
* @return
*/
void setCancelled(boolean cancel);

/**
* Sets the {@link Result} of the {@link Event}
*
* @param result the result
* @return
*/
void setResult(Result result);

/**
* Gets the {@link Result} of the {@link Event}
*
* @return
*/
Result getResult();

}

5 comments on commit 3668cdb

@DarkArc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we putting cancel implementation in all events? A cancelable interface makes more sense.

@Kiskae
Copy link
Contributor

@Kiskae Kiskae commented on 3668cdb Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkArc I don't think this was ever submitted as a pull request. It seems to have been pushed directly to master

@Zidane
Copy link
Member

@Zidane Zidane commented on 3668cdb Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkArc

I agree, I'll put it in its own interface when I get home.

@Zidane
Copy link
Member

@Zidane Zidane commented on 3668cdb Sep 10, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result should stay in Event though...

@ninja-
Copy link

@ninja- ninja- commented on 3668cdb Sep 12, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DarkArc it is because of @Cancellable annotation which is actually pretty cool.

Please sign in to comment.