本文整理汇总了Java中org.bukkit.event.entity.PlayerDeathEvent.setDeathMessage方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerDeathEvent.setDeathMessage方法的具体用法?Java PlayerDeathEvent.setDeathMessage怎么用?Java PlayerDeathEvent.setDeathMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.PlayerDeathEvent
的用法示例。
在下文中一共展示了PlayerDeathEvent.setDeathMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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"));
}
示例3: 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();
}
示例4: 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);
}
示例5: 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 + '.');
}
}
}
示例6: 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) {}
}
}
示例7: PlayerDeathEvent
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void PlayerDeathEvent(PlayerDeathEvent event){
Player player = event.getEntity();
if(isJailPlayer(player)){
event.setDeathMessage(null);
player.spigot().respawn();
playerTeleportJail(player);
}
}
示例8: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent e) {
KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getEntity());
e.setKeepInventory(false);
if(player.getKingdom().getType().equals(KingdomType.GEEN)) {
player.getInventory().clear();
player.getInventory().addItem(Item.getInstance().getItem(Material.COMPASS, ChatColor.RED + "Selecteer jouw kingdom", 1));
player.updateInventory();
player.teleport(player.getKingdom().getSpawn());
}
if (e.getEntity().getKiller() != null) {
KingdomFactionsPlayer killer = PlayerModule.getInstance().getPlayer(e.getEntity().getKiller());
e.setDeathMessage(getName(player) + " is verwond door " + getName(killer) + "!");
if(player.getCombatTracker().isInCombat()) {
player.getCombatTracker().clearCombat();
}
Bukkit.getScheduler().runTaskLater(KingdomFactionsPlugin.getInstance(), new Runnable() {
@Override
public void run() {
if(!player.hasPermission("kingdomfactions.deathban.ignore")) {
if(Setting.USE_DEATHBAN.isEnabled()) {
DeathBanModule.getInstance().ban(player);
}
}
}
}, 40L);
} else {
e.setDeathMessage(null);
}
// e.getEntity().spigot().respawn();
}
示例9: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
/**
* Handle player death
*
* @param event Event
*/
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
if (this.game.hasPlayer(event.getEntity()) && !this.game.isSpectator(event.getEntity()))
{
try
{
this.game.stumpPlayer(event.getEntity().getUniqueId(), false, false);
}
catch (GameException e)
{
this.game.getPlugin().getLogger().log(Level.SEVERE, "Error stumping player", e);
}
event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE));
event.setDeathMessage("");
if (event.getEntity().getKiller() != null)
event.getEntity().getKiller().addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 1));
new DeadCorpses(event.getEntity()).spawn(event.getEntity().getLocation());
if (deathSound)
GameUtils.broadcastSound(Sound.WITHER_SPAWN);
}
}
示例10: onDeathEvent
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeathEvent(PlayerDeathEvent e) {
Player p = e.getEntity();
if (ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Death-Message.Enable")) {
if (!ConfigGServerEvent.getConfig().getBoolean("Server.Disable.Death-Message.World.All_World")) {
if (WorldUtils.getWDM().contains(e.getEntity().getWorld().getName())) {
e.setDeathMessage(null);
}
} else {
e.setDeathMessage(null);
}
}
if (ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Clear-Drops-On-Death.Enable")) {
if (!ConfigGPlayerItems.getConfig().getBoolean("Server.Items.Clear-Drops-On-Death.World.All_World")) {
if (WorldUtils.getWClearOnDropsOnDeath().contains(e.getEntity().getWorld().getName())) {
if (ConfigGlobal.getConfig().getBoolean("Server.Items.Clear-Drops-On-Death.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.death.bypass.cleardrop")) {
if ((e.getEntity() instanceof Player)) {
e.getDrops().clear();
forceDelete(e);
}
}
} else {
if ((e.getEntity() instanceof Player)) {
e.getDrops().clear();
forceDelete(e);
}
}
}
} else {
if (ConfigGlobal.getConfig().getBoolean("Server.Items.Clear-Drops-On-Death.Bypass")) {
if (!p.hasPermission("ultimatespawn.event.death.bypass.cleardrop")) {
if ((e.getEntity() instanceof Player)) {
e.getDrops().clear();
forceDelete(e);
}
}
} else {
if ((e.getEntity() instanceof Player)) {
e.getDrops().clear();
forceDelete(e);
}
}
}
}
}
示例11: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDeath(final PlayerDeathEvent event) {
final String message = event.getDeathMessage();
if(message == null || message.isEmpty()) {
return;
}
event.setDeathMessage(getDeathMessage(message, event.getEntity(), this.getKiller(event)));
}
示例12: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerDeath(final PlayerDeathEvent event) {
final String message = event.getDeathMessage();
if(message == null || message.isEmpty()) {
return;
}
event.setDeathMessage(getDeathMessage(message, event.getEntity(), this.getKiller(event)));
}
示例13: playerDiedEvent
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void playerDiedEvent(final PlayerDeathEvent event) {
if (GameState.current() == GameState.LOBBY || GameState.current() == GameState.ENDED) {
return;
}
UHC.getInstance().getMainConfig().getDeathAction().handlePlayer(event.getEntity(), event.getDeathMessage());
long survivors = Bukkit.getServer().getOnlinePlayers().stream().filter(player -> player.getGameMode() != GameMode.SPECTATOR).count() - 1;
if (Bukkit.getServer().getOnlinePlayers().stream().allMatch(player -> player.getMetadata("wasAlive").isEmpty())) {
event.setDeathMessage(colour("&6First death: " + event.getDeathMessage() + "\n&bThere are " + survivors + " players left."));
} else {
event.setDeathMessage(colour("&e" + event.getDeathMessage() + "\n&bThere are " + survivors + " players left."));
}
if (survivors <= 1) {
Player winner = Bukkit.getServer().getOnlinePlayers().stream().filter(player -> player.getGameMode() != GameMode.SPECTATOR).findFirst().get();
GameState.ENDED.setCurrent();
onGameEnd(winner);
}
event.getEntity().setMetadata("wasAlive", new FixedMetadataValue(UHC.getInstance(), "true"));
event.getEntity().getWorld().strikeLightning(event.getEntity().getLocation());
event.getDrops().add(new PlayerheadItemStack(new ItemBuilder(Material.SKULL_ITEM).displayName(colour("&a" + event.getEntity().getName() + "'s head")).build(), false,
event.getEntity().getName()));
//TODO: Wait until the skull builder is in master to use that
}
示例14: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent event) {
event.setDeathMessage(null);
for (ItemStack i : event.getDrops()) {
i.setType(Material.AIR);
}
}
示例15: onVanillaDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onVanillaDeath(final PlayerDeathEvent event) {
event.setDeathMessage(null);
}