本文整理汇总了Java中org.bukkit.inventory.PlayerInventory.removeItem方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInventory.removeItem方法的具体用法?Java PlayerInventory.removeItem怎么用?Java PlayerInventory.removeItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.PlayerInventory
的用法示例。
在下文中一共展示了PlayerInventory.removeItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processGreenTerra
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Process the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenTerra(BlockState blockState) {
Player player = getPlayer();
if (!Permissions.greenThumbBlock(player, blockState.getType())) {
return false;
}
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = new ItemStack(Material.SEEDS);
if (!playerInventory.containsAtLeast(seed, 1)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
return false;
}
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
return Herbalism.convertGreenTerraBlocks(blockState);
}
示例2: processShroomThumb
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Process the Shroom Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
return false;
}
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
return false;
}
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
player.updateInventory();
if (!SkillUtils.activationSuccessful(SecondaryAbility.SHROOM_THUMB, getPlayer(), getSkillLevel(), activationChance)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
return false;
}
return Herbalism.convertShroomThumb(blockState);
}
示例3: onClickOnObsidian
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onClickOnObsidian(final PlayerInteractEvent event) {
if (!plugin.isSkyWorld(event.getPlayer().getWorld())) {
return;
}
long now = System.currentTimeMillis();
Player player = event.getPlayer();
PlayerInventory inventory = player != null ? player.getInventory() : null;
Block block = event.getClickedBlock();
Long lastClick = obsidianClick.get(player.getUniqueId());
if (lastClick != null && (lastClick + OBSIDIAN_SPAM) >= now) {
plugin.notifyPlayer(player, tr("\u00a74You can only convert obsidian once every 10 seconds"));
return;
}
if (Settings.extras_obsidianToLava && plugin.playerIsOnIsland(player)
&& plugin.isSkyWorld(player.getWorld())
&& event.getAction() == Action.RIGHT_CLICK_BLOCK
&& player.getItemInHand() != null
&& player.getItemInHand().getType() == Material.BUCKET
&& block != null
&& block.getType() == Material.OBSIDIAN
&& !testForObsidian(block)) {
if (inventory.firstEmpty() != -1) {
obsidianClick.put(player.getUniqueId(), now);
player.sendMessage(tr("\u00a7eChanging your obsidian back into lava. Be careful!"));
inventory.removeItem(new ItemStack(Material.BUCKET, 1));
inventory.addItem(new ItemStack(Material.LAVA_BUCKET, 1));
player.updateInventory();
block.setType(Material.AIR);
event.setCancelled(true); // Don't execute the click anymore (since that would re-place the lava).
} else {
player.sendMessage(tr("\u00a7eYour inventory must have another empty space!"));
}
}
}
示例4: processGreenThumbPlants
import org.bukkit.inventory.PlayerInventory; //导入方法依赖的package包/类
/**
* Process the Green Thumb ability for plants.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param greenTerra boolean to determine if greenTerra is active or not
*/
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = null;
switch (blockState.getType()) {
case CARROT:
seed = new ItemStack(Material.CARROT_ITEM);
break;
case CROPS:
seed = new ItemStack(Material.SEEDS);
break;
case NETHER_WARTS:
seed = new ItemStack(Material.NETHER_STALK);
break;
case POTATO:
seed = new ItemStack(Material.POTATO_ITEM);
break;
default:
break;
}
if (!playerInventory.containsAtLeast(seed, 1)) {
return;
}
if (!greenTerra && !SkillUtils.activationSuccessful(SecondaryAbility.GREEN_THUMB_PLANT, getPlayer(), getSkillLevel(), activationChance)) {
return;
}
if (!handleBlockState(blockState, greenTerra)) {
return;
}
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
}