当前位置: 首页>>代码示例>>Java>>正文


Java PlayerDeathEvent类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:23,代码来源:RespawnAction.java

示例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);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:24,代码来源:VisitorGuard.java

示例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.");
         }
         
     }
 }
 
开发者ID:cadox8,项目名称:WC,代码行数:23,代码来源:PlayerEvent.java

示例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"));
}
 
开发者ID:cadox8,项目名称:WC,代码行数:24,代码来源:WorldInteract.java

示例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();
}
 
开发者ID:DragonetMC,项目名称:PlayerStevesBattleGrounds,代码行数:22,代码来源:Battles.java

示例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);
        }
    });
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:23,代码来源:ItemKeepPlayerFacet.java

示例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()));
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:18,代码来源:PlayerListener.java

示例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;
	}
}
 
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:19,代码来源:PlayerMock.java

示例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);
  }
 
开发者ID:thekeenant,项目名称:mczone,代码行数:23,代码来源:GameEvents.java

示例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);
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:CookieHeadModule.java

示例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"));
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:StockupModule.java

示例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() + ".");
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:22,代码来源:KillSwitchModule.java

示例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;
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:21,代码来源:SpeedSwapModule.java

示例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);
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Dungeons.java

示例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 + '.');
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:ConquestTracker.java


注:本文中的org.bukkit.event.entity.PlayerDeathEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。