Search in sources :

Example 16 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class BroadcastAction method execute.

private void execute(MinigamePlayer player, ScriptObject base) {
    MinigameMessageType type = MinigameMessageType.INFO;
    if (redText.getFlag())
        type = MinigameMessageType.ERROR;
    MinigamePlayer exclude = null;
    if (excludeExecutor.getFlag())
        exclude = player;
    // Old replacement
    String message = this.message.getFlag();
    if (player != null) {
        message = message.replace("%player%", player.getDisplayName(player.getMinigame().usePlayerDisplayNames()));
    }
    // New expression system
    message = ExpressionParser.stringResolve(message, base, true, true);
    if (player != null)
        Minigames.getPlugin().getMinigameManager().sendMinigameMessage(player.getMinigame(), message, type, exclude);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) MinigameMessageType(au.com.mineauz.minigames.MinigameMessageType)

Example 17 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer 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.isInMinigame()) {
        final Trigger trig = Triggers.getTrigger("ITEM_DROP");
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, executeScriptObjects(ply, trig));
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Trigger(au.com.mineauz.minigamesregions.triggers.Trigger) EventHandler(org.bukkit.event.EventHandler)

Example 18 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer 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);
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) EventHandler(org.bukkit.event.EventHandler)

Example 19 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer 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);
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 20 with MinigamePlayer

use of au.com.mineauz.minigames.objects.MinigamePlayer in project Minigames by AddstarMC.

the class RegionEvents method playerJoin.

@EventHandler(ignoreCancelled = true)
private void playerJoin(JoinMinigameEvent event) {
    final MinigamePlayer ply = event.getMinigamePlayer();
    if (ply == null)
        return;
    final Minigame mg = event.getMinigame();
    Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
        executeRegionChanges(mg, ply);
        for (Node node : RegionModule.getMinigameModule(mg).getNodes()) {
            node.execute(Triggers.getTrigger("GAME_JOIN"), ply);
        }
        for (Region region : RegionModule.getMinigameModule(mg).getRegions()) {
            if (region.hasPlayer(ply))
                region.execute(Triggers.getTrigger("GAME_JOIN"), ply);
        }
    });
    if (event.getMinigame().getPlayers().size() == 0) {
        for (Region region : RegionModule.getMinigameModule(event.getMinigame()).getRegions()) {
            for (RegionExecutor ex : region.getExecutors()) {
                if (ex.getTrigger().getName().equalsIgnoreCase("TICK")) {
                    region.startTickTask();
                    break;
                }
            }
        }
    }
}
Also used : MinigamePlayer(au.com.mineauz.minigames.objects.MinigamePlayer) RegionExecutor(au.com.mineauz.minigamesregions.executors.RegionExecutor) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Aggregations

MinigamePlayer (au.com.mineauz.minigames.objects.MinigamePlayer)134 EventHandler (org.bukkit.event.EventHandler)46 Minigame (au.com.mineauz.minigames.minigame.Minigame)40 ArrayList (java.util.ArrayList)25 Team (au.com.mineauz.minigames.minigame.Team)24 OfflineMinigamePlayer (au.com.mineauz.minigames.objects.OfflineMinigamePlayer)15 Player (org.bukkit.entity.Player)15 Location (org.bukkit.Location)11 ItemStack (org.bukkit.inventory.ItemStack)8 MinigameTool (au.com.mineauz.minigames.tool.MinigameTool)7 Menu (au.com.mineauz.minigames.menu.Menu)5 TeamColor (au.com.mineauz.minigames.minigame.TeamColor)5 List (java.util.List)5 PotionEffect (org.bukkit.potion.PotionEffect)5 ResourcePack (au.com.mineauz.minigames.objects.ResourcePack)4 Material (org.bukkit.Material)4 Sign (org.bukkit.block.Sign)4 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)3 MenuItem (au.com.mineauz.minigames.menu.MenuItem)2 MenuItemBoolean (au.com.mineauz.minigames.menu.MenuItemBoolean)2