Permalink
Browse files

Add broadcast(message, array) console support

- Add broadcast(message, array('~console', ...)) support to target the console.
- Include broadcast to console behaviour in the documentation.
  • Loading branch information...
Pieter12345 committed Jun 27, 2018
1 parent 436a1fb commit 071371d3beb9b039e580018f66701963782db1a8
Showing with 15 additions and 8 deletions.
  1. +15 −8 src/main/java/com/laytonsmith/core/functions/Echoes.java
@@ -624,12 +624,15 @@ public String getName() {
@Override
public String docs() {
return "void {message, [permission] | message, [players]} Broadcasts a message to all or some players."
+ " If permission is given, only players with that permission will see the broadcast."
return "void {message, [permission] | message, [players]} Broadcasts a message to all or some players"
+ " and/or console."
+ " If permission is given, only players with that permission will see the broadcast. On Bukkit"
+ " servers, console will only receive the broadcast when permission is 'bukkit.broadcast'."
+ " If an array is given, only online players in the list will see the broadcast."
+ " Console will receive the broadcast only when the array contains case-insensitive '~console'."
+ " Offline players in the list will be ignored."
+ " If permission/players is null, all players will see the broadcast."
+ " Throws a CREFormatException when the given players array is associative.";
+ " If permission/players is null, all players and console will see the broadcast."
+ " Throws CREFormatException when the given players array is associative.";
}
@Override
@@ -670,10 +673,14 @@ public Construct exec(Target t, Environment env, Construct... args) throws Confi
// Get the player recipients from the array.
Set<MCCommandSender> recipients = new HashSet<>();
for(Construct p : array.asList()) {
try {
recipients.add(Static.GetPlayer(p, t));
} catch (CREPlayerOfflineException cre) {
// Ignore offline players.
if(p.val().equalsIgnoreCase("~console")) {
recipients.add(server.getConsole());
} else {
try {
recipients.add(Static.GetPlayer(p, t));
} catch (CREPlayerOfflineException cre) {
// Ignore offline players.
}
}
}

0 comments on commit 071371d

Please sign in to comment.