Skip to content

Commit

Permalink
Add - announce to_console "Hello, Mr. Owner!"
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 10, 2013
1 parent b1fd492 commit ecc62e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
Expand Up @@ -215,7 +215,7 @@ public void registerCoreMembers() {

// <--[command]
// @Name Announce
// @Usage announce ["<text>"] (to_ops/to_flagged:<flag_name>) (format:<name>)
// @Usage announce ["<text>"] (to_ops/to_console/to_flagged:<flag_name>) (format:<name>)
// @Required 1
// @Stable stable
// @Short Announces a message for everyone online to read.
Expand All @@ -224,10 +224,11 @@ public void registerCoreMembers() {
// @Description
// Announce sends a raw message to players. Simply using announce with text will send
// the message to all online players. Specifing the 'to_ops' argument will narrow down the players
// in which the message is sent to ops only. Alternatively, using the 'to_flagged' value argument
// will send the message to players only if the specified flag does not equal true. Announce can also
// utilize a format script with the 'format' argument. See the format script-container for more
// information.
// in which the message is sent to ops only. Alternatively, using the 'to_flagged' argument
// will send the message to players only if the specified flag does not equal true. You can also
// use the 'to_console' argument to make it so it only shows in the server console. Announce
// can also utilize a format script with the 'format' argument. See the format script-container
// for more information.

// @Tags
// None
Expand All @@ -244,9 +245,13 @@ public void registerCoreMembers() {
// Use to easily send a message to all online ops.
// - announce to_ops '<player.name> requires help!'

// @Usage
// Use to send a message to just the console (Primarily for debugging / logging).
// - announce to_console 'Warning- <player.name> broke a mob spawner at location <player.location>'

// -->
registerCoreMember(AnnounceCommand.class,
"ANNOUNCE", "announce [\"<text>\"] (to_ops/to_flagged:<flag_name>) (format:<name>)", 1);
"ANNOUNCE", "announce [\"<text>\"] (to_ops/to_console/to_flagged:<flag_name>) (format:<name>)", 1);


// <--[command]
Expand Down
Expand Up @@ -39,7 +39,7 @@
*/
public class AnnounceCommand extends AbstractCommand {

enum AnnounceType { ALL, TO_OPS, TO_FLAGGED }
enum AnnounceType { ALL, TO_OPS, TO_FLAGGED, TO_CONSOLE }

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {
Expand All @@ -55,6 +55,10 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
&& arg.matches("to_ops"))
scriptEntry.addObject("type", AnnounceType.TO_OPS);

else if (!scriptEntry.hasObject("type")
&& arg.matches("to_console"))
scriptEntry.addObject("type", AnnounceType.TO_CONSOLE);

else if (!scriptEntry.hasObject("type")
&& arg.matchesPrefix("to_flagged")) {
scriptEntry.addObject("type", AnnounceType.TO_FLAGGED);
Expand Down Expand Up @@ -112,6 +116,10 @@ else if (type == AnnounceType.TO_FLAGGED) {
player.sendMessage(message);
}
}

else if (type == AnnounceType.TO_CONSOLE) {
Bukkit.getServer().getConsoleSender().sendMessage(message);
}
}

}
Expand Down

0 comments on commit ecc62e7

Please sign in to comment.