本文整理汇总了Java中org.bukkit.event.entity.PlayerDeathEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerDeathEvent类的具体用法?Java PlayerDeathEvent怎么用?Java PlayerDeathEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerDeathEvent类属于org.bukkit.event.entity包,在下文中一共展示了PlayerDeathEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: autoRespawn
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void autoRespawn(PlayerDeathEvent evt) {
if (canAutoRespawn) {
final Player player = evt.getEntity();
Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis, new Runnable() {
@Override
@SuppressWarnings("all")
public void run() {
if(VersionLevel.isSpigot()){
player.spigot().respawn();
if (sendTitleAutoRespawn) {
if(VersionLevel.isHigherEquals(Version.MINECRAFT_1_8_R2)){
player.sendTitle(titleAutoRespawn, subtitleAutoRespawn);
}else{
AzureAPI.log("错误!你不应该开启自动复活的title显示,无法显示!因为你的服务器版本低于1.8.4!");
}
}
}
}
}, 1);
}
}
示例2: onVisitorDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorDeath(final PlayerDeathEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Util.inWorld(e.getEntity())) {
return;
}
// Mute death messages
if (Settings.muteDeathMessages) {
e.setDeathMessage(null);
}
// If visitors will keep items and their level on death. This overrides any global settings.
// If the player is not a visitor then they die and lose everything - sorry :-(
Island island = plugin.getIslands().getProtectedIslandAt(e.getEntity().getLocation());
if (island != null && !island.getMembers().contains(e.getEntity().getUniqueId()) && island.getFlag(SettingsFlag.KEEP_INVENTORY)) {
// They are a visitor
InventorySave.getInstance().savePlayerInventory(e.getEntity());
e.getDrops().clear();
e.setKeepLevel(true);
e.setDroppedExp(0);
}
}
示例3: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent e){
Entity en1 = e.getEntity();
Entity en = e.getEntity().getKiller();
if (en instanceof Player){
Player pl = (Player)en1;
Player p = (Player)en;
if(manager.isInPvP(p)){
vu.killMoney(p, pl);
e.setKeepInventory(true);
pvpc.removeCooldown(p);
pvpc.removeCooldown(pl);
p.sendMessage(Message.prefix + ChatColor.DARK_GREEN + " Ya no estás en pvp, puedes desconectarte.");
pl.sendMessage(Message.prefix + ChatColor.DARK_GREEN + " Ya no estás en pvp, puedes desconectarte.");
}
}
}
示例4: 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"));
}
示例5: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
@EventHandler
private void onPlayerDeath(PlayerDeathEvent e) {
e.setDeathMessage(null);
e.setDroppedExp(0);
e.getEntity().setGameMode(GameMode.SPECTATOR);
PlayerTagMetadata.updateMetadata(e.getEntity(), PlayerTag.SPECTATING);
if(e.getEntity().hasMetadata("last_hurt_by")) {
Player killer = (Player) e.getEntity().getMetadata("last_hurt_by").get(0).value();
plugin.getServer().broadcastMessage(Lang.build("messages.game.kill", e.getEntity().getName(),
killer.getName()));
if(killer.isOnline()) {
Score s = killer.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(scoreboardLabelKills);
s.setScore(s.getScore() + 1);
}
} else {
plugin.getServer().broadcastMessage(Lang.build("messages.game.died", e.getEntity().getName()));
}
rerankPlayers();
}
示例6: processPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
/**
* NOTE: Must be called before {@link tc.oc.pgm.tracker.trackers.DeathTracker#onPlayerDeath(PlayerDeathEvent)}
*/
@SuppressWarnings("deprecation")
@TargetedEventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void processPlayerDeath(PlayerDeathEvent event) {
if(!player.isParticipating()) return;
if(!rules.canKeepAny()) return;
final Map<Slot, ItemStack> carrying = new HashMap<>();
Slot.Player.player().forEach(slot -> slot.item(event.getEntity())
.ifPresent(item -> carrying.put(slot, item)));
kept.clear();
carrying.forEach((slot, item) -> {
if(rules.canKeep(slot, item)) {
event.getDrops().remove(item);
kept.put(slot, item);
}
});
}
示例7: 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()));
}
}
示例8: setHealth
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
@Override
public void setHealth(double health)
{
if (health <= 0)
{
this.health = 0;
PlayerDeathEvent event = new PlayerDeathEvent(this, new ArrayList<>(), 0, name + " got killed");
Bukkit.getPluginManager().callEvent(event);
}
else if (health > maxHealth)
{
this.health = maxHealth;
}
else
{
this.health = health;
}
}
示例9: 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);
}
示例10: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
/**
* Drop player head on kill
*
* @param event Event
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
skullMeta.setOwner(event.getEntity().getName());
skullMeta.setDisplayName(ChatColor.AQUA + "Tête de " + event.getEntity().getName());
head.setItemMeta(skullMeta);
event.getDrops().add(head);
List<PotionEffect> effectList = new ArrayList<>();
effectList.addAll(event.getEntity().getActivePotionEffects());
this.effects.put(event.getEntity().getName(), effectList);
}
示例11: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
/**
* Give x absorption to all players on deaths
*
* @param event The player death event instance
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
for (SurvivalPlayer player : (Collection<SurvivalPlayer>) SamaGamesAPI.get().getGameManager().getGame().getInGamePlayers().values())
{
if (!player.getUUID().equals(event.getEntity().getUniqueId()))
{
Player p = player.getPlayerIfOnline();
if (p == null)
continue;
EntityPlayer entityPlayer = ((CraftPlayer) p).getHandle();
entityPlayer.setAbsorptionHearts(entityPlayer.getAbsorptionHearts() + (int) this.moduleConfiguration.get("hearts"));
}
}
}
示例12: onEntityDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
/**
* When a player is dead, swap inventories
*
* @param event Event
*/
@EventHandler
public void onEntityDeath(PlayerDeathEvent event)
{
if (event.getEntity().getKiller() != null)
{
ItemStack[] content = event.getEntity().getInventory().getContents();
ItemStack[] armor = event.getEntity().getInventory().getArmorContents();
event.getEntity().getKiller().getInventory().setContents(content);
event.getEntity().getKiller().getInventory().setArmorContents(armor);
event.getDrops().clear();
event.getEntity().getKiller().sendMessage(ChatColor.GOLD + "Vous avez échangé votre inventaire avec celui de " + event.getEntity().getName() + ".");
}
}
示例13: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入依赖的package包/类
/**
* Toggle speed when player dies
*
* @param event Event
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
for (GamePlayer player : (Collection<GamePlayer>) SamaGamesAPI.get().getGameManager().getGame().getInGamePlayers().values())
{
Player p = player.getPlayerIfOnline();
if (p == null)
return;
p.addPotionEffect((this.isSpeed ? PotionEffectType.SPEED : PotionEffectType.SLOW).createEffect(Integer.MAX_VALUE, 1));
}
this.isSpeed = !this.isSpeed;
}
示例14: 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);
}
示例15: 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 + '.');
}
}
}