Skip to content

Commit

Permalink
Add support for "listed" attribute in character commands
Browse files Browse the repository at this point in the history
Introduce new commands to set and reset the "listed" attribute for PlayerCharacter instances. This extends character customization options and ensures consistent handling of the "listed" state.
  • Loading branch information
NonSwag committed Jan 24, 2025
1 parent ff90cf0 commit dd0aebf
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import net.thenextlvl.character.Character;
import net.thenextlvl.character.PlayerCharacter;
import net.thenextlvl.character.plugin.CharacterPlugin;
import net.thenextlvl.character.plugin.command.argument.NamedTextColorArgument;
import org.jspecify.annotations.NullMarked;
Expand All @@ -33,6 +34,7 @@ private static LiteralArgumentBuilder<CommandSourceStack> reset(CharacterPlugin
.then(resetColliding(plugin))
.then(resetGlowing(plugin))
.then(resetGravity(plugin))
.then(resetListed(plugin))
.then(resetPathfinding(plugin))
.then(resetScale(plugin))
.then(resetTeamColor(plugin))
Expand All @@ -45,6 +47,7 @@ private static LiteralArgumentBuilder<CommandSourceStack> set(CharacterPlugin pl
.then(setColliding(plugin))
.then(setGlowing(plugin))
.then(setGravity(plugin))
.then(setListed(plugin))
.then(setPathfinding(plugin))
.then(setScale(plugin))
.then(setTeamColor(plugin))
Expand Down Expand Up @@ -95,6 +98,10 @@ private static boolean set(CommandContext<CommandSourceStack> context, String at
return reset("gravity", character -> character.setGravity(false), Character::hasGravity, plugin);
}

private static ArgumentBuilder<CommandSourceStack, ?> resetListed(CharacterPlugin plugin) {
return reset("listed", c -> c instanceof PlayerCharacter p && p.setListed(false), Character::hasGravity, plugin);
}

private static ArgumentBuilder<CommandSourceStack, ?> resetPathfinding(CharacterPlugin plugin) {
return reset("pathfinding", character -> character.setPathfinding(false), Character::isPathfinding, plugin);
}
Expand Down Expand Up @@ -127,6 +134,10 @@ private static boolean set(CommandContext<CommandSourceStack> context, String at
return attribute("gravity", Character::setGravity, plugin);
}

private static ArgumentBuilder<CommandSourceStack, ?> setListed(CharacterPlugin plugin) {
return attribute("listed", (c, b) -> c instanceof PlayerCharacter p && p.setListed(b), plugin);
}

private static ArgumentBuilder<CommandSourceStack, ?> setPathfinding(CharacterPlugin plugin) {
return attribute("pathfinding", Character::setPathfinding, plugin);
}
Expand Down

0 comments on commit dd0aebf

Please sign in to comment.