Search in sources :

Example 1 with CheckPermMessage

use of com.github.games647.changeskin.core.message.CheckPermMessage in project ChangeSkin by games647.

the class SharedBungeeListener method checkPermissions.

private void checkPermissions(P player, ByteArrayDataInput dataInput) {
    CheckPermMessage message = new CheckPermMessage();
    message.readFrom(dataInput);
    UUID receiverUUID = message.getReceiverUUD();
    boolean op = message.isOp();
    SkinModel targetSkin = message.getTargetSkin();
    UUID skinProfile = targetSkin.getProfileId();
    boolean success = op || checkBungeePerms(player, receiverUUID, message.isSkinPerm(), skinProfile);
    sendMessage(player, new PermResultMessage(success, targetSkin, receiverUUID));
}
Also used : CheckPermMessage(com.github.games647.changeskin.core.message.CheckPermMessage) PermResultMessage(com.github.games647.changeskin.core.message.PermResultMessage) UUID(java.util.UUID) SkinModel(com.github.games647.changeskin.core.model.skin.SkinModel)

Example 2 with CheckPermMessage

use of com.github.games647.changeskin.core.message.CheckPermMessage 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();
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) Server(net.md_5.bungee.api.connection.Server) CheckPermMessage(com.github.games647.changeskin.core.message.CheckPermMessage) UserPreference(com.github.games647.changeskin.core.model.UserPreference) UUID(java.util.UUID) ChannelMessage(com.github.games647.changeskin.core.message.ChannelMessage)

Aggregations

CheckPermMessage (com.github.games647.changeskin.core.message.CheckPermMessage)2 UUID (java.util.UUID)2 ChannelMessage (com.github.games647.changeskin.core.message.ChannelMessage)1 PermResultMessage (com.github.games647.changeskin.core.message.PermResultMessage)1 UserPreference (com.github.games647.changeskin.core.model.UserPreference)1 SkinModel (com.github.games647.changeskin.core.model.skin.SkinModel)1 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)1 Server (net.md_5.bungee.api.connection.Server)1