mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-24 19:46:21 +01:00
Implemented new broadcast method
This commit is contained in:
parent
db691ff5c8
commit
fe0cd5405b
@ -53,6 +53,7 @@ import net.minecraft.server.ItemStack;
|
|||||||
import net.minecraft.server.WorldMap;
|
import net.minecraft.server.WorldMap;
|
||||||
import net.minecraft.server.WorldMapCollection;
|
import net.minecraft.server.WorldMapCollection;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.permissions.Permissible;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.ServicesManager;
|
import org.bukkit.plugin.ServicesManager;
|
||||||
@ -226,13 +227,7 @@ public final class CraftServer implements Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int broadcastMessage(String message) {
|
public int broadcastMessage(String message) {
|
||||||
Player[] players = getOnlinePlayers();
|
return broadcast(message, BROADCAST_CHANNEL_USERS);
|
||||||
|
|
||||||
for (Player player : players) {
|
|
||||||
player.sendMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
return players.length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer(final EntityPlayer entity) {
|
public Player getPlayer(final EntityPlayer entity) {
|
||||||
@ -796,4 +791,19 @@ public final class CraftServer implements Server {
|
|||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
console.a();
|
console.a();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int broadcast(String message, String permission) {
|
||||||
|
int count = 0;
|
||||||
|
Set<Permissible> permissibles = getPluginManager().getPermissionSubscriptions(permission);
|
||||||
|
|
||||||
|
for (Permissible permissible : permissibles) {
|
||||||
|
if (permissible instanceof CommandSender) {
|
||||||
|
CommandSender user = (CommandSender)permissible;
|
||||||
|
user.sendMessage(message);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user