mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 03:52:45 +01:00
Added new Server.broadcast method to broadcast to specific groups of users, including non-players
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
f4545766e3
commit
2ba705febc
4 changed files with 30 additions and 2 deletions
|
@ -219,4 +219,8 @@ public final class Bukkit {
|
|||
public static void shutdown() {
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
public int broadcast(String message, String permission) {
|
||||
return server.broadcast(message, permission);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,19 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||
* Represents a server implementation
|
||||
*/
|
||||
public interface Server {
|
||||
/**
|
||||
* Used for all administrative messages, such as an operator using a command.
|
||||
*
|
||||
* For use in {@link #broadcast(java.lang.String, java.lang.String)}
|
||||
*/
|
||||
public static final String BROADCAST_CHANNEL_ADMINISTRATIVE = "bukkit.broadcast.admin";
|
||||
|
||||
/**
|
||||
* Used for all announcement messages, such as informing users that a player has joined.
|
||||
*
|
||||
* For use in {@link #broadcast(java.lang.String, java.lang.String)}
|
||||
*/
|
||||
public static final String BROADCAST_CHANNEL_USERS = "bukkit.broadcast.user";
|
||||
|
||||
/**
|
||||
* Gets the name of this server implementation
|
||||
|
@ -103,6 +116,8 @@ public interface Server {
|
|||
/**
|
||||
* Broadcast a message to all players.
|
||||
*
|
||||
* This is the same as calling {@link #broadcast(java.lang.String, java.lang.String)} to {@link #BROADCAST_CHANNEL_USERS}
|
||||
*
|
||||
* @param message the message
|
||||
* @return the number of players
|
||||
*/
|
||||
|
@ -351,4 +366,13 @@ public interface Server {
|
|||
* Shutdowns the server, stopping everything.
|
||||
*/
|
||||
public void shutdown();
|
||||
|
||||
/**
|
||||
* Broadcasts the specified message to every user with the given permission
|
||||
*
|
||||
* @param message Message to broadcast
|
||||
* @param permission Permission the users must have to receive the broadcast
|
||||
* @return Amount of users who received the message
|
||||
*/
|
||||
public int broadcast(String message, String permission);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.bukkit.util.permissions;
|
|||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
|
||||
public class CommandPermissions {
|
||||
public final class CommandPermissions {
|
||||
private static final String ROOT = "bukkit.command";
|
||||
private static final String PREFIX = ROOT + ".";
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bukkit.util.permissions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
@ -77,6 +76,7 @@ public final class DefaultPermissions {
|
|||
Permission parent = registerPermission(ROOT, "Gives the user the ability to use all Craftbukkit utilities and commands");
|
||||
|
||||
CommandPermissions.registerPermissions(parent);
|
||||
BroadcastPermissions.registerPermissions(parent);
|
||||
|
||||
parent.recalculatePermissibles();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue