More event methods

This commit is contained in:
Mathieu Strypsteen 2024-09-14 21:47:58 +02:00
parent 71cc815d9d
commit 09b15cd16e
3 changed files with 26 additions and 3 deletions

View file

@ -3,5 +3,11 @@ package gent.zeus.mc13dtl.events;
import org.bukkit.entity.Player;
public interface Event {
public String getMessage();
public int getScore();
public int getDifficultyThreshold();
public void run(Player player);
}

View file

@ -5,13 +5,16 @@ import java.util.List;
import java.util.Random;
import java.util.Arrays;
import gent.zeus.mc13dtl.events.catalog.TestEvent;
import net.md_5.bungee.api.ChatColor;
public class RandomEventExecutor {
static List<Event> events = Arrays.asList(new TestEvent());
public static void executeRandomEvent(Player player) {
Random random = new Random();
int event = random.nextInt(events.size());
events.get(event).run(player);
int i = random.nextInt(events.size());
Event event = events.get(i);
player.sendMessage(ChatColor.ITALIC + event.getMessage());
event.run(player);
}
}

View file

@ -5,8 +5,22 @@ import org.bukkit.entity.Player;
import gent.zeus.mc13dtl.events.Event;
public class TestEvent implements Event {
@Override
public String getMessage() {
return "test";
}
@Override
public int getScore() {
return 1;
}
@Override
public int getDifficultyThreshold() {
return 0;
}
@Override
public void run(Player player) {
player.sendMessage("test");
}
}