本文整理汇总了Java中org.bukkit.block.Block.setMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java Block.setMetadata方法的具体用法?Java Block.setMetadata怎么用?Java Block.setMetadata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.setMetadata方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlace
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
Player player = event.getPlayer();
Block b = event.getBlock();
b.setMetadata("blockBreaker", new FixedMetadataValue(PrisonPicks.getInstance(), player.getUniqueId()));
}
示例2: onInventoryClose
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onInventoryClose(InventoryCloseEvent e)
{
if (!(e.getPlayer() instanceof Player))
return;
final Player p = (Player) e.getPlayer();
if (!p.hasMetadata("shared_workbench"))
return;
if (e.getInventory().getType() == InventoryType.WORKBENCH)
{
// Workaround to get the accessed WorkBench
final Block workbench = p.getTargetBlock((Set<Material>) null, 8);
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
{
if (p.getOpenInventory().getTopInventory() != null)
p.getOpenInventory().getTopInventory().clear();
p.removeMetadata("shared_workbench", Survival.instance);
return;
}
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
list.remove(p.getUniqueId());
if (list.isEmpty())
workbench.removeMetadata("shared_players", Survival.instance);
else
{
e.getInventory().clear();
workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
}
}
}
示例3: onPlayerQuit
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e)
{
if (!(e.getPlayer() instanceof Player))
return;
final Player p = (Player) e.getPlayer();
if (!p.hasMetadata("shared_workbench"))
return;
Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
if (workbench != null && workbench.hasMetadata("shared_players") && workbench.getType() == Material.WORKBENCH)
{
@SuppressWarnings("unchecked")
List<UUID> list = (workbench.getMetadata("shared_players").get(0).value() instanceof List<?>) ? (List<UUID>)workbench.getMetadata("shared_players").get(0).value() : new ArrayList<UUID>();
list.remove(p.getUniqueId());
if (list.isEmpty())
workbench.removeMetadata("shared_players", Survival.instance);
else
workbench.setMetadata("shared_players", new FixedMetadataValue(Survival.instance, list));
}
p.removeMetadata("shared_workbench", Survival.instance);
}
示例4: onBlockPlace
import org.bukkit.block.Block; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPlace(BlockPlaceEvent event) {
Gamer g = Gamer.get(event.getPlayer());
Block b = event.getBlockPlaced();
if (event.getBlockPlaced().getType() != Material.STONE_PLATE)
return;
event.setCancelled(false);
Mine mine = new Mine(g, b);
b.setMetadata("Mine", new FixedMetadataValue(Nexus.getPlugin(), Mine.getList().indexOf(mine)));
}
示例5: onBlockPlace
import org.bukkit.block.Block; //导入方法依赖的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()));
}