use of cn.nukkit.permission.Permissible in project LuckPerms by lucko.
the class InjectorSubscriptionMap method inject.
private LPSubscriptionMap inject() throws Exception {
Objects.requireNonNull(PERM_SUBS_FIELD, "PERM_SUBS_FIELD");
PluginManager pluginManager = this.plugin.getBootstrap().getServer().getPluginManager();
Object map = PERM_SUBS_FIELD.get(pluginManager);
if (map instanceof LPSubscriptionMap) {
if (((LPSubscriptionMap) map).plugin == this.plugin) {
return null;
}
map = ((LPSubscriptionMap) map).detach();
}
// noinspection unchecked
Map<String, Set<Permissible>> castedMap = (Map<String, Set<Permissible>>) map;
// make a new subscription map & inject it
LPSubscriptionMap newMap = new LPSubscriptionMap(this.plugin, castedMap);
PERM_SUBS_FIELD.set(pluginManager, newMap);
return newMap;
}
use of cn.nukkit.permission.Permissible in project Nukkit by Nukkit.
the class Command method broadcastCommandMessage.
public static void broadcastCommandMessage(CommandSender source, TextContainer message, boolean sendToSource) {
TextContainer m = message.clone();
String resultStr = "[" + source.getName() + ": " + (!m.getText().equals(source.getServer().getLanguage().get(m.getText())) ? "%" : "") + m.getText() + "]";
Set<Permissible> users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
String coloredStr = TextFormat.GRAY + "" + TextFormat.ITALIC + resultStr;
m.setText(resultStr);
TextContainer result = m.clone();
m.setText(coloredStr);
TextContainer colored = m.clone();
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
source.sendMessage(message);
}
for (Permissible user : users) {
if (user instanceof CommandSender) {
if (user instanceof ConsoleCommandSender) {
((ConsoleCommandSender) user).sendMessage(result);
} else if (!user.equals(source)) {
((CommandSender) user).sendMessage(colored);
}
}
}
}
use of cn.nukkit.permission.Permissible in project Nukkit by Nukkit.
the class Command method broadcastCommandMessage.
public static void broadcastCommandMessage(CommandSender source, String message, boolean sendToSource) {
Set<Permissible> users = source.getServer().getPluginManager().getPermissionSubscriptions(Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
TranslationContainer result = new TranslationContainer("chat.type.admin", new String[] { source.getName(), message });
TranslationContainer colored = new TranslationContainer(TextFormat.GRAY + "" + TextFormat.ITALIC + "%chat.type.admin", new String[] { source.getName(), message });
if (sendToSource && !(source instanceof ConsoleCommandSender)) {
source.sendMessage(message);
}
for (Permissible user : users) {
if (user instanceof CommandSender) {
if (user instanceof ConsoleCommandSender) {
((ConsoleCommandSender) user).sendMessage(result);
} else if (!user.equals(source)) {
((CommandSender) user).sendMessage(colored);
}
}
}
}
Aggregations