Package org.spout.vanilla.event.player

Examples of org.spout.vanilla.event.player.PlayerHeldItemChangeEvent


    Player player = session.getPlayer();
    QuickbarInventory quickbar = PlayerUtil.getQuickbar(session.getPlayer());
    if (quickbar == null) {
      return;
    }
    PlayerHeldItemChangeEvent event = new PlayerHeldItemChangeEvent(player, quickbar.getSelectedSlot().getIndex(), newSlot);
    if (player.getEngine().getEventManager().callEvent(event).isCancelled()) {
      // Reset
      player.getNetwork().callProtocolEvent(new PlayerSelectedSlotChangeEvent(session.getPlayer(), event.getPreviousSlot()), player);
    } else {
      quickbar.setSelectedSlot(event.getNewSlot());
      quickbar.updateHeldItem(player);
      // Changed slot by event handler
      if (newSlot != event.getNewSlot()) {
        player.getNetwork().callProtocolEvent(new PlayerSelectedSlotChangeEvent(session.getPlayer(), event.getNewSlot()), player);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.vanilla.event.player.PlayerHeldItemChangeEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.