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.
- Loading branch information
Showing
6 changed files
with
222 additions
and
5 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
64 changes: 64 additions & 0 deletions
64
src/main/java/com/denizenscript/denizen2sponge/commands/entity/DefuseCommand.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,64 @@ | ||
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.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.EntityTag; | ||
import org.spongepowered.api.entity.explosive.FusedExplosive; | ||
|
||
public class DefuseCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name defuse | ||
// @Arguments <entity> | ||
// @Short defuses an explosive entity. | ||
// @Updated 2018/01/10 | ||
// @Group Entity | ||
// @Minimum 1 | ||
// @Maximum 1 | ||
// @Description | ||
// Defuses an explosive entity. Inverse of <@link command prime>prime<@/link>. | ||
// @Example | ||
// # This example defuses the creeper the player is looking at. | ||
// - defuse <player.target_entities[type:creeper].get[1]> | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "defuse"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<entity>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
EntityTag ent = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
try { | ||
((FusedExplosive) ent.getInternal()).defuse(); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Defusing entity: " + ColorSet.emphasis + ent.debug() + ColorSet.good + "!"); | ||
} | ||
} | ||
catch (ClassCastException e) { | ||
queue.handleError("This entity is not an explosive, so it can't be defused!"); | ||
} | ||
catch (IllegalStateException e) { | ||
queue.handleError("This explosive entity is not primed!"); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/main/java/com/denizenscript/denizen2sponge/commands/entity/DetonateCommand.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.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.EntityTag; | ||
import org.spongepowered.api.entity.explosive.Explosive; | ||
|
||
public class DetonateCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name detonate | ||
// @Arguments <entity> | ||
// @Short instantly detonates an explosive entity. | ||
// @Updated 2018/01/10 | ||
// @Group Entity | ||
// @Minimum 1 | ||
// @Maximum 1 | ||
// @Description | ||
// Instantly detonates an explosive entity. | ||
// @Example | ||
// # This example detonates the creeper the player is looking at. | ||
// - detonate <player.target_entities[type:creeper].get[1]> | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "detonate"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<entity>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
EntityTag ent = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
try { | ||
((Explosive) ent.getInternal()).detonate(); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Detonating entity: " + ColorSet.emphasis + ent.debug() + ColorSet.good + "!"); | ||
} | ||
} | ||
catch (ClassCastException e) { | ||
queue.handleError("This entity is not an explosive, so it can't be detonated!"); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/com/denizenscript/denizen2sponge/commands/entity/PrimeCommand.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,64 @@ | ||
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.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.EntityTag; | ||
import org.spongepowered.api.entity.explosive.FusedExplosive; | ||
|
||
public class PrimeCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name prime | ||
// @Arguments <entity> | ||
// @Short primes an explosive entity. | ||
// @Updated 2018/01/10 | ||
// @Group Entity | ||
// @Minimum 1 | ||
// @Maximum 1 | ||
// @Description | ||
// Primes an explosive entity. Inverse of <@link command defuse>defuse<@/link>. | ||
// @Example | ||
// # This example primes the creeper the player is looking at. | ||
// - prime <player.target_entities[type:creeper].get[1]> | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "prime"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<entity>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
EntityTag ent = EntityTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
try { | ||
((FusedExplosive) ent.getInternal()).prime(); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Priming entity: " + ColorSet.emphasis + ent.debug() + ColorSet.good + "!"); | ||
} | ||
} | ||
catch (ClassCastException e) { | ||
queue.handleError("This entity is not an explosive, so it can't be primed!"); | ||
} | ||
catch (IllegalStateException e) { | ||
queue.handleError("This explosive entity is already primed!"); | ||
} | ||
} | ||
} |
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