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


Java BlockPlaceEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.block.BlockPlaceEvent的典型用法代碼示例。如果您正苦於以下問題:Java BlockPlaceEvent類的具體用法?Java BlockPlaceEvent怎麽用?Java BlockPlaceEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onPlaceDropper

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceDropper(final BlockPlaceEvent e) {
	if (!cm.tileLimitEnabled) {
		return;
	}
	if (e.getBlock().getType() == Material.DROPPER) {
		Player p = e.getPlayer();
		if (p.isOp()) {
			return;
		}
		int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dropper.");
		if (limit <= 0) {
			limit = cm.tileLimitDefaultDropper;
		}
		if (isLimit(e.getBlock().getLocation(), Material.DROPPER, limit)) {
			e.setCancelled(true);
			p.sendMessage(i18n.tr("message", limit));
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:21,代碼來源:TilesLimiter.java

示例2: PlaceCheckDoor

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
 public void PlaceCheckDoor(BlockPlaceEvent e) {
     if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
	Player p = e.getPlayer();
             List<Entity> entities = p.getNearbyEntities(2, 2, 2);
             for(int i=0;i<entities.size();i++){
                 Entity ent = entities.get(i);
                 if(ent.getType() == EntityType.DROPPED_ITEM){
                     Item item = (Item)ent;
                     if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
                         ent.remove();
                     }
                 }
             }
}
     }
 }
 
開發者ID:GelandiAssociation,項目名稱:EscapeLag,代碼行數:19,代碼來源:AntiInfSuagr.java

示例3: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
public void onBlockPlace(BlockPlaceEvent e) {

        Map cpl = RegionMapGen.getPlayerLocations();
        cpl.put(e.getPlayer().getUniqueId(), RegionMapGen.getMap()[(int)e.getPlayer().getLocation().getX()][(int)e.getPlayer().getLocation().getZ()]);
        RegionMapGen.setPlayerLocations(cpl);

        if (cpl.get(e.getPlayer().getUniqueId()).equals("lava")) {
            Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in Warvale's territory.");
            e.setCancelled(true);
        } else if (cpl.get(e.getPlayer().getUniqueId()).equals(Main.get().getConfig().getString("Player-Data."+e.getPlayer().getUniqueId()+"Guild-Name"))) {
            e.setCancelled(false);
        } else {
            Broadcast.toPlayer(e.getPlayer(), Broadcast.BroadcastType.FAILURE, "You cannot build in "+cpl.get(e.getPlayer().getUniqueId())+"'s territory.");
            e.setCancelled(true);
        }
    }
 
開發者ID:Warvale,項目名稱:Scorch,代碼行數:17,代碼來源:RegionMapListener.java

示例4: onPlayerBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
/**
 * Prevents placing of blocks
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW)
public void onPlayerBlockPlace(final BlockPlaceEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());
    if (!Settings.netherIslands) {
        if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
                || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
            if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
                return;
            }
            if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
                e.setCancelled(true);
            }
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:22,代碼來源:NetherEvents.java

示例5: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent event) {
	Game game = Chambers.getInstance().getGameManager().getGame();
	if (!game.hasStarted()) {
		return;
	}
	Location location = event.getBlock().getLocation();
	Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getPlayer().getUniqueId());
	if (profile.isBypassMode()) {
		event.setCancelled(false);
		return;
	}
	if (profile.getTeam() == null) {
		event.setCancelled(true);
		return;
	}
	Team team = Chambers.getInstance().getClaimManager().getTeamAt(location);
	if (team.isRaidable()) {
		event.setCancelled(false);
		return;
	}
	if (team != profile.getTeam()) {
		event.setCancelled(true);
		profile.sendMessage(ChatColor.YELLOW + "You cannot do that in the territory of " + team.getFormattedName() + ChatColor.YELLOW + ".");
	}
	}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:27,代碼來源:TeamBlockListener.java

示例6: onBlockRegister

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockRegister(BlockPlaceEvent e) {
	if (BlockStorage.hasBlockInfo(e.getBlock())) {
		e.setCancelled(true);
		return;
	}
	ItemStack item = e.getItemInHand();
	if (item != null && item.getType() == Material.INK_SACK) return;
	SlimefunItem sfItem = SlimefunItem.getByItem(item);
	if (sfItem != null && !(sfItem instanceof NotPlaceable)){
		BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
		if (SlimefunItem.blockhandler.containsKey(sfItem.getID())) {
			SlimefunItem.blockhandler.get(sfItem.getID()).onPlace(e.getPlayer(), e.getBlock(), sfItem);
		}
	}
	else {
		for (ItemHandler handler: SlimefunItem.getHandlers("BlockPlaceHandler")) {
			if (((BlockPlaceHandler) handler).onBlockPlace(e, item)) break;
		}
	}
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:22,代碼來源:ToolListener.java

示例7: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent e){
    WCUser p = WCSurvival.getPlayer(e.getPlayer());

    if (e.getBlock().getType() == Material.DROPPER && plugin.getCreando().contains(p.getPlayer())){
        if (plugin.getCasinos().contains(e.getBlock().getLocation())) {
            p.sendMessagePrefix(ChatColor.RED + "Este espacio esta ocupado por otra maquina");
            return;
        }
        plugin.getCreando().remove(p.getPlayer());
        plugin.getFiles().getConfig().set("casino.id_" + plugin.getFiles().getID(), Utils.locationToString(e.getBlock().getLocation()));
        plugin.getFiles().saveFiles();
        p.sendMessagePrefix(ChatColor.GREEN + "Máquina añadida " + plugin.getFiles().getCurrentID());
        plugin.getCasinos().add(e.getBlock().getLocation());
    }
}
 
開發者ID:cadox8,項目名稱:WC,代碼行數:17,代碼來源:PlayerEvent.java

示例8: ignite

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public boolean ignite(Player igniter, Location loc, IgniteCause cause) {
    Random rand = new Random();

    loc.add(0.5, 0.5, 0.5);
    
    BlockIgniteEvent igniteEvent = new BlockIgniteEvent(loc.getBlock(), 
            cause, (org.bukkit.entity.Entity) igniter);
    Bukkit.getServer().getPluginManager().callEvent(igniteEvent);
    if (igniteEvent.isCancelled()) {
        return false;
    }
 
    BlockState blockState = loc.getBlock().getState();
 
    BlockPlaceEvent placeEvent = new BlockPlaceEvent(loc.getBlock(), 
            blockState, loc.getBlock(), igniter.getItemInHand(), igniter, true);
    Bukkit.getServer().getPluginManager().callEvent(placeEvent);
 
    if (placeEvent.isCancelled() || !placeEvent.canBuild()) {
        placeEvent.getBlockPlaced().setTypeIdAndData(0, (byte) 0, false);
        return false;
    }

    loc.getWorld().playSound(loc, Sound.ITEM_FLINTANDSTEEL_USE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
    loc.getBlock().setType(Material.FIRE);
    
    return true;
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:30,代碼來源:FirestrikerClick.java

示例9: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlace(BlockPlaceEvent e) {
	if (haulted) {
		if (!e.getPlayer().isOp()) {
			e.getPlayer().sendMessage(TAG + ChatColor.RED + "Server Haulted!");
			e.setCancelled(true);
			return;
		}
	}
	if (!e.getPlayer().hasPermission("behave.build.place")) {
		e.setCancelled(true);
		if(getConfig().getBoolean("msgbb")){
			e.getPlayer().sendMessage(ChatColor.BLUE + "[Behave] " + ChatColor.RED + "you dont have permision");
		}
	}
}
 
開發者ID:OverloadedCore,項目名稱:behave,代碼行數:17,代碼來源:MainPart.java

示例10: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
  public void onBlockPlace(BlockPlaceEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
	event.setCancelled(true);
	return;
}

      if (State.PVP)
          return;
      
      Block b = event.getBlock();
      if (b.getType()==Material.TNT && !State.PVP) {
          Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!");
          event.setCancelled(true);
      }
      
      
      Team team = Team.getTeam(event.getPlayer());
      if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
          event.setCancelled(true);
      }
      if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
          event.setCancelled(true);
      }
  }
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:26,代碼來源:Events.java

示例11: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
/**
 * Handle Towers
 *
 * @param event Event
 */
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
    /*if (this.game.isPvPActivated() && event.getBlockPlaced().getY() > event.getBlock().getWorld().getHighestBlockYAt(event.getBlockPlaced().getX(), event.getBlockPlaced().getZ()) + 15)
    {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.DARK_RED + "[" + ChatColor.RED + "Tours" + ChatColor.DARK_RED + "] " + ChatColor.RED + "Les Tours sont interdites !");

        return;
    }*/

    if (!this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT)
    {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "Vous ne pouvez pas utiliser de la TNT tant que le PvP est désactivé !");
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:23,代碼來源:GameListener.java

示例12: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event)
{
    int x = event.getBlock().getX() + this.data.length / 2;
    int z = event.getBlock().getZ() + this.data.length / 2;
    if (x >= 0 && z >= 0 && x < this.data.length && z < this.data.length)
    {
        byte high = this.data[x][z];
        if (event.getBlock().getY() > high + 15
                && event.getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR
                && event.getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR)
        {
            event.setCancelled(true);
            event.getPlayer().sendMessage(ChatColor.RED + "Les towers sont interdites.");
        }
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:20,代碼來源:AntiTowerListener.java

示例13: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent e)
{
    User user = MWAPI.getUserHandler().findById(e.getPlayer().getUniqueId());

    if (user.getGame() != null)
    {
        if (user.getGame().getSpectators().contains(user) || user.getGame().getState().equals(GameState.LOBBY))
        {
            e.setCancelled(true);
            return;
        }

        // TODO handle other stuff like the castles and walls
    }
}
 
開發者ID:WoutDev,項目名稱:Mega-Walls,代碼行數:17,代碼來源:BlockPlaceListener.java

示例14: onPlaceDispenser

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceDispenser(final BlockPlaceEvent e) {
	if (!cm.tileLimitEnabled) {
		return;
	}
	if (e.getBlock().getType() == Material.DISPENSER) {
		Player p = e.getPlayer();
		if (p.isOp()) {
			return;
		}
		int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.dispenser.");
		if (limit <= 0) {
			limit = cm.tileLimitDefaultDispenser;
		}
		if (isLimit(e.getBlock().getLocation(), Material.DISPENSER, limit)) {
			e.setCancelled(true);
			p.sendMessage(i18n.tr("message", limit));
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:21,代碼來源:TilesLimiter.java

示例15: onPlaceHopper

import org.bukkit.event.block.BlockPlaceEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlaceHopper(final BlockPlaceEvent e) {
	if (!cm.tileLimitEnabled) {
		return;
	}
	if (e.getBlock().getType() == Material.HOPPER) {
		Player p = e.getPlayer();
		if (p.isOp()) {
			return;
		}
		int limit = NeverLagUtils.getMaxPermission(p, "neverlag.limit.hopper.");
		if (limit <= 0) {
			limit = cm.tileLimitDefaultHopper;
		}
		if (isLimit(e.getBlock().getLocation(), Material.HOPPER, limit)) {
			e.setCancelled(true);
			p.sendMessage(i18n.tr("message", limit));
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:21,代碼來源:TilesLimiter.java


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