TenLives 插件

概述:
TenLives 是一款 Minecraft 插件,通过限制玩家的生命次数来增加生存挑战的趣味性。每次死亡都会减少玩家的最大生命值,如果生命值降至过低,玩家将面临严重后果,例如被切换到旁观者模式或被封禁。玩家可以通过特殊的自定义图腾来恢复生命。
功能特性:
-
死亡时减少生命值:
- 每次死亡会使玩家的最大生命值减少 2 点。
- 当玩家的最大生命值低于 1 点时,根据配置的不同,他们会被切换到旁观者模式或被封禁。
-
生命恢复:
- 玩家可以使用自定义图腾来恢复生命。
- 自定义图腾可以增加玩家的最大生命值 2 点,最高可达 20 点。
-
可自定义的消息:
-
图腾分发:
- 自定义图腾有 10% 的几率在储物矿车中找到。
- 拥有相应权限的玩家也可以通过
/gettotem 命令获得图腾。
-
命令:
/gettotem <nickname>:如果玩家拥有所需权限(tenlives.gettotem),则给予其一个自定义图腾。
-
占位符:
%tenlives_lives%:根据玩家当前的最大生命值显示其剩余的生命次数。
安装:
- 下载 TenLives 插件。
- 将下载的文件放入服务器的
plugins 目录中。
- 启动或重启服务器以加载插件。
- 在生成的
config.yml 文件中按需配置插件。
配置:
config.yml 文件允许服务器管理员自定义插件的各个方面,例如死亡时的消息和行为。
用法:
- 玩家初始拥有一定数量的默认生命次数。
- 每次死亡都会减少其最大生命值,必须使用自定义图腾才能恢复。
- 管理员可以使用
/gettotem 命令分发图腾。
指令:
/gettotem:若玩家拥有所需权限(tenlives.gettotem),则为其提供一个自定义图腾。
配置文件 (config.yml):
# TenLives 配置
death_action: "spectator" # 选项:'spectator'(旁观者模式)或 'ban'(封禁)
death_message: "&c你的生命值已耗尽..."
totem_name: "&6生命图腾"
totem_custom_model_data: 993
life_lost_title: "&c你失去了一条生命"
life_lost_subtitle: "&e小心一点,它们并非永恒"
life_restored_title: "&a1 条生命已恢复"
life_restored_subtitle: "&e请明智地使用它"
totem_received_message: "&a你获得了生命图腾!"
command_player_only: "&c只有玩家才能使用此命令。"
no_permission_message: "&c你没有权限执行此命令。"
指标数据:
- 本插件使用 bStats 收集匿名使用统计数据,以帮助改进插件。
代码解析
主类:TenLives
这是负责以下功能的主插件类:
- 启用和禁用插件。
- 管理事件和命令。
- 处理玩家死亡、重生以及与存储矿车的交互。
方法:
onEnable(): 初始化插件,加载配置文件,注册事件和命令,并设置指标数据。
onDisable(): 在插件禁用时进行清理工作。
onPlayerDeath(PlayerDeathEvent event): 处理玩家死亡事件并减少其最大生命值。
onPlayerRespawn(PlayerRespawnEvent event): 在玩家重生时提供反馈信息。
onEntityResurrect(EntityResurrectEvent event): 处理玩家重生事件,如果使用自定义图腾则恢复其生命值。
onPlayerInteractEntity(PlayerInteractEntityEvent event): 管理与存储矿车的交互,并将自定义图腾添加到玩家的物品栏中。
onCommand(CommandSender sender, Command command, String label, String[] args): 处理 /gettotem 命令。
createCustomTotem(): 创建自定义图腾物品。
isValidTotem(ItemStack item): 检查某物品是否为有效的自定义图腾。
占位符扩展:LivesPlaceholder
此类与 PlaceholderAPI 集成以提供自定义占位符。
方法:
getIdentifier(): 返回此占位符扩展的标识符。
getAuthor(): 返回此占位符扩展的作者。
getVersion(): 返回此占位符扩展的版本号。
onPlaceholderRequest(Player player, @NotNull String identifier): 处理占位符请求并返回 %tenlives_lives% 的相应值。
使用说明
- 在
config.yml 文件中自定义消息及其他设置。
- 确保玩家拥有使用
/gettotem 命令的相应权限。
- 监控玩家的生命值与互动情况,以确保插件按预期运行。
- 在支持的插件或消息格式中使用
%tenlives_lives% 占位符来显示玩家拥有的生命次数。
TenLives Plugin

Overview:
TenLives is a Minecraft plugin that adds an exciting survival challenge by limiting the number of lives a player has. Each death reduces the player's maximum health, and if it drops too low, the player faces severe consequences such as being switched to spectator mode or banned. Players can restore their lives using special custom totems.
Features:
Installation:
- Download the TenLives plugin.
- Place the downloaded file into your server's
plugins directory.
- Start or restart your server to load the plugin.
- Configure the plugin as needed in the generated
config.yml file.
Configuration:
- The
config.yml file allows server administrators to customize various aspects of the plugin, such as messages and actions on death.
Usage:
- Players start with a default number of lives.
- Each death reduces their maximum health, and they must use custom totems to restore it.
- Admins can distribute totems using the
/gettotem command.
Commands:
/gettotem: Gives the player a custom totem if they have the required permission (tenlives.gettotem).
Configuration File (config.yml):
# TenLives configuration
death_action: "spectator" # Options: 'spectator' or 'ban'
death_message: "&cВаши жизни закончились..."
totem_name: "&6Тотем Жизни"
totem_custom_model_data: 993
life_lost_title: "&cВы потеряли жизнь"
life_lost_subtitle: "&eБудь внимательнее, они не вечны"
life_restored_title: "&a1 Жизнь восстановлена"
life_restored_subtitle: "&eПотрать её с умом"
totem_received_message: "&aВы получили Тотем Жизни!"
command_player_only: "&cЭту команду может использовать только игрок."
no_permission_message: "&cУ вас нет прав на использование этой команды."
Metrics:
- This plugin uses bStats to collect anonymous usage statistics to help improve the plugin.
Code Breakdown
Main Class: TenLives
This is the main plugin class responsible for:
- Enabling and disabling the plugin.
- Managing events and commands.
- Handling player deaths, resurrections, and interactions with storage minecarts.
Methods:
onEnable(): Initializes the plugin, loads the configuration, registers events and commands, and sets up metrics.
onDisable(): Cleans up when the plugin is disabled.
onPlayerDeath(PlayerDeathEvent event): Handles player deaths and reduces their maximum health.
onPlayerRespawn(PlayerRespawnEvent event): Provides feedback to the player when they respawn.
onEntityResurrect(EntityResurrectEvent event): Handles player resurrections and restores their health if a custom totem is used.
onPlayerInteractEntity(PlayerInteractEntityEvent event): Manages interactions with storage minecarts and adds custom totems to their inventory.
onCommand(CommandSender sender, Command command, String label, String[] args): Handles the /gettotem command.
createCustomTotem(): Creates the custom totem item.
isValidTotem(ItemStack item): Checks if an item is a valid custom totem.
Placeholder Expansion: LivesPlaceholder
This class integrates with PlaceholderAPI to provide custom placeholders.
Methods:
getIdentifier(): Returns the identifier for this placeholder expansion.
getAuthor(): Returns the author of this placeholder expansion.
getVersion(): Returns the version of this placeholder expansion.
onPlaceholderRequest(Player player, @NotNull String identifier): Handles the placeholder request and returns the appropriate value for %tenlives_lives%.
Usage Notes
- Customize messages and other settings in the
config.yml file.
- Ensure players have the appropriate permissions to use the
/gettotem command.
- Monitor player health and interactions to ensure the plugin functions as expected.
- Use the
%tenlives_lives% placeholder in supported plugins or message formats to display the number of lives a player has.
评论 0
登录后参与评分
还没有评论,来抢沙发吧