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));
}
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!");
}
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()));
}
}
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);
}
}
}
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()));
}
}
}
Aggregations