Java 类org.bukkit.event.world.PortalCreateEvent 实例源码

项目:WorldGuardExtraFlagsPlugin    文件:EntityListener.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPortalCreateEvent(PortalCreateEvent event)
{
    for(Block block : event.getBlocks())
    {
        //Unable to get the player who created it....

        ApplicableRegionSet regions = WorldGuardExtraFlagsPlugin.getWorldGuardPlugin().getRegionContainer().createQuery().getApplicableRegions(block.getLocation());
        if (regions.queryValue(null, FlagUtils.NETHER_PORTALS) == State.DENY)
        {
            event.setCancelled(true);
            break;
        }
    }
}
项目:CanaryBukkit    文件:CanaryWorldListener.java   
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onPortalCreation(final PortalCreateHook hook) {
    PortalCreateEvent event = new PortalCreateEvent(null, new CanaryWorld(hook.getWorld()), null);
    event.setCancelled(hook.isCanceled());
    server.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        hook.setCanceled();
    }
}
项目:RedProtect    文件:RPPlayerListener.java   
@EventHandler
public void onPortalCreate(PortalCreateEvent e){   
    List<Block> blocks = e.getBlocks();
    for (Block b:blocks){
        Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
        if (r != null && !r.canCreatePortal()){
            e.setCancelled(true);
            break;
        }
    }       
}
项目:Bits    文件:ConfigurationManager.java   
private static HashMap<String, Class> getEventClassAssociations()
    {
        HashMap<String, Class> classHashMap = new HashMap<String, Class>();
        classHashMap.put("block-break", BlockBreakEvent.class);
        classHashMap.put("block-place", BlockPlaceEvent.class);

//      classHashMap.put("entity-leash", PlayerLeashEntityEvent.class);
        classHashMap.put("entity-kill", EntityDeathEvent.class);
        classHashMap.put("entity-shear", PlayerShearEntityEvent.class);

        classHashMap.put("item-brew", BrewEvent.class);
        classHashMap.put("item-enchant", EnchantItemEvent.class);
        classHashMap.put("item-furnace", FurnaceExtractEvent.class);

        classHashMap.put("painting-create", HangingPlaceEvent.class);

        classHashMap.put("player-regenerate", EntityRegainHealthEvent.class);
        classHashMap.put("player-shoot", EntityShootBowEvent.class);
        classHashMap.put("player-chat", AsyncPlayerChatEvent.class);
        classHashMap.put("player-death", PlayerDeathEvent.class);
        classHashMap.put("player-sleep", PlayerBedEnterEvent.class);
        classHashMap.put("player-author", PlayerEditBookEvent.class);
        classHashMap.put("player-egg", PlayerEggThrowEvent.class);
        classHashMap.put("player-fish", PlayerFishEvent.class);
        classHashMap.put("player-eat", PlayerItemConsumeEvent.class);
        classHashMap.put("player-join", PlayerJoinEvent.class);
        classHashMap.put("player-move", PlayerMoveEvent.class);

        classHashMap.put("portal-create", PortalCreateEvent.class);

        classHashMap.put("vehicle-move", VehicleMoveEvent.class);

        classHashMap.put("world-change", PlayerChangedWorldEvent.class);

        return classHashMap;
    }
项目:xEssentials-deprecated-bukkit    文件:DisablePortalCreationEvent.java   
@EventHandler
public void onCreatePortal(PortalCreateEvent e) {
    Block block = e.getBlocks().get(0);
    Player p = ExtractPlayerFromLocation(block.getLocation());
    if(p instanceof Player) {
        if(!p.hasPermission(PermissionKey.IS_ADMIN.getPermission())) {
            e.setCancelled(true);
            sendMessage(p, ChatColor.RED + "portal creation has been disabled on the server!");
        }
    }
}
项目:ProjectAres    文件:EventFilterMatchModule.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalCreate(final PortalCreateEvent event) {
    cancelAlways(event, event.getWorld());
}
项目:Arcade2    文件:GeneralListeners.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPortalCreate(PortalCreateEvent event) {
    event.setCancelled(true);
}
项目:civcraft    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.HIGHEST) 
public void onPortalCreate(PortalCreateEvent event) {
    event.setCancelled(true);
}
项目:Almura-Server    文件:BlockPortal.java   
public boolean o_(World world, int i, int j, int k) {
    byte b0 = 0;
    byte b1 = 0;

    if (world.getTypeId(i - 1, j, k) == Block.OBSIDIAN.id || world.getTypeId(i + 1, j, k) == Block.OBSIDIAN.id) {
        b0 = 1;
    }

    if (world.getTypeId(i, j, k - 1) == Block.OBSIDIAN.id || world.getTypeId(i, j, k + 1) == Block.OBSIDIAN.id) {
        b1 = 1;
    }

    if (b0 == b1) {
        return false;
    } else {
        // CraftBukkit start
        java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>();
        org.bukkit.World bworld = world.getWorld();
        // CraftBukkit end

        if (world.getTypeId(i - b0, j, k - b1) == 0) {
            i -= b0;
            k -= b1;
        }

        int l;
        int i1;

        for (l = -1; l <= 2; ++l) {
            for (i1 = -1; i1 <= 3; ++i1) {
                boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3;

                if (l != -1 && l != 2 || i1 != -1 && i1 != 3) {
                    int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l);

                    if (flag) {
                        if (j1 != Block.OBSIDIAN.id) {
                            return false;
                        } else { // CraftBukkit
                            blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l)); // CraftBukkit
                        }
                    } else if (j1 != 0 && j1 != Block.FIRE.id) {
                        return false;
                    }
                }
            }
        }

        // CraftBukkit start
        for (l = 0; l < 2; ++l) {
            for (i1 = 0; i1 < 3; ++i1) {
                blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l));
            }
        }

        PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        for (l = 0; l < 2; ++l) {
            for (i1 = 0; i1 < 3; ++i1) {
                world.setTypeIdAndData(i + b0 * l, j + i1, k + b1 * l, Block.PORTAL.id, 0, 2);
            }
        }

        return true;
    }
}
项目:BedrockAPI    文件:PortalCreateEvent.java   
public PortalCreateEvent(Collection<Block> blocks, World world, PortalCreateEvent.CreateReason reason) {
       super(world);
}
项目:BedrockAPI    文件:PortalCreateEvent.java   
public PortalCreateEvent.CreateReason getReason() {
    return null;
}
项目:xEssentials-deprecated-bukkit    文件:PortalSizeEvent.java   
@EventHandler
public void PortalSizeCheck(PortalCreateEvent e) {
    if(e.getBlocks().size() > 6) {
        e.setCancelled(true);
    }
}
项目:Craft-city    文件:BlockPortal.java   
public boolean n_(World world, int i, int j, int k) {
    byte b0 = 0;
    byte b1 = 0;

    if (world.getTypeId(i - 1, j, k) == Block.OBSIDIAN.id || world.getTypeId(i + 1, j, k) == Block.OBSIDIAN.id) {
        b0 = 1;
    }

    if (world.getTypeId(i, j, k - 1) == Block.OBSIDIAN.id || world.getTypeId(i, j, k + 1) == Block.OBSIDIAN.id) {
        b1 = 1;
    }

    if (b0 == b1) {
        return false;
    } else {
        // CraftBukkit start
        java.util.Collection<org.bukkit.block.Block> blocks = new java.util.HashSet<org.bukkit.block.Block>();
        org.bukkit.World bworld = world.getWorld();
        // CraftBukkit end

        if (world.getTypeId(i - b0, j, k - b1) == 0) {
            i -= b0;
            k -= b1;
        }

        int l;
        int i1;

        for (l = -1; l <= 2; ++l) {
            for (i1 = -1; i1 <= 3; ++i1) {
                boolean flag = l == -1 || l == 2 || i1 == -1 || i1 == 3;

                if (l != -1 && l != 2 || i1 != -1 && i1 != 3) {
                    int j1 = world.getTypeId(i + b0 * l, j + i1, k + b1 * l);

                    if (flag) {
                        if (j1 != Block.OBSIDIAN.id) {
                            return false;
                        } else { // CraftBukkit
                            blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l)); // CraftBukkit
                        }
                    } else if (j1 != 0 && j1 != Block.FIRE.id) {
                        return false;
                    }
                }
            }
        }

        // CraftBukkit start
        for (l = 0; l < 2; ++l) {
            for (i1 = 0; i1 < 3; ++i1) {
                blocks.add(bworld.getBlockAt(i + b0 * l, j + i1, k + b1 * l));
            }
        }

        PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return false;
        }
        // CraftBukkit end

        for (l = 0; l < 2; ++l) {
            for (i1 = 0; i1 < 3; ++i1) {
                world.setTypeIdAndData(i + b0 * l, j + i1, k + b1 * l, Block.PORTAL.id, 0, 2);
            }
        }

        return true;
    }
}