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


Java BlockPlaceEvent.getBlock方法代碼示例

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


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

示例1: 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

示例2: onPlaceChest

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlaceChest(BlockPlaceEvent e) {
	if (!cm.isAntiQuickDoubleChest) {
		return;
	}
	Block block = e.getBlock();
	if (block == null) {
		return;
	}
	Material blockType = block.getType();
	if (Material.CHEST == blockType || Material.TRAPPED_CHEST == blockType) {
		if (isShopBlockNearby(block)) {
			e.setCancelled(true);
			e.getPlayer().sendMessage(i18n.tr("antiQuickShopDoubleChest"));
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:18,代碼來源:AntiQuickShopDoubleChest.java

示例3: BlockPlaceEvent

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void BlockPlaceEvent(BlockPlaceEvent e){
    Player p = e.getPlayer();
    Block b = e.getBlock();

    if (e.getItemInHand().getType() == Material.DROPPER && e.getItemInHand().getEnchantments() != null && e.getItemInHand().getEnchantments().containsKey(Enchantment.ARROW_DAMAGE)) {
        Casino c = new Casino(e.getBlockPlaced().getLocation());
        c.effect();
    }

    for(Entity en : p.getNearbyEntities (4D, 4D, 4D)){
        if (en instanceof Player){
            if(en == p) continue;
            if(b.getType() == Material.FIRE){

                if(Files.user.getBoolean("Users." + en.getName() + ".pvp") == false){
                    p.sendMessage(Utils.colorize(PAData.SURVIVAL.getPrefix() + ChatColor.DARK_RED + " No puedes poner ese bloque cerca de un jugador con el pvp desactivado."));
                    e.setCancelled(true);
                }
            }
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:24,代碼來源:PlayerEvents.java

示例4: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlace(BlockPlaceEvent e) {
	if (e.isCancelled()) {
		return;
	}
	if (!e.getBlock().getType().equals(Material.CAULDRON)) {
		return;
	}
	Block b = e.getBlock();
	Location loc = b.getLocation();
	loc.setY(loc.getY() + 1);
	Block upon = loc.getBlock();
	if (upon.getType().equals(Material.AIR)) {
		return;
	}
	e.setCancelled(true);
	e.getPlayer().sendMessage(Messages.getMessages().getNoPlace().replace("&", "§"));
}
 
開發者ID:Soldier233,項目名稱:SlimefunBugFixer,代碼行數:19,代碼來源:Listeners.java

示例5: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
    Player player = event.getPlayer();
    Block b = event.getBlock();
    b.setMetadata("blockBreaker", new FixedMetadataValue(PrisonPicks.getInstance(), player.getUniqueId()));
}
 
開發者ID:ThePhilderbeast,項目名稱:prisonPicks,代碼行數:8,代碼來源:Events.java

示例6: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
/**
 * Tagging placed logs
 *
 * @param event Event
 */
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
    Block block = event.getBlock();

    if (block.getType().equals(Material.LOG) || block.getType().equals(Material.LOG_2))
        block.setMetadata("placed", new FixedMetadataValue(this.plugin, event.getPlayer().getUniqueId()));
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:14,代碼來源:FastTreeModule.java

示例7: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onBlockPlace(final BlockPlaceEvent event) {
    final Block block = event.getBlock();
    if(block.getType() == FoundDiamondsListener.SEARCH_TYPE) {
        this.foundLocations.add(block.getLocation().toString());
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:8,代碼來源:FoundDiamondsListener.java

示例8: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onBlockPlace(final BlockPlaceEvent event) {
    final Block block = event.getBlock();
    final WorldBorder worldBorder = wbHandler.getBorder(block.getWorld());
    if (worldBorder != null && !worldBorder.isInBounds(block)) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(DENY_BUILD);
    }
}
 
開發者ID:Mystiflow,項目名稱:WorldBorder,代碼行數:10,代碼來源:WorldBorderListener.java

示例9: onPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlace(BlockPlaceEvent evt) {
    Block source = evt.getBlock();
    Structure s = match(source);
    if (s == null) return;
    
    s.onCreate(evt);
}
 
開發者ID:Recraft,項目名稱:Recreator,代碼行數:9,代碼來源:StructureChangeListener.java

示例10: onPlaceBlock

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlaceBlock(BlockPlaceEvent e) {
	Block block = e.getBlock();

	Material blockMaterial = block.getType();
	int x = block.getX();
	int y = block.getY();
	int z = block.getZ();
	WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());

	if (CropControl.getDAO().isTracked(block) == true) {
		// We've got a replacement
		CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
		handleRemoval(block, chunk);
	}
	if (harvestableCrops.containsKey(blockMaterial)) {
		// we placed a block overtop an existing crop. Will be handled by a break event?
		/*Crop crop = chunk.getCrop(x, y, z);
		if (crop != null) {
			crop.setRemoved();
			CropControl.getPlugin().debug("Missed an event? Replacing a Crop at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		
		// We've placed a crop!
		Crop.create(chunk, x, y, z, blockMaterial.toString(), getBaseCropState(blockMaterial),
				e.getPlayer().getUniqueId(), System.currentTimeMillis(), harvestableCrops.get(blockMaterial));
	} else if (blockMaterial == Material.SAPLING) {
		// we placed a block overtop an existing sapling. TODO: Do I need to remove sapling here, or will there be a break event?
		/*Sapling sapling = chunk.getSapling(x, y, z);
		if (sapling != null) {
			sapling.setRemoved();
			CropControl.getPlugin().debug("Missed an event? Replacing a Sapling at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		// We've placed a sapling!
		Sapling.create(chunk, x, y, z, getSaplingType(block.getData()),
				e.getPlayer().getUniqueId(), System.currentTimeMillis(), false);
	} else if (blockMaterial == Material.CHORUS_FLOWER) {
		/*if (CropControl.getDAO().isTracked(block) == true) {
			CropControl.getPlugin().debug("Ghost object? Placement is overtop a tracked object at {0}, {1}, {2}", x, y, z);
			//return;
		}*/
		
		// TODO: Check if connected to an existing chorus tree.

		// First register the "tree"
		Tree chorusPlant = Tree.create(chunk, x, y, z, Material.CHORUS_PLANT.toString(),
				e.getPlayer().getUniqueId(), System.currentTimeMillis());

		// Then the component in the tree.
		TreeComponent.create(chorusPlant, chunk, x, y, z, Material.CHORUS_PLANT.toString(),
				e.getPlayer().getUniqueId(), false);
	} else if (blockMaterial.isSolid()){ // check for cactus.
		for (BlockFace face : CropControlEventHandler.directions) {
			Block adj = block.getRelative(face);
			if (Material.CACTUS.equals(adj.getType())) {
				Location loc = adj.getLocation();
				if (!pendingChecks.contains(loc)) {
					pendingChecks.add(loc);
					handleBreak(adj, BreakType.PLAYER, e.getPlayer().getUniqueId(), null);
				}		
			}
		}
	}
}
 
開發者ID:DevotedMC,項目名稱:CropControl,代碼行數:67,代碼來源:CropControlEventHandler.java

示例11: onBlockPlace

import org.bukkit.event.block.BlockPlaceEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();

    blockBridge.notifyBlockUpdate(block.getLocation(), block.getType(), block.getState());
}
 
開發者ID:satoshinm,項目名稱:WebSandboxMC,代碼行數:7,代碼來源:BlockListener.java


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