当前位置: 首页>>代码示例>>Java>>正文


Java HookHandler类代码示例

本文整理汇总了Java中net.canarymod.hook.HookHandler的典型用法代码示例。如果您正苦于以下问题:Java HookHandler类的具体用法?Java HookHandler怎么用?Java HookHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HookHandler类属于net.canarymod.hook包,在下文中一共展示了HookHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockPistonRetract

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority=Priority.PASSIVE, ignoreCanceled=true)
public void onBlockPistonRetract(PistonRetractHook event) {
    Block b = event.getPiston();
    Location loc = b.getLocation();
    String wn = getWorld(loc.getWorld()).getName();
    int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
    sscache.invalidateSnapshot(wn, x, y, z);
    if(onpiston)
        mapManager.touch(wn, x, y, z, "pistonretract");
    b = event.getMoving();
    if (b != null) {
        loc = b.getLocation();
        x = loc.getBlockX();
        y = loc.getBlockY();
        z = loc.getBlockZ();
        sscache.invalidateSnapshot(wn, x, y, z);
        if(onpiston)
            mapManager.touch(wn, x, y, z, "pistonretract");
    }
}
 
开发者ID:webbukkit,项目名称:DynmapCanary,代码行数:21,代码来源:DynmapPlugin.java

示例2: onBlockPistonExtend

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority=Priority.PASSIVE, ignoreCanceled=true)
public void onBlockPistonExtend(PistonExtendHook event) {
    Block b = event.getPiston();
    Location loc = b.getLocation();
    String wn = getWorld(loc.getWorld()).getName();
    int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
    sscache.invalidateSnapshot(wn, x, y, z);
    if(onpiston)
        mapManager.touch(wn, x, y, z, "pistonretract");
    b = event.getMoving();
    if (b != null) {
        loc = b.getLocation();
        x = loc.getBlockX();
        y = loc.getBlockY();
        z = loc.getBlockZ();
        sscache.invalidateSnapshot(wn, x, y, z);
        if(onpiston)
            mapManager.touch(wn, x, y, z, "pistonretract");
    }
}
 
开发者ID:webbukkit,项目名称:DynmapCanary,代码行数:21,代码来源:DynmapPlugin.java

示例3: onCommand

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onCommand(final ConsoleCommandHook hook) {
    String command = "";
    for (String s : hook.getCommand()) {
        command += s + " ";
    }
    server.getPluginManager().callEvent(new ServerCommandEvent(new CanaryCommandSender(hook.getCaller()), command) {
        @Override
        public void setCommand(String msg) {
            super.setCommand(msg);
            // Set command
        }
    });
    if (server.dispatchCommand(new CanaryCommandSender(hook.getCaller()), command)) {
        hook.setCanceled();
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:18,代码来源:CanaryServerListener.java

示例4: onServerListPing

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onServerListPing(final ServerListPingHook hook) {
    server.getPluginManager().callEvent(
            new ServerListPingEvent(hook.getRequesterAddress(), hook.getMotd().getFullText(), hook
                    .getCurrentPlayers(), hook.getMaxPlayers()) {
                @Override
                public void setMotd(String motd) {
                    super.setMotd(motd);
                    hook.setMotd(motd);
                }

                @Override
                public void setMaxPlayers(int maxPlayers) {
                    super.setMaxPlayers(maxPlayers);
                    hook.setMaxPlayers(maxPlayers);
                }

                @Override
                public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException,
                        UnsupportedOperationException {
                    super.setServerIcon(icon);
                }
            });
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:25,代码来源:CanaryServerListener.java

示例5: onCommand

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onCommand(final PlayerCommandHook hook) {
    String command = "";
    for (String s : hook.getCommand()) {
        command += s + " ";
    }
    PlayerCommandPreprocessEvent event =
            new PlayerCommandPreprocessEvent(new CanaryPlayer(hook.getPlayer()), command) {
                @Override
                public void setMessage(String msg) {
                    super.setMessage(msg);
                    // Set command
                }
            };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
    if (server.dispatchCommand(new CanaryCommandSender(hook.getPlayer()), command)) {
        hook.setCanceled(); //TODO: is this the best possible way?
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:24,代码来源:CanaryPlayerListener.java

示例6: onEnchant

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onEnchant(final EnchantHook hook) {
    EnchantItemEvent event = new EnchantItemEvent(new CanaryPlayer(hook.getPlayer()), null, new CanaryBlock(hook
            .getEnchantmentTable().getBlock()), null, 0, null, 0) {
        @Override
        public void setExpLevelCost(int level) {
            super.setExpLevelCost(level);
            // How can you do this in Canary?
        }
    };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
    // TODO: Fill in.
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:18,代码来源:CanaryPlayerListener.java

示例7: onTeleportation

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onTeleportation(final TeleportHook hook) {
    PlayerTeleportEvent event =
            new PlayerTeleportEvent(new CanaryPlayer(hook.getPlayer()), new CanaryLocation(hook.getPlayer()
                    .getLocation(), new CanaryWorld(hook.getDestination().getWorld())), new CanaryLocation(hook
                    .getDestination(), new CanaryWorld(hook.getDestination().getWorld())),
                    TeleportCauseConverter.of(hook.getTeleportReason())) {
                @Override
                public void setFrom(Location from) {
                    super.setFrom(from);
                    // How can you do this in Canary?
                }

                @Override
                public void setTo(Location to) {
                    super.setTo(to);
                    // How can you do this in Canary?
                }
            };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:26,代码来源:CanaryPlayerListener.java

示例8: onBlockPlace

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onBlockPlace(final BlockPlaceHook hook) {
    BlockPlaceEvent event = new BlockPlaceEvent(new CanaryBlock(hook.getBlockPlaced()), null, new CanaryBlock(hook
            .getBlockClicked()), null, new CanaryPlayer(hook.getPlayer()), true) {
        @Override
        public void setBuild(boolean canBuild) {
            super.setBuild(canBuild);
            // How can you do this in Canary?
        }
    };
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
    // TODO: Fill in and check some of the arguments.
}
 
开发者ID:CanaryBukkitTeam,项目名称:CanaryBukkit,代码行数:18,代码来源:CanaryBlockListener.java

示例9: onBlockDestroy

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onBlockDestroy(final BlockDestroyHook hook) {
    final Player player = hook.getPlayer();
    final Block block = hook.getBlock();

    if (!player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(block.getLocation());
        if (!zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.build.name());
            if (flag != null) {
                final boolean excluded = zownTree.getData().getConfiguration()
                        .hasBlockBuildExclusion(block.getType());
                if (flag) {
                    if (excluded) {
                        hook.setCanceled();
                    }
                } else {
                    if (!excluded) {
                        hook.setCanceled();
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:26,代码来源:ModifyWorldListener.java

示例10: onHangingEntityDestroy

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onHangingEntityDestroy(final HangingEntityDestroyHook hook) {
    final Player player = hook.getPlayer();
    final HangingEntity entity = hook.getPainting();

    if (player == null || !player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(entity.getLocation());
        if (player == null || !zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.build.name());
            if (flag != null) {
                final boolean excluded = zownTree.getData().getConfiguration()
                        .hasEntityCreateExclusion(entity.getClass());
                if (flag) {
                    if (excluded) {
                        hook.setCanceled();
                    }
                } else {
                    if (!excluded) {
                        hook.setCanceled();
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:26,代码来源:ModifyWorldListener.java

示例11: onItemUse

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onItemUse(final ItemUseHook hook) {
    final Player player = hook.getPlayer();
    final Block block = hook.getBlockClicked();

    if (!player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(block.getLocation());
        if (!zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.build.name());
            if (flag != null && !flag) {
                final ItemType type = hook.getItem().getType();
                if (type == ItemType.FlintAndSteel || type == ItemType.WaterBucket
                        || type == ItemType.LavaBucket || type == ItemType.Bonemeal) {
                    hook.setCanceled();
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:20,代码来源:ModifyWorldListener.java

示例12: onExplosion

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onExplosion(final ExplosionHook hook) {
    final List<Block> blocks = hook.getAffectedBlocks();

    final Entity cause = hook.getEntity();
    boolean isTnt = false;
    if (cause != null && cause.getEntityType() == EntityType.TNTMINECART && cause.getEntityType() == EntityType.TNTPRIMED) {
        isTnt = true;
    }

    for (final Block block : blocks) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(block.getLocation());
        final Boolean flag;
        if (isTnt) {
            flag = zownTree.getData().getConfiguration().getFlag(Flag.build.name());
        } else {
            flag = zownTree.getData().getConfiguration().getFlag(Flag.mobgrief.name());
        }
        if (flag != null && !flag) {
            hook.setCanceled();
            break;
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:25,代码来源:ModifyWorldListener.java

示例13: onItemFrameRotate

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onItemFrameRotate(final ItemFrameRotateHook hook) {
    final Player player = hook.getPlayer();
    final Entity entity = hook.getItemFrame();

    if (!player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(entity.getLocation());
        if (!zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.interact.name());
            if (flag != null) {
                final boolean excluded = zownTree.getData().getConfiguration()
                        .hasEntityInteractExclusion(entity.getClass());
                if (flag) {
                    if (excluded) {
                        hook.setCanceled();
                    }
                } else {
                    if (!excluded) {
                        hook.setCanceled();
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:26,代码来源:ModifyWorldListener.java

示例14: onItemFrameSetItem

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onItemFrameSetItem(final ItemFrameSetItemHook hook) {
    final Player player = hook.getPlayer();
    final Entity entity = hook.getItemFrame();

    if (!player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(entity.getLocation());
        if (!zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.interact.name());
            if (flag != null) {
                final boolean excluded = zownTree.getData().getConfiguration()
                        .hasEntityInteractExclusion(entity.getClass());
                if (flag) {
                    if (excluded) {
                        hook.setCanceled();
                    }
                } else {
                    if (!excluded) {
                        hook.setCanceled();
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:26,代码来源:ModifyWorldListener.java

示例15: onEntityRightClick

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onEntityRightClick(final EntityRightClickHook hook) {
    final Player player = hook.getPlayer();
    final Entity entity = hook.getEntity();

    if (!player.isOperator()) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(entity.getLocation());
        if (!zownTree.getData().isOwnerOrMember(player)) {
            final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.interact.name());
            if (flag != null) {
                final boolean excluded = zownTree.getData().getConfiguration()
                        .hasEntityInteractExclusion(entity.getClass());
                if (flag) {
                    if (excluded) {
                        hook.setCanceled();
                    }
                } else {
                    if (!excluded) {
                        hook.setCanceled();
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:26,代码来源:ModifyWorldListener.java


注:本文中的net.canarymod.hook.HookHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。