本文整理匯總了Java中org.bukkit.block.Block.removeMetadata方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.removeMetadata方法的具體用法?Java Block.removeMetadata怎麽用?Java Block.removeMetadata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.block.Block
的用法示例。
在下文中一共展示了Block.removeMetadata方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: checkPedestal
import org.bukkit.block.Block; //導入方法依賴的package包/類
private void checkPedestal(Block pedestal)
{
Item item = AncientAltarListener.findItem(pedestal);
if(item == null)
{
abort();
} else
{
particles.add(pedestal.getLocation().add(0.5D, 1.5D, 0.5D));
items.add(AncientAltarListener.fixItemStack(item.getItemStack(), item.getCustomName()));
pedestal.getWorld().playSound(pedestal.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 5F, 2.0F);
try
{
ParticleEffect.ENCHANTMENT_TABLE.display(pedestal.getLocation().add(0.5D, 1.5D, 0.5D), 0.3F, 0.2F, 0.3F, 0.0F, 16);
ParticleEffect.CRIT_MAGIC.display(pedestal.getLocation().add(0.5D, 1.5D, 0.5D), 0.3F, 0.2F, 0.3F, 0.0F, 8);
}
catch(Exception e)
{
e.printStackTrace();
}
item.remove();
pedestal.removeMetadata("item_placed", SlimefunStartup.instance);
}
}
示例2: onDisable
import org.bukkit.block.Block; //導入方法依賴的package包/類
public void onDisable()
{
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
getServer().getScheduler().cancelTasks(this);
getServer().resetRecipes();
usingPlayers = new ArrayList<Player>();
//Avoid WorkbenchShare glitch
for(Player p : Bukkit.getOnlinePlayers())
{
if (p.hasMetadata("shared_workbench"))
{
Block workbench = (p.getMetadata("shared_workbench").get(0).value() instanceof Block) ? (Block)p.getMetadata("shared_workbench").get(0).value() : null;
if(workbench != null && workbench.getType() == Material.WORKBENCH)
{
if (workbench.hasMetadata("shared_players"))
workbench.removeMetadata("shared_players", Survival.instance);
else
p.getOpenInventory().getTopInventory().clear();
p.closeInventory();
}
p.removeMetadata("shared_workbench", Survival.instance);
}
}
logger.info(pdfFile.getName() + " has been disabled.");
}
示例3: 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));
}
}
}
示例4: 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);
}
示例5: onBreakWorkbench
import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onBreakWorkbench(BlockBreakEvent e)
{
if(e.isCancelled()) return;
Block workbench = e.getBlock();
if (!workbench.hasMetadata("shared_players") || workbench.getType() != Material.WORKBENCH)
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>();
Iterator<UUID> iterator = list.iterator();
Inventory sharedInventory = Bukkit.createInventory(null, InventoryType.WORKBENCH);
while (iterator.hasNext())
{
UUID next = iterator.next();
iterator.remove();
final Player idPlayer = Bukkit.getPlayer(next);
if (idPlayer != null)
{
idPlayer.removeMetadata("shared_inv", Survival.instance);
if(idPlayer.isOnline())
{
final Inventory open = idPlayer.getOpenInventory().getTopInventory();
if (open != null && open.getType() == InventoryType.WORKBENCH)
{
sharedInventory.setContents(open.getContents());
open.clear();
idPlayer.closeInventory();
}
}
}
}
for(int i = 1; i < sharedInventory.getSize(); i++)
{
ItemStack item = sharedInventory.getItem(i);
if(item != null)
workbench.getWorld().dropItem(workbench.getLocation(), item);
}
workbench.removeMetadata("shared_players", Survival.instance);
}