org.bukkit.event.player.PlayerSwapHandItemsEvent Java Examples
The following examples show how to use
org.bukkit.event.player.PlayerSwapHandItemsEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Player19Listener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { Player player = event.getPlayer(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() == GameState.WAITING || (game.getCycle() instanceof BungeeGameCycle && game.getCycle().isEndGameRunning() && BedwarsRel.getInstance().getBooleanConfig("bungeecord.endgame-in-lobby", true))) { event.setCancelled(true); return; } }
Example #2
Source File: SwapHandListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void playerSwapHand(PlayerSwapHandItemsEvent event) { GameMap gMap = MatchManager.get().getPlayerMap(event.getPlayer()); if (gMap == null) { ItemStack item = event.getOffHandItem(); if (item.equals(SkyWarsReloaded.getIM().getItem("optionselect")) || item.equals(SkyWarsReloaded.getIM().getItem("joinselect")) || item.equals(SkyWarsReloaded.getIM().getItem("spectateselect"))) { event.setCancelled(true); } } else { if (gMap.getMatchState().equals(MatchState.WAITINGSTART) || gMap.getMatchState().equals(MatchState.ENDING)) { event.setCancelled(true); } } }
Example #3
Source File: Player19Listener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { Player player = event.getPlayer(); if (Main.isPlayerInGame(player)) { GamePlayer gPlayer = Main.getPlayerGameProfile(player); if (gPlayer.getGame().getStatus() == GameStatus.WAITING) { event.setCancelled(true); } } }
Example #4
Source File: ListenerShortcutSwapHand.java From TrMenu with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void offHand(PlayerSwapHandItemsEvent e) { boolean opened = TrMenuAPI.openByShortcut(e.getPlayer(), (e.getPlayer().isSneaking() ? TrMenu.SETTINGS.getString("SHORTCUT-OPEN.SNEAKING-OFFHAND", null) : TrMenu.SETTINGS.getString("SHORTCUT-OPEN.OFFHAND", null))); if (opened) { e.setCancelled(true); } }
Example #5
Source File: Player19Listener.java From BedWars with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { Player player = event.getPlayer(); if (Main.isPlayerInGame(player)) { GamePlayer gPlayer = Main.getPlayerGameProfile(player); if (gPlayer.getGame().getStatus() == GameStatus.WAITING) { event.setCancelled(true); } } }
Example #6
Source File: DurabilityBar.java From AdditionsAPI with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void onHandSwitch(PlayerSwapHandItemsEvent event) { if (event.isCancelled()) return; sendDurabilityBossBar(event.getPlayer(), event.getMainHandItem(), EquipmentSlot.HAND); sendDurabilityBossBar(event.getPlayer(), event.getOffHandItem(), EquipmentSlot.OFF_HAND); }
Example #7
Source File: ClickListenerOffhand.java From TabooLib with MIT License | 4 votes |
@EventHandler public void onSwap(PlayerSwapHandItemsEvent e) { if (e.getPlayer().getOpenInventory().getTopInventory().getHolder() instanceof MenuHolder && ((MenuHolder) e.getPlayer().getOpenInventory().getTopInventory().getHolder()).getBuilder().isLockHand()) { e.setCancelled(true); } }
Example #8
Source File: CustomBookOverlayListener.java From CS-CoreLib with GNU General Public License v3.0 | 4 votes |
@EventHandler public void onDrop(PlayerSwapHandItemsEvent e) { if (CustomBookOverlay.opening.contains(e.getPlayer().getUniqueId())) e.setCancelled(true); }
Example #9
Source File: PlayerListener19.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) { if (listenerService.shouldCancelEvent(event)) { event.setCancelled(true); } }
Example #10
Source File: PlayerListener19Test.java From AuthMeReloaded with GNU General Public License v3.0 | 4 votes |
@Test public void shouldCancelEvent() { withServiceMock(listenerService) .check(listener::onPlayerSwapHandItems, PlayerSwapHandItemsEvent.class); }