Skip to content

Commit

Permalink
part one of command format modernization
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 14, 2020
1 parent 7f9353e commit d24778b
Show file tree
Hide file tree
Showing 39 changed files with 268 additions and 84 deletions.
Expand Up @@ -12,15 +12,19 @@
import com.denizenscript.denizencore.scripts.ScriptEntry;
import com.denizenscript.denizencore.scripts.commands.AbstractCommand;

/**
* <p>Sets a 'cooldown' period on a script. Can be per-player or globally.</p>
*/
public class CooldownCommand extends AbstractCommand {

public CooldownCommand() {
setName("cooldown");
setSyntax("cooldown [<duration>] (global) (script:<script>)");
setRequiredArguments(1, 3);
}

// <--[command]
// @Name Cooldown
// @Syntax cooldown [<duration>] (global) (script:<script>)
// @Required 1
// @Maximum 3
// @Short Temporarily disables a script-container from meeting requirements.
// @Group core
//
Expand Down
Expand Up @@ -21,10 +21,17 @@

public class FlagCommand extends AbstractCommand implements Listener {

public FlagCommand() {
setName("flag");
setSyntax("flag ({player}/npc/server/<entity>) [<name>([<#>])](:<action>)[:<value>] (duration:<value>)");
setRequiredArguments(1, 3);
}

// <--[command]
// @Name Flag
// @Syntax flag ({player}/npc/server/<entity>) [<name>([<#>])](:<action>)[:<value>] (duration:<value>)
// @Required 1
// @Maximum 3
// @Short Sets or modifies a flag on the player, NPC, entity, or server.
// @Group core
// @Guide https://guide.denizenscript.com/guides/basics/flags.html
Expand Down Expand Up @@ -256,7 +263,6 @@ else if (flagArgs[1].equals("//") || flagArgs[1].equals("/")) {
scriptEntry.defaultObject("flag_target", Utilities.getEntryPlayer(scriptEntry));
}

// Check required arguments
if (!scriptEntry.hasObject("action")) {
throw new InvalidArgumentsException("Must specify a flag action or value.");
}
Expand Down
Expand Up @@ -12,10 +12,17 @@

public class NoteCommand extends AbstractCommand {

public NoteCommand() {
setName("note");
setSyntax("note [<Notable ObjectTag>/remove] [as:<name>]");
setRequiredArguments(2, 2);
}

// <--[command]
// @Name Note
// @Syntax note [<Notable ObjectTag>/remove] [as:<name>]
// @Required 2
// @Maximum 2
// @Short Adds or removes a notable object.
// @Group core
// @Guide https://guide.denizenscript.com/guides/advanced/notables.html
Expand Down
Expand Up @@ -14,10 +14,17 @@

public class ResetCommand extends AbstractCommand {

public ResetCommand() {
setName("reset");
setSyntax("reset (<player>|...) [cooldown/saves/global_cooldown] (<script>)");
setRequiredArguments(1, 3);
}

// <--[command]
// @Name Reset
// @Syntax reset (<player>|...) [cooldown/saves/global_cooldown] (<script>)
// @Required 1
// @Maximum 3
// @Short Resets various parts of Denizen's save data, including a script's cooldowns or general player saves.
// @Group core
//
Expand Down
Expand Up @@ -18,10 +18,17 @@

public class ZapCommand extends AbstractCommand implements Listener {

public ZapCommand() {
setName("zap");
setSyntax("zap (<script>) [<step>] (<duration>)");
setRequiredArguments(0, 3);
}

// <--[command]
// @Name Zap
// @Syntax zap (<script>) [<step>] (<duration>)
// @Required 0
// @Maximum 3
// @Short Changes the current interact script step.
// @Group core
// @Guide https://guide.denizenscript.com/guides/npcs/interact-scripts.html
Expand Down Expand Up @@ -51,7 +58,7 @@ public class ZapCommand extends AbstractCommand implements Listener {
// - zap 3 Interact_Example
//
// @Usage
// Use to change the step to 1 for player bob in a script called InteractScript.
// Use to change the step to 1 for the defined player in a script called InteractScript.
// - zap 1 InteractScript player:<[player]>
// -->

Expand Down
Expand Up @@ -55,7 +55,6 @@ public class CastCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Iterate through arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("remove")
Expand Down
Expand Up @@ -55,7 +55,6 @@ public class FollowCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Parse Arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {
if (!scriptEntry.hasObject("stop") &&
arg.matches("stop")) {
Expand Down
Expand Up @@ -83,7 +83,6 @@ else if (arg.matchesArgumentType(ItemTag.class)
}
}

// Check required args
if (!scriptEntry.hasObject("item")) {
throw new InvalidArgumentsException("Must specify an item to display.");
}
Expand Down
Expand Up @@ -51,7 +51,6 @@ private enum Action {SET, REMOVE}
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Parse Arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (arg.matchesEnum(Action.values())
Expand All @@ -74,7 +73,6 @@ else if (arg.matchesArgumentType(ScriptTag.class)
}
}

// Check required arguments
if (!Utilities.entryHasNPC(scriptEntry)) {
throw new InvalidArgumentsException("NPC linked was missing or invalid.");
}
Expand Down
Expand Up @@ -69,7 +69,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
throw new InvalidArgumentsException("This command requires a linked NPC!");
}

// Parse arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("duration")
Expand Down
Expand Up @@ -49,7 +49,6 @@ public class LookcloseCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Parse Arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (arg.matches("realistic", "realistically")) {
Expand Down
Expand Up @@ -53,7 +53,6 @@ private enum Action {ADD, REMOVE, ASSUME}
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Parse Arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (arg.matches("add", "assume", "remove")) {
Expand Down
Expand Up @@ -68,7 +68,6 @@ public class ShowFakeCommand extends AbstractCommand {
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Iterate through arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (!scriptEntry.hasObject("players")
Expand Down
Expand Up @@ -18,10 +18,17 @@

public class AnnounceCommand extends AbstractCommand {

public AnnounceCommand() {
setName("announce");
setSyntax("announce [<text>] (to_ops/to_console/to_flagged:<flag_name>) (format:<name>)");
setRequiredArguments(1, 3);
}

// <--[command]
// @Name Announce
// @Syntax announce [<text>] (to_ops/to_console/to_flagged:<flag_name>) (format:<name>)
// @Required 1
// @Maximum 3
// @Short Announces a message for everyone online to read.
// @Group server
//
Expand Down
Expand Up @@ -17,10 +17,17 @@

public class BanCommand extends AbstractCommand {

public BanCommand() {
setName("ban");
setSyntax("ban ({add}/remove) [<player>|.../addresses:<address>|...] (reason:<text>) (duration:<duration>) (source:<text>)");
setRequiredArguments(1, 5);
}

// <--[command]
// @Name Ban
// @Syntax ban ({add}/remove) [<player>|.../addresses:<address>|...] (reason:<text>) (duration:<duration>) (source:<text>)
// @Required 1
// @Maximum 5
// @Short Ban or un-ban players or ip addresses.
// @Group server
//
Expand Down
Expand Up @@ -23,10 +23,17 @@

public class BossBarCommand extends AbstractCommand {

public BossBarCommand() {
setName("bossbar");
setSyntax("bossbar ({create}/update/remove) [<id>] (players:<player>|...) (title:<title>) (progress:<#.#>) (color:<color>) (style:<style>) (flags:<flag>|...)");
setRequiredArguments(1, 8);
}

// <--[command]
// @Name BossBar
// @Syntax bossbar ({create}/update/remove) [<id>] (players:<player>|...) (title:<title>) (progress:<#.#>) (color:<color>) (style:<style>) (flags:<flag>|...)
// @Required 1
// @Maximum 8
// @Short Shows players a boss bar.
// @Group server
//
Expand Down Expand Up @@ -57,7 +64,7 @@ public class BossBarCommand extends AbstractCommand {
//
// @Usage
// Remove a player from the boss bar.
// - bossbar remove MyMessageID players:<server.match_player[joe]>
// - bossbar remove MyMessageID players:<[player]>
//
// @Usage
// Delete the boss bar.
Expand Down
Expand Up @@ -25,10 +25,17 @@

public class ExecuteCommand extends AbstractCommand {

public ExecuteCommand() {
setName("execute");
setSyntax("execute [as_player/as_op/as_npc/as_server] [<Bukkit-command>] (silent)");
setRequiredArguments(2, 3);
}

// <--[command]
// @Name Execute
// @Syntax execute [as_player/as_op/as_npc/as_server] [<Bukkit-command>] (silent)
// @Required 2
// @Maximum 3
// @Short Executes an arbitrary server command as if the player, NPC, or server typed it in.
// @Group server
//
Expand Down Expand Up @@ -64,7 +71,6 @@ enum Type {AS_SERVER, AS_NPC, AS_PLAYER, AS_OP}
@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

// Parse arguments
for (Argument arg : scriptEntry.getProcessedArgs()) {

if (arg.matches("asplayer", "as_player")
Expand Down
Expand Up @@ -21,10 +21,17 @@

public class ScoreboardCommand extends AbstractCommand {

public ScoreboardCommand() {
setName("scoreboard");
setSyntax("scoreboard ({add}/remove) (viewers:<player>|...) (lines:<player>/<text>|...) (id:<value>/{main}) (objective:<value>) (criteria:<criteria>/{dummy}) (score:<#>) (displayslot:<value>/{sidebar}/none) (displayname:<name>)");
setRequiredArguments(1, 9);
}

// <--[command]
// @Name Scoreboard
// @Syntax scoreboard ({add}/remove) (viewers:<player>|...) (lines:<player>/<text>|...) (id:<value>/{main}) (objective:<value>) (criteria:<criteria>/{dummy}) (score:<#>) (displayslot:<value>/{sidebar}/none) (displayname:<name>)
// @Required 1
// @Maximum 9
// @Short Add or removes viewers, objectives and scores from scoreboards.
// @Group server
//
Expand Down Expand Up @@ -67,7 +74,7 @@ public class ScoreboardCommand extends AbstractCommand {
// <server.scoreboard[(<board>)].team[<team>].members>
//
// @Usage
// Add a score for the player "joe" to the default scoreboard under the objective "cookies" and let him see it
// Add a score for the defined player to the default scoreboard under the objective "cookies" and let him see it
// - scoreboard add obj:cookies lines:joe score:1000 viewers:<[aplayer]>
//
// @Usage
Expand All @@ -91,7 +98,7 @@ public class ScoreboardCommand extends AbstractCommand {
// - scoreboard remove viewers:<[aplayer]>
//
// @Usage
// Make the player "bob" see the health of other players below their names
// Make the defined player see the health of other players below their names
// - scoreboard add viewers:<[player]> id:test obj:anything criteria:health displayslot:below_name
//
// @Usage
Expand Down
Expand Up @@ -17,10 +17,17 @@

public class AdjustBlockCommand extends AbstractCommand {

public AdjustBlockCommand() {
setName("adjustblock");
setSyntax("adjustblock [<location>|...] [<mechanism>](:<value>)");
setRequiredArguments(2, 2);
}

// <--[command]
// @Name AdjustBlock
// @Syntax adjustblock [<location>|...] [<mechanism>](:<value>)
// @Required 2
// @Maximum 2
// @Short Adjusts a mechanism on the material of a block at the location.
// @Group core
// @Guide https://guide.denizenscript.com/guides/basics/mechanisms.html
Expand Down
Expand Up @@ -21,10 +21,17 @@

public class AnimateChestCommand extends AbstractCommand {

public AnimateChestCommand() {
setName("animatechest");
setSyntax("animatechest [<location>] ({open}/close) (sound:{true}/false) (<player>|...)");
setRequiredArguments(1, 4);
}

// <--[command]
// @Name AnimateChest
// @Syntax animatechest [<location>] ({open}/close) (sound:{true}/false) (<player>|...)
// @Required 1
// @Maximum 4
// @Short Makes a chest appear to open or close.
// @Group world
//
Expand Down
Expand Up @@ -27,10 +27,22 @@

public class ChunkLoadCommand extends AbstractCommand implements Listener {

public ChunkLoadCommand() {
setName("chunkload");
setSyntax("chunkload ({add}/remove/removeall) [<chunk>] (duration:<value>)");
setRequiredArguments(1, 3);
Denizen denizen = DenizenAPI.getCurrentInstance();
denizen.getServer().getPluginManager().registerEvents(this, denizen);
if (Depends.citizens != null) {
denizen.getServer().getPluginManager().registerEvents(new ChunkLoadCommandNPCEvents(), denizen);
}
}

// <--[command]
// @Name ChunkLoad
// @Syntax chunkload ({add}/remove/removeall) [<chunk>] (duration:<value>)
// @Required 1
// @Maximum 3
// @Short Keeps a chunk actively loaded and allowing activity.
// @Group world
//
Expand Down Expand Up @@ -62,15 +74,6 @@ public class ChunkLoadCommand extends AbstractCommand implements Listener {
// - chunkload removeall
// -->

@Override
public void onEnable() {
Denizen denizen = DenizenAPI.getCurrentInstance();
denizen.getServer().getPluginManager().registerEvents(this, denizen);
if (Depends.citizens != null) {
denizen.getServer().getPluginManager().registerEvents(new ChunkLoadCommandNPCEvents(), denizen);
}
}

/*
* Keeps a chunk loaded
*/
Expand Down

0 comments on commit d24778b

Please sign in to comment.