Search in sources :

Example 41 with EventHandler

use of org.bukkit.event.EventHandler in project GameCore by Warvale.

the class GlobalEvent method onPlayerDeath.

@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
    event.setDeathMessage("");
    Player vName = event.getEntity();
    Player kName = vName.getKiller();
    ChatColor gray = ChatColor.GRAY;
    String victim = (Main.getTeams().getBlueTeam().hasPlayer(vName) ? ChatColor.DARK_AQUA + vName.getName() : (Main.getTeams().getRedTeam().hasPlayer(vName) ? ChatColor.RED + vName.getName() : ChatColor.AQUA + vName.getName()));
    String killer = (Main.getTeams().getBlueTeam().hasPlayer(kName) ? ChatColor.DARK_AQUA + kName.getName() : (Main.getTeams().getRedTeam().hasPlayer(kName) ? ChatColor.RED + kName.getName() : ChatColor.AQUA + kName.getName()));
    ArrayList<String> deathMessages = new ArrayList<>();
    deathMessages.addAll(Arrays.asList(killer + gray + " squished " + victim + gray + " like a bug.", killer + gray + " delivered the final coup de grĂ¢ce to " + victim, killer + gray + " assassinated " + victim, killer + gray + " put " + victim + gray + " out of their misery.", killer + gray + " showed no mercy to " + victim, killer + gray + " back-stabbed " + victim, killer + gray + " slayed " + victim, killer + gray + " brutally beat " + victim, killer + gray + " rearranged " + victim + gray + "'s face.", killer + gray + " ended " + victim + gray + "'s pitiful existence.", killer + gray + " removed the limbs of " + victim, killer + gray + " answered " + victim + "'s plea for death.", gray + "Thanks to " + killer + gray + ", " + victim + gray + " no longer exists.", killer + gray + " proved that " + victim + gray + " was no match for them.", killer + gray + " sent " + victim + gray + " to their grave."));
    int r = NumberUtils.random(deathMessages.size() - 1, 0);
    vName.sendMessage(deathMessages.get(r));
    kName.sendMessage(deathMessages.get(r));
}
Also used : Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) ChatColor(org.bukkit.ChatColor) EventHandler(org.bukkit.event.EventHandler)

Example 42 with EventHandler

use of org.bukkit.event.EventHandler in project GameCore by Warvale.

the class LeaveServer method onPlayerLeaveEvent.

@EventHandler
public void onPlayerLeaveEvent(PlayerQuitEvent event) {
    event.setQuitMessage("");
    String playerName = event.getPlayer().getName();
    event.getPlayer().getInventory().clear();
    if (Main.getTeams().getSpectatorTeam().getEntries().contains(event.getPlayer().getName())) {
        Main.getTeams().getSpectatorTeam().removeEntry(event.getPlayer().getName());
    }
    if (Main.getTeams().getRedTeam().getEntries().contains(event.getPlayer().getName())) {
        Main.getTeams().getRedTeam().removeEntry(event.getPlayer().getName());
    }
    if (Main.getTeams().getBlueTeam().getEntries().contains(event.getPlayer().getName())) {
        Main.getTeams().getBlueTeam().removeEntry(event.getPlayer().getName());
    }
    for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) {
        if (!Preferences.noLeaveMessages.contains(onlinePlayer.getName()) && onlinePlayer.getName() != event.getPlayer().getName()) {
            onlinePlayer.sendMessage(ChatColor.GRAY + playerName + ChatColor.GRAY + " left.");
        }
    }
    LobbyScoreboard.getInstance().removeScoreboard(event.getPlayer());
    BarManager.broadcast(BarColor.RED, ChatColor.DARK_RED + ChatColor.BOLD.toString() + "[-] " + ChatColor.RESET + playerName);
    BarManager.broadcastSound(Sound.BLOCK_NOTE_BASS);
    int minPlayers = Game.getInstance().getMinPlayers() - Bukkit.getOnlinePlayers().size();
    MessageManager.broadcast(PrefixType.MAIN, ChatColor.RED + String.valueOf(minPlayers) + ChatColor.DARK_GREEN + " more players needed to start the game!");
}
Also used : Player(org.bukkit.entity.Player) EventHandler(org.bukkit.event.EventHandler)

Example 43 with EventHandler

use of org.bukkit.event.EventHandler in project GameCore by Warvale.

the class AbilityManager method onMove.

@EventHandler
public void onMove(PlayerMoveEvent e) {
    if (!freeze.contains(e.getPlayer()))
        return;
    if (!electroCooldown.contains(e.getPlayer()))
        return;
    Location from = e.getFrom();
    Location to = e.getTo();
    double x = Math.floor(from.getX());
    double z = Math.floor(from.getZ());
    if (Math.floor(to.getX()) != x || Math.floor(to.getZ()) != z) {
        x += .5;
        z += .5;
        e.getPlayer().teleport(new Location(from.getWorld(), x, from.getY(), z, from.getYaw(), from.getPitch()));
    }
}
Also used : Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 44 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class Events method breakScoreboard.

@EventHandler(ignoreCancelled = true)
private void breakScoreboard(BlockBreakEvent event) {
    Block block = event.getBlock();
    if (block.getType() == Material.WALL_SIGN) {
        if (block.hasMetadata("MGScoreboardSign")) {
            Minigame minigame = (Minigame) block.getMetadata("Minigame").get(0).value();
            minigame.getScoreboardData().removeDisplay(block);
        }
    }
}
Also used : Block(org.bukkit.block.Block) Minigame(au.com.mineauz.minigames.minigame.Minigame) EventHandler(org.bukkit.event.EventHandler)

Example 45 with EventHandler

use of org.bukkit.event.EventHandler in project Minigames by AddstarMC.

the class SignBase method signBreak.

@EventHandler(priority = EventPriority.LOWEST)
private void signBreak(BlockBreakEvent event) {
    if (event.getBlock().getType() == Material.SIGN_POST || event.getBlock().getType() == Material.WALL_SIGN) {
        Sign sign = (Sign) event.getBlock().getState();
        if (sign.getLine(0).equals(ChatColor.DARK_BLUE + "[Minigame]") && minigameSigns.containsKey(ChatColor.stripColor(sign.getLine(1).toLowerCase()))) {
            MinigameSign mgSign = minigameSigns.get(ChatColor.stripColor(sign.getLine(1).toLowerCase()));
            if (mgSign.getCreatePermission() != null && !event.getPlayer().hasPermission(mgSign.getCreatePermission())) {
                event.setCancelled(true);
                return;
            }
            mgSign.signBreak(sign, Minigames.plugin.pdata.getMinigamePlayer(event.getPlayer()));
        }
    }
}
Also used : Sign(org.bukkit.block.Sign) EventHandler(org.bukkit.event.EventHandler)

Aggregations

EventHandler (org.bukkit.event.EventHandler)532 Player (org.bukkit.entity.Player)185 Entity (org.bukkit.entity.Entity)70 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)67 net.aufdemrand.denizen.objects.dLocation (net.aufdemrand.denizen.objects.dLocation)62 Block (org.bukkit.block.Block)62 ItemStack (org.bukkit.inventory.ItemStack)55 Location (org.bukkit.Location)54 Island (com.wasteofplastic.acidisland.Island)42 Element (net.aufdemrand.denizencore.objects.Element)38 LivingEntity (org.bukkit.entity.LivingEntity)37 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)31 Minigame (au.com.mineauz.minigames.minigame.Minigame)29 net.aufdemrand.denizen.objects.dItem (net.aufdemrand.denizen.objects.dItem)29 net.aufdemrand.denizencore.objects.dList (net.aufdemrand.denizencore.objects.dList)28 Projectile (org.bukkit.entity.Projectile)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)23 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)22 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)18 ArrayList (java.util.ArrayList)18