-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP rewrite, add helper for `glow` and `invisible` * `perPlayerMap` -> `packetOverrides` * Prefix isn't required for enum args (`state:`) * Update meta * Remove `state:` tab-complete * `applyByteFlag` -> `applyEntityDataFlag`, imports * Slight cleanup/opti * Optimize `setForPlayers` modification checking * Minor code cleanup * Use `Predicate` instead of `Function<X, Boolean>` * Fix `isGlowing` (only need the bukkit method) * Move `EntityMetadataCommandHelper` to `utilities` * Move `GlowCommand` to `entity` package + group * Lowercase `state` argument default value * Fix `invisible` command syntax meta
- Loading branch information
Showing
12 changed files
with
289 additions
and
451 deletions.
There are no files selected for viewing
8 changes: 0 additions & 8 deletions
8
...c/main/java/com/denizenscript/denizen/nms/interfaces/packets/PacketOutEntityMetadata.java
This file was deleted.
Oops, something went wrong.
82 changes: 82 additions & 0 deletions
82
plugin/src/main/java/com/denizenscript/denizen/scripts/commands/entity/GlowCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.denizenscript.denizen.scripts.commands.entity; | ||
|
||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.entity.EntityMetadataCommandHelper; | ||
import com.denizenscript.denizencore.scripts.ScriptEntry; | ||
import com.denizenscript.denizencore.scripts.commands.AbstractCommand; | ||
import com.denizenscript.denizencore.scripts.commands.generator.*; | ||
import net.citizensnpcs.api.npc.NPC; | ||
import org.bukkit.entity.Entity; | ||
|
||
import java.util.List; | ||
|
||
public class GlowCommand extends AbstractCommand { | ||
|
||
public static final EntityMetadataCommandHelper helper = new EntityMetadataCommandHelper(Entity::isGlowing, GlowCommand::setGlowing); | ||
|
||
public GlowCommand() { | ||
setName("glow"); | ||
setSyntax("glow (<entity>|...) ({true}/false/toggle/reset) (for:<player>|...)"); | ||
setRequiredArguments(0, 3); | ||
isProcedural = false; | ||
autoCompile(); | ||
} | ||
|
||
// <--[command] | ||
// @Name Glow | ||
// @Syntax glow (<entity>|...) ({true}/false/toggle/reset) (for:<player>|...) | ||
// @Required 0 | ||
// @Maximum 3 | ||
// @Short Sets whether an NPC or entity is glowing. | ||
// @Group entity | ||
// | ||
// @Description | ||
// Sets whether the specified entities glow, defaults to the linked player/NPC if none were specified. | ||
// | ||
// Optionally specify 'for:' with a list of players to fake the entities' glow state for these players. | ||
// When using 'toggle' with the 'for:' argument, the glow state will be toggled for each player separately. | ||
// If unspecified, will be set globally. | ||
// 'for:' players remain tracked even when offline/reconnecting, but are forgotten after server restart. | ||
// | ||
// When not using 'for:', the glow is global / on the real entity, which will persist in that entity's data until changed. | ||
// | ||
// To reset an entity's fake glow use the 'reset' state. | ||
// A reset is global by default, use the 'for:' argument to reset specific players. | ||
// | ||
// @Tags | ||
// <EntityTag.glowing> | ||
// | ||
// @Usage | ||
// Use to make the linked player (or NPC, if there isn't one) glow. | ||
// - glow | ||
// | ||
// @Usage | ||
// Use to toggle whether the linked NPC is glowing. | ||
// - glow <npc> toggle | ||
// | ||
// @Usage | ||
// Use to make an entity glow for specific players, without changing the way other players see it. | ||
// - glow <[entity]> for:<[player1]>|<[player2]> | ||
// | ||
// @Usage | ||
// Use to reset an entity's fake glow state for the linked player. | ||
// - glow <[entity]> reset for:<player> | ||
// --> | ||
|
||
public static void setGlowing(EntityTag entity, boolean glowing) { | ||
if (entity.isCitizensNPC()) { | ||
entity.getDenizenNPC().getCitizen().data().setPersistent(NPC.Metadata.GLOWING, glowing); | ||
} | ||
else { | ||
entity.getBukkitEntity().setGlowing(glowing); | ||
} | ||
} | ||
|
||
public static void autoExecute(ScriptEntry scriptEntry, | ||
@ArgName("target") @ArgLinear @ArgDefaultNull @ArgSubType(EntityTag.class) List<EntityTag> targets, | ||
@ArgName("state") @ArgDefaultText("true") EntityMetadataCommandHelper.Action action, | ||
@ArgName("for") @ArgPrefixed @ArgDefaultNull @ArgSubType(PlayerTag.class) List<PlayerTag> forPlayers) { | ||
helper.execute(scriptEntry, targets, action, forPlayers); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.