use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class LivesMechanic method minigameStart.
@EventHandler
private void minigameStart(StartMinigameEvent event) {
if (event.getMinigame().getMechanicName().equals(getMechanic())) {
final List<MinigamePlayer> players = event.getPlayers();
final Minigame minigame = event.getMinigame();
for (MinigamePlayer player : players) {
player.setScore(minigame.getLives());
minigame.setScore(player, minigame.getLives());
}
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method playerMove.
@EventHandler(ignoreCancelled = true)
private void playerMove(PlayerMoveEvent event) {
MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
Minigame mg = ply.getMinigame();
executeRegionChanges(mg, ply);
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method itemPickupEvent.
@EventHandler(ignoreCancelled = true)
private void itemPickupEvent(PlayerDropItemEvent event) {
final MinigamePlayer ply = pdata.getMinigamePlayer(event.getPlayer());
if (ply == null)
return;
if (ply.isInMinigame()) {
final Trigger trig = Triggers.getTrigger("ITEM_DROP");
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
if (!ply.isInMinigame()) {
return;
}
for (Node node : getRegionModule(ply.getMinigame()).getNodes()) {
node.execute(trig, ply);
}
for (Region region : getRegionModule(ply.getMinigame()).getRegions()) {
if (region.hasPlayer(ply)) {
region.execute(trig, ply);
}
}
}
});
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method playerQuit.
@EventHandler(ignoreCancelled = true)
private void playerQuit(QuitMinigameEvent event) {
MinigamePlayer ply = event.getMinigamePlayer();
if (ply == null)
return;
Minigame mg = ply.getMinigame();
for (Region r : RegionModule.getMinigameModule(mg).getRegions()) {
if (r.hasPlayer(ply))
r.removePlayer(ply);
}
for (Node node : RegionModule.getMinigameModule(event.getMinigame()).getNodes()) {
node.execute(Triggers.getTrigger("GAME_QUIT"), event.getMinigamePlayer());
if (event.getMinigame().getPlayers().size() > 1) {
for (NodeExecutor exec : node.getExecutors()) exec.removeTrigger(event.getMinigamePlayer());
} else {
for (NodeExecutor exec : node.getExecutors()) exec.clearTriggers();
node.setEnabled(true);
}
}
for (Region region : RegionModule.getMinigameModule(event.getMinigame()).getRegions()) {
if (region.playerInRegion(ply))
region.execute(Triggers.getTrigger("GAME_QUIT"), event.getMinigamePlayer());
if (event.getMinigame().getPlayers().size() > 1) {
for (RegionExecutor exec : region.getExecutors()) exec.removeTrigger(event.getMinigamePlayer());
} else {
for (RegionExecutor exec : region.getExecutors()) {
exec.clearTriggers();
}
region.removeTickTask();
region.setEnabled(true);
}
}
}
use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.
the class RegionEvents method playerXpChange.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void playerXpChange(PlayerExpChangeEvent event) {
final MinigamePlayer player = pdata.getMinigamePlayer(event.getPlayer());
if (player == null || !player.isInMinigame()) {
return;
}
executeTrigger(Triggers.getTrigger("XP_CHANGE"), player);
}
Aggregations