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


Java PlayerDeathEvent.getEntity方法代码示例

本文整理汇总了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 + '.');
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:ConquestTracker.java

示例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) {}
    }
}
 
开发者ID:JordanOsterberg,项目名称:SkywarsSeries,代码行数:24,代码来源:PlayerDeath.java

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

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

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

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

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

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

示例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);
        }
    }
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:13,代码来源:RankListener.java

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

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

示例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);
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:10,代码来源:UnloadClear.java

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

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

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


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