Brings getPlayer() and getWorld() to events
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package io.akarin.server.api.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Represents event with a player attached
|
||||
*/
|
||||
public interface PlayerAttachedEvent {
|
||||
public Player getPlayer();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package io.akarin.server.api.event;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Represents event with a world attached
|
||||
*/
|
||||
public interface WorldAttachedEvent {
|
||||
public World getWorld();
|
||||
}
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a block related event.
|
||||
*/
|
||||
public abstract class BlockEvent extends Event {
|
||||
public abstract class BlockEvent extends Event implements WorldAttachedEvent {
|
||||
protected Block block;
|
||||
@Override @NotNull public World getWorld() { return block.getWorld(); } // Akarin
|
||||
|
||||
public BlockEvent(@NotNull final Block theBlock) {
|
||||
block = theBlock;
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents an Entity-related event
|
||||
*/
|
||||
public abstract class EntityEvent extends Event {
|
||||
public abstract class EntityEvent extends Event implements WorldAttachedEvent { // Akarin
|
||||
protected Entity entity;
|
||||
@Override @NotNull public World getWorld() { return entity.getWorld(); } // Akarin
|
||||
|
||||
public EntityEvent(@NotNull final Entity what) {
|
||||
entity = what;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.bukkit.event.hanging;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a hanging entity-related event.
|
||||
*/
|
||||
public abstract class HangingEvent extends Event {
|
||||
public abstract class HangingEvent extends Event implements WorldAttachedEvent { // Akarin
|
||||
protected Hanging hanging;
|
||||
@Override @NotNull public World getWorld() { return hanging.getWorld(); } // Akarin
|
||||
|
||||
protected HangingEvent(@NotNull final Hanging painting) {
|
||||
this.hanging = painting;
|
||||
|
||||
@@ -73,7 +73,7 @@ public class InventoryCloseEvent extends InventoryEvent {
|
||||
* @return Player who is involved in this event
|
||||
*/
|
||||
@NotNull
|
||||
public final HumanEntity getPlayer() {
|
||||
public final HumanEntity getWhoClicked() { // Akarin
|
||||
return transaction.getPlayer();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,33 @@ package org.bukkit.event.inventory;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.PlayerAttachedEvent;
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a player related inventory event
|
||||
*/
|
||||
public class InventoryEvent extends Event {
|
||||
public class InventoryEvent extends Event implements PlayerAttachedEvent, WorldAttachedEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
protected InventoryView transaction;
|
||||
// Akarin start
|
||||
@NotNull
|
||||
@Override
|
||||
public Player getPlayer() { return (Player) transaction.getPlayer(); } // Akarin
|
||||
@NotNull
|
||||
@Override
|
||||
public World getWorld() { return transaction.getPlayer().getWorld(); } // Akarin
|
||||
@NotNull
|
||||
public HumanEntity getWhoClicked() { return transaction.getPlayer(); } // Akarin
|
||||
// Akarin end
|
||||
|
||||
public InventoryEvent(@NotNull InventoryView transaction) {
|
||||
this.transaction = transaction;
|
||||
|
||||
@@ -24,7 +24,7 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable {
|
||||
* @return Player who is involved in this event
|
||||
*/
|
||||
@NotNull
|
||||
public final HumanEntity getPlayer() {
|
||||
public final HumanEntity getWhoClicked() { // Akarin
|
||||
return transaction.getPlayer();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.bukkit.event.player;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a player related event
|
||||
*/
|
||||
public abstract class PlayerEvent extends Event {
|
||||
public abstract class PlayerEvent extends Event implements WorldAttachedEvent { // Akarin
|
||||
protected Player player;
|
||||
@Override @NotNull public World getWorld() { return player.getWorld(); } // Akarin
|
||||
|
||||
public PlayerEvent(@NotNull final Player who) {
|
||||
player = who;
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package org.bukkit.event.vehicle;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a vehicle-related event.
|
||||
*/
|
||||
public abstract class VehicleEvent extends Event {
|
||||
public abstract class VehicleEvent extends Event implements WorldAttachedEvent { // Akarin
|
||||
protected Vehicle vehicle;
|
||||
@Override @NotNull public World getWorld() { return vehicle.getWorld(); } // Akarin
|
||||
|
||||
public VehicleEvent(@NotNull final Vehicle vehicle) {
|
||||
this.vehicle = vehicle;
|
||||
|
||||
@@ -4,10 +4,12 @@ import org.bukkit.World;
|
||||
import org.bukkit.event.Event;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import io.akarin.server.api.event.WorldAttachedEvent;
|
||||
|
||||
/**
|
||||
* Represents a Weather-related event
|
||||
*/
|
||||
public abstract class WeatherEvent extends Event {
|
||||
public abstract class WeatherEvent extends Event implements WorldAttachedEvent { // Akarin
|
||||
protected World world;
|
||||
|
||||
public WeatherEvent(@NotNull final World where) {
|
||||
|
||||
Reference in New Issue
Block a user