set-max-health allows values below 1
bug
### Before Submitting
- [x] I have searched existing issues and confirmed this is not a duplicate.
### Minecraft Edition
Java Edition
### Server Version / Commit
cda8f19
### Operating System
Fedora 44
### Bug Description & Expected Behavior
When you tell a plugin to set a player's max health to a value below 1, it works. This causes the player to die the instant they join/respawn. In vanilla, it accepts a value below 1, but the player's health is capped at 1 instead.
### Steps to Reproduce
1. Set player's max health to 0 or below via a plugin. One has been attached. Use the command /no_hp
```rust
use pumpkin_plugin_api::{self, Context, Plugin, PluginMetadata, Server, command::{Command, CommandError}, commands::CommandHandler, permission::{Permission, PermissionDefault}};
struct CommandTesting;
impl Plugin for CommandTesting {
fn new() -> Self { CommandTesting }
fn metadata(&self) -> PluginMetadata {
PluginMetadata {
name: "Command Testing".into(),
version: env!("CARGO_PKG_VERSION").into(),
authors: vec!["FireAcidCow".into()],
description: "set player max health to 0".into(),
dependencies: vec![],
permissions: vec![]
}
}
fn on_load(&mut self, context: Context) -> pumpkin_plugin_api::Result<()> {
context.register_permission(&Permission {
node: "Command Testing:use".into(),
description: "Allows running /hello".into(),
default: PermissionDefault::Allow,
children: vec![],
})?;
let mut command = Command::new(&["no_hp".into(), "a".into()], "proof of concept for hp issue");
command = command.execute(Command1);
context.register_command(command, "Command Testing:use");
Ok(())
}
}
struct Command1;
impl CommandHandler for Command1 {
fn handle(&self,sender: pumpkin_plugin_api::command::CommandSender,_server: Server,_args: pumpkin_plugin_api::command::ConsumedArgs,) -> pumpkin_plugin_api::Result<i32, CommandError>
{
sender.as_player().unwrap().set_max_health(0.0);
Ok(1)
}
}
pumpkin_plugin_api::register_plugin!(CommandTesting);
```
0 条评论