當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.PORTAL屬性代碼示例

本文整理匯總了Java中org.bukkit.Material.PORTAL屬性的典型用法代碼示例。如果您正苦於以下問題:Java Material.PORTAL屬性的具體用法?Java Material.PORTAL怎麽用?Java Material.PORTAL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.PORTAL屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPortalDestroy

@EventHandler
public void onPortalDestroy(BlockBreakEvent e) {
	if (e.getBlock() == null)
		return;
	if(e.getBlock().getType() == Material.PORTAL) {
		if(!e.getPlayer().isOp()) {
			e.setCancelled(true);
		}
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:10,代碼來源:PortalTravelEventListener.java

示例2: onBlockPlace

/**
 * Prevent portal trap
 *
 * @param event Event
 */
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
    if(!this.game.isGameStarted() || !this.game.hasPlayer(event.getPlayer()))
    {
        event.setCancelled(true);
        return;
    }

    boolean flag = false;

    if(event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(1.0D, 0.0D, 0.0D)).getType() == Material.PORTAL)
        flag = true;

    if(event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().subtract(1.0D, 0.0D, 0.0D)).getType() == Material.PORTAL)
        flag = true;

    if(event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().add(0.0D, 0.0D, 1.0D)).getType() == Material.PORTAL)
        flag = true;

    if(event.getBlock().getWorld().getBlockAt(event.getBlock().getLocation().subtract(0.0D, 0.0D, 1.0D)).getType() == Material.PORTAL)
        flag = true;

    if(flag)
    {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "Vous ne pouvez pas placer de bloc ici !");
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:34,代碼來源:SecurityListener.java

示例3: onClick

@EventHandler
public void onClick(PlayerInteractEvent e){
    if(e.getClickedBlock() == null) return;
    if(HCF.getPlugin().getFactionManager().getFactionAt(e.getClickedBlock().getLocation()).isSafezone()) return;
    if(e.getClickedBlock().getType() == Material.PORTAL){
        e.getClickedBlock().setType(Material.AIR);
        e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',"&eYou have &cdisabled &ethis portal&e."));
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:9,代碼來源:PortalTrapFixListener.java

示例4: checkLocation

public static void checkLocation(Player p) {
    if (p.getWorld().equals(instance.world) && p.getLocation().getBlock().getType() == Material.PORTAL) {
        instance.warp(p);
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:5,代碼來源:WorldBossManager.java

示例5: isSafeLocation

/**
 * Checks if this location is safe for a player to teleport to. Used by
 * warps and boat exits Unsafe is any liquid or air and also if there's no
 * space
 *
 * @param l
 *            - Location to be checked
 * @return true if safe, otherwise false
 */
public static boolean isSafeLocation(final Location l) {
    if (l == null) {
        return false;
    }
    // TODO: improve the safe location finding.
    //Bukkit.getLogger().info("DEBUG: " + l.toString());
    final Block ground = l.getBlock().getRelative(BlockFace.DOWN);
    final Block space1 = l.getBlock();
    final Block space2 = l.getBlock().getRelative(BlockFace.UP);
    //Bukkit.getLogger().info("DEBUG: ground = " + ground.getType());
    //Bukkit.getLogger().info("DEBUG: space 1 = " + space1.getType());
    //Bukkit.getLogger().info("DEBUG: space 2 = " + space2.getType());
    // Portals are not "safe"
    if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
            || space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
        return false;
    }
    // If ground is AIR, then this is either not good, or they are on slab,
    // stair, etc.
    if (ground.getType() == Material.AIR) {
        // Bukkit.getLogger().info("DEBUG: air");
        return false;
    }
    // In BSkyBlock, liquid may be unsafe
    if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
        // Check if acid has no damage
        if (Settings.acidDamage > 0D) {
            // Bukkit.getLogger().info("DEBUG: acid");
            return false;
        } else if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
                || space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
                || space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
            // Lava check only
            // Bukkit.getLogger().info("DEBUG: lava");
            return false;
        }
    }
    MaterialData md = ground.getState().getData();
    if (md instanceof SimpleAttachableMaterialData) {
        //Bukkit.getLogger().info("DEBUG: trapdoor/button/tripwire hook etc.");
        if (md instanceof TrapDoor) {
            TrapDoor trapDoor = (TrapDoor)md;
            if (trapDoor.isOpen()) {
                //Bukkit.getLogger().info("DEBUG: trapdoor open");
                return false;
            }
        } else {
            return false;
        }
        //Bukkit.getLogger().info("DEBUG: trapdoor closed");
    }
    if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().equals(Material.FENCE)
            || ground.getType().equals(Material.NETHER_FENCE) || ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
        // Bukkit.getLogger().info("DEBUG: cactus");
        return false;
    }
    // Check that the space is not solid
    // The isSolid function is not fully accurate (yet) so we have to
    // check
    // a few other items
    // isSolid thinks that PLATEs and SIGNS are solid, but they are not
    if (space1.getType().isSolid() && !space1.getType().equals(Material.SIGN_POST) && !space1.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    if (space2.getType().isSolid()&& !space2.getType().equals(Material.SIGN_POST) && !space2.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    // Safe
    //Bukkit.getLogger().info("DEBUG: safe!");
    return true;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:80,代碼來源:IslandsManager.java

示例6: isSafeLocation

/**
 * Checks if this location is safe for a player to teleport to. Used by
 * warps and boat exits Unsafe is any liquid or air and also if there's no
 * space
 * 
 * @param l
 *            - Location to be checked
 * @return true if safe, otherwise false
 */
public static boolean isSafeLocation(final Location l) {
    if (l == null) {
        return false;
    }
    // TODO: improve the safe location finding.
    //Bukkit.getLogger().info("DEBUG: " + l.toString());
    final Block ground = l.getBlock().getRelative(BlockFace.DOWN);
    final Block space1 = l.getBlock();
    final Block space2 = l.getBlock().getRelative(BlockFace.UP);
    //Bukkit.getLogger().info("DEBUG: ground = " + ground.getType());
    //Bukkit.getLogger().info("DEBUG: space 1 = " + space1.getType());
    //Bukkit.getLogger().info("DEBUG: space 2 = " + space2.getType());
    // Portals are not "safe"
    if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
            || space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
        return false;
    }
    // If ground is AIR, then this is either not good, or they are on slab,
    // stair, etc.
    if (ground.getType() == Material.AIR) {
        // Bukkit.getLogger().info("DEBUG: air");
        return false;
    }
    // In ASkyBlock, liquid may be unsafe
    if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
        // Check if acid has no damage
        if (Settings.acidDamage > 0D) {
            // Bukkit.getLogger().info("DEBUG: acid");
            return false;
        } else if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
                || space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
                || space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
            // Lava check only
            // Bukkit.getLogger().info("DEBUG: lava");
            return false;
        }
    }
    MaterialData md = ground.getState().getData();
    if (md instanceof SimpleAttachableMaterialData) {
        //Bukkit.getLogger().info("DEBUG: trapdoor/button/tripwire hook etc.");
        if (md instanceof TrapDoor) {
            TrapDoor trapDoor = (TrapDoor)md;
            if (trapDoor.isOpen()) {
                //Bukkit.getLogger().info("DEBUG: trapdoor open");
                return false;
            }
        } else {
            return false;
        }
        //Bukkit.getLogger().info("DEBUG: trapdoor closed");
    }
    if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().equals(Material.FENCE)
            || ground.getType().equals(Material.NETHER_FENCE) || ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
        // Bukkit.getLogger().info("DEBUG: cactus");
        return false;
    }
    // Check that the space is not solid
    // The isSolid function is not fully accurate (yet) so we have to
    // check
    // a few other items
    // isSolid thinks that PLATEs and SIGNS are solid, but they are not
    if (space1.getType().isSolid() && !space1.getType().equals(Material.SIGN_POST) && !space1.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    if (space2.getType().isSolid()&& !space2.getType().equals(Material.SIGN_POST) && !space2.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    // Safe
    //Bukkit.getLogger().info("DEBUG: safe!");
    return true;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:80,代碼來源:Util.java

示例7: onPortal

@EventHandler
public void onPortal(PlayerMoveEvent e) {
	if (e.getPlayer().getEyeLocation().getBlock().getType() == Material.PORTAL) {
		KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());
		if(p.getKingdomTerritory() == p.getKingdom().getType() || p.getKingdomTerritory() == KingdomType.GEEN) {
		if (e.getPlayer().getLocation().getWorld() == Utils.getInstance().getMiningWorld()) {
			e.getPlayer()
					.sendMessage(ChatColor.DARK_PURPLE + "Woosh.. Je bent geteleporteerd naar Ranos!");

	
			e.getPlayer().teleport(PlayerModule.getInstance().getPlayer(e.getPlayer()).getKingdom().getSpawn());

			new BukkitRunnable() {

				@Override
				public void run() {
					e.getPlayer()
							.teleport(PlayerModule.getInstance().getPlayer(e.getPlayer()).getKingdom().getSpawn());

				}
			}.runTaskLater(KingdomFactionsPlugin.getInstance(), 20L);
			   Bukkit.getPluginManager().callEvent(new MineTravelEvent(p));
			   PlayerModule.getInstance().getPlayer(e.getPlayer()).updateTerritory();
		} else {
			e.getPlayer().sendMessage(ChatColor.DARK_PURPLE + "Woosh.. Je bent geteleporteerd naar Mithras!");

			e.getPlayer()
					.teleport(PlayerModule.getInstance().getPlayer(e.getPlayer()).getKingdom().getMiningSpawn());
         
			new BukkitRunnable() {

				@Override
				public void run() {
					e.getPlayer().teleport(
							PlayerModule.getInstance().getPlayer(e.getPlayer()).getKingdom().getMiningSpawn());

				}
			}.runTaskLater(KingdomFactionsPlugin.getInstance(), 20L);
			   Bukkit.getPluginManager().callEvent(new MineTravelEvent(p));
		   PlayerModule.getInstance().getPlayer(e.getPlayer()).updateTerritory();
		}
		}
	}
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:44,代碼來源:PortalTravelEventListener.java

示例8: isMinePortal

public boolean isMinePortal(Location location) {
	return(location.getBlock().getType() == Material.PORTAL);
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:3,代碼來源:MineModule.java


注:本文中的org.bukkit.Material.PORTAL屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。