More event methods
This commit is contained in:
parent
71cc815d9d
commit
09b15cd16e
3 changed files with 26 additions and 3 deletions
|
@ -3,5 +3,11 @@ package gent.zeus.mc13dtl.events;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public interface Event {
|
public interface Event {
|
||||||
|
public String getMessage();
|
||||||
|
|
||||||
|
public int getScore();
|
||||||
|
|
||||||
|
public int getDifficultyThreshold();
|
||||||
|
|
||||||
public void run(Player player);
|
public void run(Player player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,16 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import gent.zeus.mc13dtl.events.catalog.TestEvent;
|
import gent.zeus.mc13dtl.events.catalog.TestEvent;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
public class RandomEventExecutor {
|
public class RandomEventExecutor {
|
||||||
static List<Event> events = Arrays.asList(new TestEvent());
|
static List<Event> events = Arrays.asList(new TestEvent());
|
||||||
|
|
||||||
public static void executeRandomEvent(Player player) {
|
public static void executeRandomEvent(Player player) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int event = random.nextInt(events.size());
|
int i = random.nextInt(events.size());
|
||||||
events.get(event).run(player);
|
Event event = events.get(i);
|
||||||
|
player.sendMessage(ChatColor.ITALIC + event.getMessage());
|
||||||
|
event.run(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,22 @@ import org.bukkit.entity.Player;
|
||||||
import gent.zeus.mc13dtl.events.Event;
|
import gent.zeus.mc13dtl.events.Event;
|
||||||
|
|
||||||
public class TestEvent implements 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
|
@Override
|
||||||
public void run(Player player) {
|
public void run(Player player) {
|
||||||
player.sendMessage("test");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue