Add event interface

This commit is contained in:
Mathieu Strypsteen 2024-09-14 21:31:03 +02:00
parent c4599d1421
commit 71cc815d9d
3 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,7 @@
package gent.zeus.mc13dtl.events;
import org.bukkit.entity.Player;
public interface Event {
public void run(Player player);
}

View file

@ -1,9 +1,17 @@
package gent.zeus.mc13dtl.events;
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 {
static List<Event> events = Arrays.asList(new TestEvent());
public static void executeRandomEvent(Player player) {
player.sendMessage("test");
Random random = new Random();
int event = random.nextInt(events.size());
events.get(event).run(player);
}
}

View file

@ -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");
}
}