This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also fixed Drop command definition
- Loading branch information
Showing
4 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/denizenscript/denizen2sponge/commands/entity/InvisibleCommand.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,61 @@ | ||
package com.denizenscript.denizen2sponge.commands.entity; | ||
|
||
import com.denizenscript.denizen2core.commands.AbstractCommand; | ||
import com.denizenscript.denizen2core.commands.CommandEntry; | ||
import com.denizenscript.denizen2core.commands.CommandQueue; | ||
import com.denizenscript.denizen2core.tags.objects.BooleanTag; | ||
import com.denizenscript.denizen2core.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.EntityTag; | ||
import org.spongepowered.api.data.key.Keys; | ||
|
||
public class InvisibleCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name invisible | ||
// @Arguments <entity> <state> | ||
// @Short changes the invisibility state of an entity. | ||
// @Updated 2018/02/11 | ||
// @Group Entity | ||
// @Minimum 2 | ||
// @Maximum 2 | ||
// @Description | ||
// Changes the invisibility state of an entity. Invisible entities can't be seen, | ||
// but update packets are still sent to the server and clients. | ||
// Related commands: <@link command vanish>vanish<@/link>. | ||
// @Example | ||
// # Makes the player invisible. | ||
// - invisible <player> true | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "invisible"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<entity> <state>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
EntityTag entity = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
BooleanTag state = BooleanTag.getFor(queue.error, entry.getArgumentObject(queue, 1)); | ||
entity.getInternal().offer(Keys.INVISIBLE, state.getInternal()); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Setting invisible state of entity '" + ColorSet.emphasis + entity.debug() | ||
+ ColorSet.good + "' to '" + ColorSet.emphasis + state.debug() + ColorSet.good + "'!"); | ||
} | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/com/denizenscript/denizen2sponge/commands/entity/VanishCommand.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,75 @@ | ||
package com.denizenscript.denizen2sponge.commands.entity; | ||
|
||
import com.denizenscript.denizen2core.commands.AbstractCommand; | ||
import com.denizenscript.denizen2core.commands.CommandEntry; | ||
import com.denizenscript.denizen2core.commands.CommandQueue; | ||
import com.denizenscript.denizen2core.tags.objects.BooleanTag; | ||
import com.denizenscript.denizen2core.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.EntityTag; | ||
import org.spongepowered.api.data.key.Keys; | ||
import org.spongepowered.api.entity.Entity; | ||
|
||
public class VanishCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name vanish | ||
// @Arguments <entity> <state> | ||
// @Short changes the vanish state of an entity. | ||
// @Updated 2018/02/11 | ||
// @Group Entity | ||
// @Minimum 2 | ||
// @Maximum 2 | ||
// @Named ignore_collisions (BooleanTag) Sets whether this vanished entity can collide with other entities. | ||
// @Named untargeteable (BooleanTag) Sets whether this vanished entity can be selected as a target. | ||
// @Description | ||
// Changes the vanish state of an entity. Vanished entities don't send packets to clients, | ||
// but they can still affect collisions or target selection server-side. This can be adjusted | ||
// with the "ignore_collisions" and "untargeteable" named arguments. | ||
// but update packets are still sent to the server and clients. | ||
// Related commands: <@link command invisible>invisible<@/link>. | ||
// @Example | ||
// # Vanishes the player and makes it untargeteable and uncollidable. | ||
// - vanish <player> true --ignore_collisions true --untargeteable true | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "vanish"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<entity> <state>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
EntityTag entityTag = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
BooleanTag state = BooleanTag.getFor(queue.error, entry.getArgumentObject(queue, 1)); | ||
Entity entity = entityTag.getInternal(); | ||
entity.offer(Keys.VANISH, state.getInternal()); | ||
if (entry.namedArgs.containsKey("ignore_collisions")) { | ||
BooleanTag bt = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "ignore_collisions")); | ||
entity.offer(Keys.VANISH_IGNORES_COLLISION, bt.getInternal()); | ||
} | ||
if (entry.namedArgs.containsKey("untargeteable")) { | ||
BooleanTag bt = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "untargeteable")); | ||
entity.offer(Keys.VANISH_PREVENTS_TARGETING, bt.getInternal()); | ||
} | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Setting vanish state of entity '" + ColorSet.emphasis + entityTag.debug() | ||
+ ColorSet.good + "' to '" + ColorSet.emphasis + state.debug() + ColorSet.good + "'!"); | ||
} | ||
} | ||
} |