本文整理汇总了Java中org.bukkit.event.entity.PlayerDeathEvent.setKeepLevel方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerDeathEvent.setKeepLevel方法的具体用法?Java PlayerDeathEvent.setKeepLevel怎么用?Java PlayerDeathEvent.setKeepLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.PlayerDeathEvent
的用法示例。
在下文中一共展示了PlayerDeathEvent.setKeepLevel方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例3: 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);
}
}