本文整理汇总了Java中com.sk89q.worldedit.LocalSession.getTool方法的典型用法代码示例。如果您正苦于以下问题:Java LocalSession.getTool方法的具体用法?Java LocalSession.getTool怎么用?Java LocalSession.getTool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.LocalSession
的用法示例。
在下文中一共展示了LocalSession.getTool方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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);
}
}
}
}
示例2: onPlayerInteract
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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);
}
}
}
}
示例3: onPlayerMove
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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);
}
}
}
}
示例4: onPlayerInteract
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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);
}
}
}
}
示例5: onPlayerItemHoldEvent
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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();
}
}
}
}
示例6: onPlayerItemHoldEvent
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
@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);
}
}
}
示例7: VisualQueue
import com.sk89q.worldedit.LocalSession; //导入方法依赖的package包/类
public VisualQueue() {
playerMap = new ConcurrentHashMap<>();
Runnable task = new Runnable() {
@Override
public void run() {
long allowedTick = Fawe.get().getTimer().getTick() - 1;
Iterator<Map.Entry<FawePlayer, Long>> iter = playerMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<FawePlayer, Long> entry = iter.next();
Long time = entry.getValue();
if (time < allowedTick) {
FawePlayer fp = entry.getKey();
iter.remove();
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);
}
}
}
}
}
TaskManager.IMP.laterAsync(this, 3);
}
};
TaskManager.IMP.laterAsync(task, 3);
}