use of net.md_5.bungee.api.connection.ProxiedPlayer in project ChangeSkin by games647.
the class MessageListener method onPluginMessage.
@EventHandler
public void onPluginMessage(PluginMessageEvent messageEvent) {
String channel = messageEvent.getTag();
if (messageEvent.isCancelled() || !plugin.getName().equals(channel)) {
return;
}
ByteArrayDataInput dataInput = ByteStreams.newDataInput(messageEvent.getData());
String subChannel = dataInput.readUTF();
ProxiedPlayer invoker = (ProxiedPlayer) messageEvent.getReceiver();
if ("PermissionResult".equals(subChannel)) {
PermResultMessage message = new PermResultMessage();
message.readFrom(dataInput);
if (message.isAllowed()) {
onPermissionSuccess(message, invoker);
} else {
plugin.sendMessage(invoker, "no-permission");
}
} else if ("ForwardCmd".equals(subChannel)) {
onCommandForward(invoker, dataInput);
}
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project ChangeSkin by games647.
the class SkinApplier method run.
@Override
public void run() {
if (!isConnected()) {
return;
}
UUID receiverUUID = receiver.getUniqueId();
if (invoker instanceof ProxiedPlayer) {
if (targetSkin != null && core.getConfig().getBoolean("bukkit-permissions")) {
Server server = ((ProxiedPlayer) invoker).getServer();
boolean skinPerm = core.getConfig().getBoolean("skinPermission");
ChannelMessage message = new CheckPermMessage(targetSkin, receiverUUID, skinPerm, bukkitOp);
plugin.sendPluginMessage(server, message);
return;
}
// uuid was successful resolved, we could now make a cooldown check
core.getCooldownService().trackPlayer(((ProxiedPlayer) invoker).getUniqueId());
}
// check if that specific player is online
UserPreference preferences = plugin.getLoginSession(receiver.getPendingConnection());
if (preferences == null) {
preferences = plugin.getStorage().getPreferences(receiverUUID);
}
save(preferences);
applySkin();
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project ChangeSkin by games647.
the class InvalidateCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
boolean isOp = sender.getGroups().contains(plugin.getName() + "-OP");
if (sender instanceof ProxiedPlayer) {
sender.removeGroups(plugin.getName() + "-OP");
}
if (args.length > 0) {
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(args[0]);
if (targetPlayer == null) {
plugin.sendMessage(sender, "not-online");
return;
}
String permPrefix = plugin.getName().toLowerCase() + ".command.skinupdate.other.";
if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId()) && !sender.hasPermission(permPrefix + '*')) {
plugin.sendMessage(sender, "no-permission-other");
return;
}
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, targetPlayer, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
return;
}
if (!(sender instanceof ProxiedPlayer)) {
plugin.sendMessage(sender, "no-console");
return;
}
ProxiedPlayer receiver = (ProxiedPlayer) sender;
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, receiver, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
}
use of net.md_5.bungee.api.connection.ProxiedPlayer in project Bukkit_Bungee_PluginLib by GeorgH93.
the class ChatSenderTest method testSend.
@Test
public void testSend() {
List<ProxiedPlayer> players = new ArrayList<>();
players.add(TestObjects.getPlayer());
players.add(TestObjects.getPlayer());
int sendCalls = 0;
int playerCount = players.size();
ChatSender chatSender = new ChatSender();
chatSender.doSend(TestObjects.getPlayer(), "");
verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
chatSender.doSend(TestObjects.getPlayer(), "", 1);
verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
ChatSender.send(TestObjects.getPlayer(), new Message(""));
verify(TestObjects.getPlayer().unsafe(), times(++sendCalls)).sendPacket(any(Chat.class));
chatSender.doSend(players, "");
sendCalls += playerCount;
verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
chatSender.doSend(players, "", 1);
sendCalls += playerCount;
verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
ChatSender.send(players, new Message(""));
sendCalls += playerCount;
verify(TestObjects.getPlayer().unsafe(), times(sendCalls)).sendPacket(any(Chat.class));
}
Aggregations