本文整理汇总了Java中org.bukkit.event.entity.PlayerDeathEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerDeathEvent.getEntity方法的具体用法?Java PlayerDeathEvent.getEntity怎么用?Java PlayerDeathEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.PlayerDeathEvent
的用法示例。
在下文中一共展示了PlayerDeathEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
Faction currentEventFac = plugin.getTimerManager().getEventTimer().getEventFaction();
if (currentEventFac instanceof ConquestFaction) {
Player player = event.getEntity();
PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction != null && SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH > 0) {
int oldPoints = getPoints(playerFaction);
if (oldPoints == 0) return;
int newPoints = takePoints(playerFaction, SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH);
event.setDeathMessage(null); // for some reason if it isn't handled manually, weird colour coding happens
Bukkit.broadcastMessage(ChatColor.YELLOW + "[" + currentEventFac.getName() + "] " +
ChatColor.GOLD + playerFaction.getName() + " lost " +
SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH + " points because " + player.getName() + " died." +
ChatColor.AQUA + " (" + newPoints + '/' + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + ')' + ChatColor.YELLOW + '.');
}
}
}
示例2: handle
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
private void handle(PlayerDeathEvent event, Game game) {
Player player = event.getEntity();
if (!game.isState(Game.GameState.ACTIVE) && !game.isState(Game.GameState.DEATHMATCH)) {
return;
}
event.setDeathMessage(null);
game.activateSpectatorSettings(player);
if (game.getPlayers().size() <= 1) {
try {
GamePlayer winner = game.getPlayers().get(0);
if (winner.isTeamClass()) {
game.sendMessage("&a"); // Broadcast team win
} else {
game.sendMessage("&a" + winner.getName() + " won the game!"); // Indiv win
}
game.setState(Game.GameState.ENDING);
} catch (IndexOutOfBoundsException ignored) {}
}
}
示例3: playerDie
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void playerDie(PlayerDeathEvent e){
Player p = e.getEntity();
Location l = p.getLocation();
Economy eco = new Economy(p);
DecimalFormat df = new DecimalFormat("0.##");
double money = 0;
try {
money = new Double(df.format(eco.getMoney() * 0.04).replace(",", "."));
}catch(NumberFormatException ex){
WCServer.log(WCServer.Level.WARNING, "Intentando crear un double con ,");
}
if (eco.getMoney() - money <= 0) return;
eco.removeMoney(money);
l.getWorld().dropItemNaturally(l, new ItemMaker(Material.GOLD_INGOT).setDisplayName("&2" + money + "&6€ de &c" + p.getName()).build());
Teams.TeamsInfo team = plugin.getTeams().getTeam(WCTWD.getPlayer(p));
e.setDeathMessage(Utils.colorize(team.getColor() + p.getName() + " &7ha muerto por un &cataque Zombie"));
}
示例4: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player killedP = event.getEntity();
Player killerP = event.getEntity().getKiller();
FPlayer killedF = fPlayers.getByPlayer(killedP);
FPlayer killerF = killerP != null ? fPlayers.getByPlayer(killerP) : null;
double loss = fConfig.getPowerDeathLoss();
double newPower = killedF.getPower() - loss;
killedF.setPower(newPower < fConfig.getMinPower() ? fConfig.getMinPower() : newPower);
if (killerP != null) {
killerF.setPower(killerF.getPower() + loss);
ParsingUtil.sendMessage(killedP, FMessage.DEATH_PLAYER_KILL_KILLED.getMessage(), killerF, String.valueOf(loss), String.valueOf(killedF.getPower()));
ParsingUtil.sendMessage(killerP, FMessage.DEATH_PLAYER_KILL_KILLER.getMessage(), killedF, String.valueOf(loss), String.valueOf(killerF.getPower()));
} else {
ParsingUtil.sendMessage(killedP, FMessage.DEATH_DEFAULT_DEATH.getMessage(), String.valueOf(loss), String.valueOf(killedF.getPower()));
}
}
示例5: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
String dmessage = event.getDeathMessage() + "!";
Team.getTeam(event.getEntity()).leave(event.getEntity());
event.setDeathMessage(null);
if (State.PRE)
return;
if (event.getEntity().getKiller() instanceof Player) {
Hive.getInstance().getDatabase().update(String.format("INSERT INTO kills (server,game_id,player,target) VALUES ('%s',%d,'%s','%s')","walls",Walls.ID,event.getEntity().getKiller().getName(),event.getEntity().getName()));
}
else {
Hive.getInstance().getDatabase().update(String.format("INSERT INTO kills (server,game_id,player,target) VALUES ('%s',%d,'%s','%s')","walls",Walls.ID,"natural",event.getEntity().getName()));
}
Chat.server(dmessage.replace(event.getEntity().getName(), event.getEntity().getDisplayName() + "&c"));
Walls.getSpectators().add(event.getEntity().getName());
Player p = event.getEntity();
Chat.player(p, "&2You are now a spectator and can watch the game.");
Walls.updateSpectators();
p.setFlying(true);
}
示例6: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) // Handle dungeon death.
public void onPlayerDeath(PlayerDeathEvent evt) {
if (!isDungeon(evt.getEntity()))
return;
evt.setKeepLevel(true); // Keep XP, but drop inventory. (Since you can't bring anything in)
Player p = evt.getEntity();
makeCorpse(p);
p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); // Restore to max health.
p.setGameMode(GameMode.SPECTATOR); // Set to spectator.
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 50, 2)); // Give blindness.
p.sendTitle(new Title(ChatColor.RED + "Dungeon Failed"));
getDungeon(p).alert(p.getName() + " has been eliminated.");
Utils.stopNBS(p); //Disable music.
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
Utils.toSpawn(p); // Teleport to spawn.
p.setGameMode(GameMode.SURVIVAL);
}, 50L);
}
示例7: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
World world = player.getWorld();
Location location = player.getLocation();
Collection<ItemStack> drops = event.getDrops();
if (!drops.isEmpty()) {
Iterator<ItemStack> iterator = drops.iterator();
// Drop the items manually so we can add meta to prevent
// PVP Protected players from collecting them.
long stamp = System.currentTimeMillis() + +ITEM_PICKUP_DELAY;
while (iterator.hasNext()) {
itemUUIDPickupDelays.put(world.dropItemNaturally(location, iterator.next()).getUniqueId(), stamp);
iterator.remove();
}
}
clearCooldown(player);
}
示例8: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Deathban deathban = plugin.getDeathbanManager().applyDeathBan(player, event.getDeathMessage());
long remaining = deathban.getRemaining();
if (remaining <= 0L || player.hasPermission(DeathbanListener.DEATH_BAN_BYPASS_PERMISSION)) {
return;
}
if (DeathbanListener.RESPAWN_KICK_DELAY_MILLIS <= 0L || remaining < DeathbanListener.RESPAWN_KICK_DELAY_MILLIS) {
this.handleKick(player, deathban);
return;
}
// Let the player see the death screen for 10 seconds
this.respawnTickTasks.put(player.getUniqueId(), new BukkitRunnable() {
@Override
public void run() {
DeathbanListener.this.handleKick(player, deathban);
}
}.runTaskLater(plugin, DeathbanListener.RESPAWN_KICK_DELAY_TICKS).getTaskId());
}
示例9: onKill
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onKill(PlayerDeathEvent event) {
Player target = event.getEntity();
Player killer = target.getKiller();
if (RankManager.isPrisoner(killer)) {
if (RankManager.isPrisoner(target)) {
killer.setTotalExperience(killer.getTotalExperience() + 250);
} else if (RankManager.isGuard(target) || RankManager.isWarden(target)) {
killer.setTotalExperience(killer.getTotalExperience() + 2000);
}
}
}
示例10: PlayerDeathListener
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void PlayerDeathListener(PlayerDeathEvent e) {
Player p = e.getEntity();
if (SettingsManager.deathchest) {
int x = p.getLocation().getBlockX();
int y = p.getLocation().getBlockY();
int z = p.getLocation().getBlockZ();
World w = p.getWorld();
Location loc = new Location(w, x, y, z);
loc.getBlock().setType(Material.CHEST);
Chest c = (Chest) loc.getBlock().getState();
c.getBlockInventory().setContents(p.getInventory().getArmorContents());
c.getBlockInventory().setContents(p.getInventory().getContents());
}
}
示例11: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer != null && !killer.equals(player)) {
event.getDrops().add(getDeathSign(player.getName(), killer.getName()));
}
}
示例12: DeathNoClear
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void DeathNoClear(PlayerDeathEvent event) {
if (ConfigOptimize.UnloadClearDROPPED_ITEMNoCleatDeath != true) {
return;
}
Player player = event.getEntity();
Chunk chunk = player.getLocation().getChunk();
DeathChunk.add(chunk);
}
示例13: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent e){
Player p = e.getEntity();
if(WCSurvival.getPlayer(p).hasPermission("noDrop")) {
e.setKeepInventory(true);
e.setKeepLevel(true);
}
}
示例14: clearActiveEnderPearls
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void clearActiveEnderPearls(final PlayerDeathEvent event) {
for(Entity entity : event.getEntity().getWorld().getEntitiesByClass(EnderPearl.class)) {
if(((EnderPearl) entity).getShooter() == event.getEntity()) {
entity.remove();
}
}
}
示例15: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
/**
* On kill, give Ninjanaut to killer
*
* @param event Death event instace
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
if (this.ninjanaut == null || !event.getEntity().getUniqueId().equals(this.ninjanaut) || event.getEntity().getKiller() == null
|| event.getEntity().getKiller() == event.getEntity())
return;
SurvivalGame game = (SurvivalGame)SamaGamesAPI.get().getGameManager().getGame();
SurvivalPlayer player = (SurvivalPlayer)game.getPlayer(event.getEntity().getKiller().getUniqueId());
if (player != null)
this.setNinjaNaut(game, player, false);
}