@EventHandler(priority=EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
String playerName = player.getName();
ProtectedItemsSnapshot protectedItemsSnapshot = playerItemSnapshots.get(playerName);
// if we have an inventory snapshot for this player
if (protectedItemsSnapshot != null) {
// merge the snapshot into the player's inventory, dropping overflow items at the respawn location
protectedItemsSnapshot.mergeIntoPlayerInventory(player, event.getRespawnLocation());
if (protectedItemsSnapshot.hasNonEmptyItems()) {
player.sendMessage("[" + ChatColor.GREEN + "DropProtect" + ChatColor.RESET + "] Inventory restored. Type /dropprotect for details.");
}
// remove the snapshot since it has now been applied
playerItemSnapshots.remove(playerName);
}
}
EntityDeathRespawnListener.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:Bukkit-DropProtect
作者:
评论列表
文章目录