diff --git a/event-loop/src/main/java/mc/core/events/api/interfaces/LocationProvidingEvent.java b/event-loop/src/main/java/mc/core/events/api/interfaces/LocationProvidingEvent.java new file mode 100644 index 0000000..bec7040 --- /dev/null +++ b/event-loop/src/main/java/mc/core/events/api/interfaces/LocationProvidingEvent.java @@ -0,0 +1,9 @@ +package mc.core.events.api.interfaces; + +import mc.core.Location; + +import java.util.Collection; + +public interface LocationProvidingEvent { + Collection getAssociatedLocations(); +} diff --git a/event-loop/src/main/java/mc/core/events/api/interfaces/PlayerProvidingEvent.java b/event-loop/src/main/java/mc/core/events/api/interfaces/PlayerProvidingEvent.java new file mode 100644 index 0000000..b434061 --- /dev/null +++ b/event-loop/src/main/java/mc/core/events/api/interfaces/PlayerProvidingEvent.java @@ -0,0 +1,22 @@ +package mc.core.events.api.interfaces; + +import mc.core.Location; +import mc.core.player.Player; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public interface PlayerProvidingEvent extends LocationProvidingEvent { + List getAssociatedPlayers(); + + @Override + default Collection getAssociatedLocations() { + List players = getAssociatedPlayers(); + if (players.size() == 1) + return Collections.singletonList(players.get(0).getLocation()); + else + throw new NotImplementedException(); + } +} diff --git a/event-loop/src/main/java/mc/core/events/api/interfaces/WorldProvidingEvent.java b/event-loop/src/main/java/mc/core/events/api/interfaces/WorldProvidingEvent.java new file mode 100644 index 0000000..9f561e5 --- /dev/null +++ b/event-loop/src/main/java/mc/core/events/api/interfaces/WorldProvidingEvent.java @@ -0,0 +1,10 @@ +package mc.core.events.api.interfaces; + +import mc.core.world.World; + +import java.util.Collection; + +public interface WorldProvidingEvent { + Collection getAssociatedWorlds(); + +} diff --git a/event-loop/src/main/java/mc/core/events/api/samples/BlockBreakEvent.java b/event-loop/src/main/java/mc/core/events/api/samples/BlockBreakEvent.java new file mode 100644 index 0000000..b0f3044 --- /dev/null +++ b/event-loop/src/main/java/mc/core/events/api/samples/BlockBreakEvent.java @@ -0,0 +1,28 @@ +package mc.core.events.api.samples; + +import mc.core.Location; +import mc.core.events.EventBase; +import mc.core.events.api.interfaces.LocationProvidingEvent; +import mc.core.events.api.interfaces.PlayerProvidingEvent; +import mc.core.player.Player; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +public class BlockBreakEvent extends EventBase implements PlayerProvidingEvent, LocationProvidingEvent { + private Player player; + // TODO: There should be a proper block reference + private Location blockLocation; + + + @Override + public List getAssociatedPlayers() { + return Collections.singletonList(player); + } + + @Override + public Collection getAssociatedLocations() { + return Collections.singletonList(blockLocation); + } +}