Search in sources :

Example 1 with BukkitInventoryUpdateTask

use of com.viaversion.viaversion.bukkit.tasks.protocol1_12to1_11_1.BukkitInventoryUpdateTask in project ViaVersion by ViaVersion.

the class BukkitInventoryQuickMoveProvider method registerQuickMoveAction.

@Override
public boolean registerQuickMoveAction(short windowId, short slotId, short actionId, UserConnection userConnection) {
    if (!supported) {
        return false;
    }
    if (slotId < 0) {
        // clicked out of inv slot
        return false;
    }
    if (windowId == 0) {
        // This has almost definitely something to do with the offhand slot.
        if (slotId >= 36 && slotId <= 45) {
            int protocolId = Via.getAPI().getServerVersion().lowestSupportedVersion();
            // this seems to be working just fine.
            if (protocolId == ProtocolVersion.v1_8.getVersion()) {
                return false;
            }
        }
    }
    ProtocolInfo info = userConnection.getProtocolInfo();
    UUID uuid = info.getUuid();
    BukkitInventoryUpdateTask updateTask = updateTasks.get(uuid);
    final boolean registered = updateTask != null;
    if (!registered) {
        updateTask = new BukkitInventoryUpdateTask(this, uuid);
        updateTasks.put(uuid, updateTask);
    }
    // http://wiki.vg/index.php?title=Protocol&oldid=13223#Click_Window
    updateTask.addItem(windowId, slotId, actionId);
    if (!registered && Via.getPlatform().isPluginEnabled()) {
        Via.getPlatform().runSync(updateTask);
    }
    return true;
}
Also used : ProtocolInfo(com.viaversion.viaversion.api.connection.ProtocolInfo) UUID(java.util.UUID) BukkitInventoryUpdateTask(com.viaversion.viaversion.bukkit.tasks.protocol1_12to1_11_1.BukkitInventoryUpdateTask)

Aggregations

ProtocolInfo (com.viaversion.viaversion.api.connection.ProtocolInfo)1 BukkitInventoryUpdateTask (com.viaversion.viaversion.bukkit.tasks.protocol1_12to1_11_1.BukkitInventoryUpdateTask)1 UUID (java.util.UUID)1