Add event interface
This commit is contained in:
parent
c4599d1421
commit
71cc815d9d
3 changed files with 28 additions and 1 deletions
7
src/main/java/gent/zeus/mc13dtl/events/Event.java
Normal file
7
src/main/java/gent/zeus/mc13dtl/events/Event.java
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package gent.zeus.mc13dtl.events;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface Event {
|
||||||
|
public void run(Player player);
|
||||||
|
}
|
|
@ -1,9 +1,17 @@
|
||||||
package gent.zeus.mc13dtl.events;
|
package gent.zeus.mc13dtl.events;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import gent.zeus.mc13dtl.events.catalog.TestEvent;
|
||||||
|
|
||||||
public class RandomEventExecutor {
|
public class RandomEventExecutor {
|
||||||
|
static List<Event> events = Arrays.asList(new TestEvent());
|
||||||
|
|
||||||
public static void executeRandomEvent(Player player) {
|
public static void executeRandomEvent(Player player) {
|
||||||
player.sendMessage("test");
|
Random random = new Random();
|
||||||
|
int event = random.nextInt(events.size());
|
||||||
|
events.get(event).run(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package gent.zeus.mc13dtl.events.catalog;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import gent.zeus.mc13dtl.events.Event;
|
||||||
|
|
||||||
|
public class TestEvent implements Event {
|
||||||
|
@Override
|
||||||
|
public void run(Player player) {
|
||||||
|
player.sendMessage("test");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue