• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HookHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: onConnection

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler
public void onConnection(final ConnectionHook hook)
        throws DatabaseReadException, DatabaseWriteException {
    final Player player = hook.getPlayer();
    final World world = player.getWorld();
    final Location toLoc = player.getLocation();

    new WorldEnterHook(player, world, null, toLoc).call();

    if (hook.isFirstConnection()) {
        if (config.exactSpawn()) {
            player.teleportTo(Canary.getServer().getDefaultWorld().getSpawnLocation());
        }
    }

    connectingPlayers.add(player.getUUIDString());
}
 
开发者ID:toddharrison,项目名称:PlayerState,代码行数:18,代码来源:PlayerStatePlugin.java


示例17: onWorldExit

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler
public void onWorldExit(final WorldExitHook hook) throws DatabaseWriteException {
    final Player player = hook.getPlayer();
    final String fromState = getState(hook.getFromLocation().getWorld());
    String toState = null;
    if (hook.getToLocation() != null) {
        toState = getState(hook.getToLocation().getWorld());
    }

    player.message(ChatFormat.GRAY + "Exited world " + hook.getWorld().getName());

    if (!fromState.equals(toState)) {
        manager.savePlayerState(player, fromState, getSaves(fromState));
        player.message(ChatFormat.GOLD + "Saved state " + fromState);
    }
}
 
开发者ID:toddharrison,项目名称:PlayerState,代码行数:17,代码来源:PlayerStatePlugin.java


示例18: onWorldUnload

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority=Priority.PASSIVE, ignoreCanceled=true)
public void onWorldUnload(UnloadWorldHook event) {
    CanaryModWorld w = getWorld(event.getWorld());
    if(w != null) {
        core.listenerManager.processWorldEvent(EventType.WORLD_UNLOAD, w);
        w.setWorldUnloaded();
        core.processWorldUnload(w);
    }
}
 
开发者ID:webbukkit,项目名称:DynmapCanary,代码行数:10,代码来源:DynmapPlugin.java


示例19: onChunkPopulate

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority=Priority.PASSIVE, ignoreCanceled=true)
public void onChunkPopulate(ChunkCreatedHook event) {
    Chunk c = event.getChunk();
    int maxy = 0;
    int[] hmap = c.getHeightMap();
    int[] hmap2 = c.getPrecipitationHeightMap();
    for (int i = 0; i < hmap.length; i++) {
        if (hmap[i] > maxy) maxy = hmap[i];
        if (hmap2[i] > maxy) maxy = hmap2[i];
    }
    /* Touch extreme corners */
    int x = c.getX() << 4;
    int z = c.getZ() << 4;
    mapManager.touchVolume(getWorld(event.getWorld()).getName(), x, 0, z, x+15, maxy, z+16, "chunkpopulate");
}
 
开发者ID:webbukkit,项目名称:DynmapCanary,代码行数:16,代码来源:DynmapPlugin.java


示例20: onEntityExplode

import net.canarymod.hook.HookHandler; //导入依赖的package包/类
@HookHandler(priority=Priority.PASSIVE, ignoreCanceled=true)
public void onEntityExplode(ExplosionHook event) {
    Location loc = event.getBlock().getLocation();
    String wname = getWorld(loc.getWorld()).getName();
    int minx, maxx, miny, maxy, minz, maxz;
    minx = maxx = loc.getBlockX();
    miny = maxy = loc.getBlockY();
    minz = maxz = loc.getBlockZ();
    /* Calculate volume impacted by explosion */
    List<Block> blocks = event.getAffectedBlocks();
    for(Block b: blocks) {
        Location l = b.getLocation();
        int x = l.getBlockX();
        if(x < minx) minx = x;
        if(x > maxx) maxx = x;
        int y = l.getBlockY();
        if(y < miny) miny = y;
        if(y > maxy) maxy = y;
        int z = l.getBlockZ();
        if(z < minz) minz = z;
        if(z > maxz) maxz = z;
    }
    sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
    if(onexplosion) {
        mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "entityexplode");
    }
}
 
开发者ID:webbukkit,项目名称:DynmapCanary,代码行数:28,代码来源:DynmapPlugin.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JARArchive类代码示例发布时间:2022-05-22
下一篇:
Java SMILLayoutElement类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap