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


Java PlayerDeathEvent.setKeepLevel方法代码示例

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

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

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


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