Java Code Examples for com.sk89q.worldedit.LocalSession#getTool()
The following examples show how to use
com.sk89q.worldedit.LocalSession#getTool() .
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: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { Location from = event.getFrom(); Location to = event.getTo(); if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getBlockX() != to.getBlockX() || from.getBlockZ() != to.getBlockZ() || from.getBlockY() != to.getBlockY()) { Player bukkitPlayer = event.getPlayer(); FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool != null) { if (tool instanceof MovableTool) { ((MovableTool) tool).move(player); } } } }
Example 2
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerInteract(final PlayerInteractEvent event) { Player bukkitPlayer = event.getPlayer(); if (bukkitPlayer.isSneaking()) { if (event.getAction() == Action.PHYSICAL) { return; } FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool instanceof ResettableTool) { if (((ResettableTool) tool).reset()) { event.setCancelled(true); } } } }
Example 3
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent event) { Location from = event.getFrom(); Location to = event.getTo(); if ((from.getYaw() != to.getYaw() && from.getPitch() != to.getPitch()) || from.getFloorX() != to.getFloorX() || from.getFloorZ() != to.getFloorZ() || from.getFloorY() != to.getFloorY()) { Player nukkitPlayer = event.getPlayer(); FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool != null) { if (tool instanceof MovableTool) { ((MovableTool) tool).move(player); } } } }
Example 4
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onPlayerInteract(final PlayerInteractEvent event) { Player nukkitPlayer = event.getPlayer(); if (nukkitPlayer.isSneaking()) { if (event.getAction() == PlayerInteractEvent.Action.PHYSICAL) { return; } FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool instanceof ResettableTool) { if (((ResettableTool) tool).reset()) { event.setCancelled(true); } } } }
Example 5
Source File: VisualQueue.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void operate(FawePlayer fp) { LocalSession session = fp.getSession(); Player player = fp.getPlayer(); Tool tool = session.getTool(player); Brush brush; if (tool instanceof BrushTool) { BrushTool brushTool = (BrushTool) tool; if (brushTool.getVisualMode() != VisualMode.NONE) { try { brushTool.visualize(BrushTool.BrushAction.PRIMARY, player); } catch (Throwable e) { WorldEdit.getInstance().getPlatformManager().handleThrowable(e, player); } } } }
Example 6
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) { final Player bukkitPlayer = event.getPlayer(); if (bukkitPlayer.isSneaking()) { return; } FawePlayer<Object> fp = FawePlayer.wrap(bukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool instanceof ScrollTool) { final int slot = event.getNewSlot(); final int oldSlot = event.getPreviousSlot(); final int ri; if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) { ri = 1; } else { ri = -1; } ScrollTool scrollable = (ScrollTool) tool; if (scrollable.increment(player, ri)) { if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) { bukkitPlayer.getInventory().setHeldItemSlot(oldSlot); } else { final PlayerInventory inv = bukkitPlayer.getInventory(); final ItemStack item = inv.getItem(slot); final ItemStack newItem = inv.getItem(oldSlot); inv.setItem(slot, newItem); inv.setItem(oldSlot, item); bukkitPlayer.updateInventory(); } } } }
Example 7
Source File: BrushListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerItemHoldEvent(final PlayerItemHeldEvent event) { Player nukkitPlayer = event.getPlayer(); if (nukkitPlayer.isSneaking()) { return; } FawePlayer<Object> fp = FawePlayer.wrap(nukkitPlayer); com.sk89q.worldedit.entity.Player player = fp.getPlayer(); LocalSession session = fp.getSession(); Tool tool = session.getTool(player); if (tool instanceof ScrollTool) { final int slot = event.getInventorySlot(); final int oldSlot = event.getSlot(); final int ri; if ((((slot - oldSlot) <= 4) && ((slot - oldSlot) > 0)) || (((slot - oldSlot) < -4))) { ri = 1; } else { ri = -1; } ScrollTool scrollable = (ScrollTool) tool; if (scrollable.increment(player, ri)) { final PlayerInventory inv = nukkitPlayer.getInventory(); final Item item = inv.getItem(slot); final Item newItem = inv.getItem(oldSlot); inv.setItem(slot, newItem); inv.setItem(oldSlot, item); inv.sendContents(nukkitPlayer); } } }