Introduced event-based resource getter interfaces
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
package mc.core.events.api.interfaces;
|
||||||
|
|
||||||
|
import mc.core.Location;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface LocationProvidingEvent {
|
||||||
|
Collection<Location> getAssociatedLocations();
|
||||||
|
}
|
||||||
@@ -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<Player> getAssociatedPlayers();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default Collection<Location> getAssociatedLocations() {
|
||||||
|
List<Player> players = getAssociatedPlayers();
|
||||||
|
if (players.size() == 1)
|
||||||
|
return Collections.singletonList(players.get(0).getLocation());
|
||||||
|
else
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package mc.core.events.api.interfaces;
|
||||||
|
|
||||||
|
import mc.core.world.World;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface WorldProvidingEvent {
|
||||||
|
Collection<World> getAssociatedWorlds();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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<Player> getAssociatedPlayers() {
|
||||||
|
return Collections.singletonList(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Location> getAssociatedLocations() {
|
||||||
|
return Collections.singletonList(blockLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user