本文整理汇总了Java中org.bukkit.entity.Item.getItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java Item.getItemStack方法的具体用法?Java Item.getItemStack怎么用?Java Item.getItemStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Item
的用法示例。
在下文中一共展示了Item.getItemStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemDrop
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
System.out.println("Item drop");
Item item = event.getItemDrop();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
DropItemObsel obsel = new DropItemObsel(
new Date().getTime(),
stack.getType().toString(),
stack.getAmount(),
stack.getData().getData(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
location.getWorld().getName(),
playerName);
JSONObselManager.getInstance().addObsel(obsel);
}
示例2: onItemPickup
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event)
{
System.out.println("Item pickup");
Item item = event.getItem();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
PickupItemObsel obsel = new PickupItemObsel(
new Date().getTime(),
stack.getType().toString(),
stack.getAmount(),
stack.getData().getData(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
location.getWorld().getName(),
playerName);
JSONObselManager.getInstance().addObsel(obsel);
}
示例3: StopDrops
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void StopDrops(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
Item item = event.getItemDrop();
if(item != null)
{
ItemStack stack = item.getItemStack();
if(stack != null)
{
if(KitUtils.isSoulbound(stack))
{
player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1.0F, 0.3F);
event.getItemDrop().remove();
}
}
}
}
示例4: addLots
import org.bukkit.entity.Item; //导入方法依赖的package包/类
public int addLots(List<Item> items)
{
int addedCount = 0;
for(Item itemEntity : items)
{
ItemStack item = itemEntity.getItemStack();
AuctionableItem ai = regionalConfigManager.getAuctionableItemConfig(itemEntity);
if(null == ai) continue;
double startingPrice = (((int)(ai.getStartingPrice() * 100)) * item.getAmount()) / 100D;
double minimumIncrement = (((int)(ai.getMinimumIncrement() * 100)) * item.getAmount()) / 100D;
Lot lot = new Lot(item, false, startingPrice, null, null, null, -1, minimumIncrement, System.currentTimeMillis() + ai.getPreserveTimeInSeconds() * 1000, ai.getAuctionDurationInSeconds() * 1000);
lots.add(lot);
addedCount++;
}
LotShowcase.updateAll();
return addedCount;
}
示例5: clearDropInfo
import org.bukkit.entity.Item; //导入方法依赖的package包/类
private void clearDropInfo(Item item) {
ItemStack stack = item.getItemStack();
ItemMeta meta = stack.getItemMeta();
if (meta != null) {
List<String> lore = meta.getLore();
if (lore != null && !lore.isEmpty()) {
for (Iterator<String> it = lore.iterator(); it.hasNext(); ) {
String line = it.next();
if (line.contains(tr("Owner: {0}", ""))) {
it.remove();
}
}
meta.setLore(lore);
stack.setItemMeta(meta);
item.setItemStack(stack);
}
}
}
示例6: onItemPickup
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
Game bw = io.github.bedwarsrel.BedwarsRel.Main.getInstance()
.getGameManager().getGameOfPlayer(e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
Player p = e.getPlayer();
Item entity = e.getItem();
ItemStack stack = entity.getItemStack();
int count = Res.convertResToXP(stack);
if (count == 0) {
return;
}
e.setCancelled(true);
XPManager.addXP(bw.getName(), p, count);
p.playSound(p.getLocation(),
SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
10.0F, 1.0F);
if (!Config.Message.equals("")) {
ActionBarUtils.sendActionBar(p,
Config.Message.replaceAll("%xp%", Integer.toString(count)));
/*
* if (!ActionBarUtils.works) {
* p.sendMessage(Config.Message.replaceAll("%xp%",
* Integer.toString(count))); }
*/
}
entity.remove();
}
示例7: onItemPickup
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
.getGameOfPlayer(e.getPlayer());
if (bw == null) {
return;
}
if (!Config.isGameEnabledXP(bw.getName())) {
return;
}
Player p = e.getPlayer();
Item entity = e.getItem();
ItemStack stack = entity.getItemStack();
int count = Res.convertResToXP(stack);
if (count == 0) {
return;
}
e.setCancelled(true);
XPManager.addXP(bw.getName(), p, count);
p.playSound(p.getLocation(),
SoundMachine.get("ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP"),
10.0F, 1.0F);
if (!Config.Message.equals("")) {
ActionBarUtils.sendActionBar(p,
Config.Message.replaceAll("%xp%", Integer.toString(count)));
/*
* if (!ActionBarUtils.works) {
* p.sendMessage(Config.Message.replaceAll("%xp%",
* Integer.toString(count))); }
*/
}
entity.remove();
}
示例8: handleItemDrop
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleItemDrop(final PlayerDropItemEvent event) {
ParticipantState player = PGM.getMatchManager().getParticipantState(event.getPlayer());
if(player == null) return;
Competitor team = player.getParty();
Item itemDrop = event.getItemDrop();
ItemStack item = itemDrop.getItemStack();
if (this.isDestroyableWool(item, team)) {
this.droppedWools.put(itemDrop, player.getPlayerId());
}
}
示例9: onItemSpawn
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
Item item = event.getEntity();
ItemStack stack = item.getItemStack();
World world = item.getWorld();
if (world.getEnvironment() != Environment.THE_END || stack.getType() != Material.DRAGON_EGG
|| stack.hasItemMeta()) return;
DragonTemplate dragon = plugin.getDEDManager().getWorldWrapper(world).getActiveBattle();
DragonLoot loot = dragon.getLoot();
String eggName = loot.getEggName().replace("%dragon%", dragon.getName());
List<String> eggLore = loot.getEggLore().stream()
.map(s -> s.replace("%dragon%", dragon.getName()))
.collect(Collectors.toList());
ItemMeta eggMeta = stack.getItemMeta();
if (eggName != null && !eggName.isEmpty()) {
eggMeta.setDisplayName(eggName);
}
if (eggLore != null && !eggLore.isEmpty()) {
eggMeta.setLore(eggLore);
}
stack.setItemMeta(eggMeta);
}
示例10: onItemSpawn
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
if (e.isCancelled()) {
return;
}
Item item = e.getEntity();
ItemStack is = item.getItemStack();
if (isMoneyItem(is)) {
item.setCustomName(is.getItemMeta().getDisplayName());
item.setCustomNameVisible(true);
}
}
示例11: onItemPickUp
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onItemPickUp(PlayerPickupItemEvent e) {
if (e.isCancelled()) {
return;
}
Item item = e.getItem();
ItemStack is = item.getItemStack();
if (isMoneyItem(is)) {
e.setCancelled(true);
BigDecimal money = new BigDecimal(Double.valueOf(ChatColor.stripColor(is.getItemMeta().getLore().get(0))
.replaceAll("[^0-9.]", "")))
.setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN);
EntityType entityType = EntityType.valueOf(is.getItemMeta().getLore().get(1));
EntityProperties ep = EntityManager.getEntityProperties(entityType);
if (ep == null) {
return;
}
UUID uuid = UUID.fromString(is.getItemMeta().getLore().get(2));
if (!DefaultConfig.isMoneyItemAnyonePickUp() && !uuid.equals(e.getPlayer().getUniqueId())) {
return;
}
WorldProperties wp = EntityManager.getWorldProperties(ep, e.getItem().getLocation().getWorld().getName());
if (wp != null) {
item.remove();
Bukkit.getPluginManager().callEvent(new KMEarnMoneyPickedUpEvent(wp.getMoneyProperties(),
e.getPlayer(), money));
}
}
}
示例12: init
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@Override
protected boolean init(final @Nullable Class<? extends Item> c, final @Nullable Item e) {
if (e != null) {
final ItemStack i = e.getItemStack();
if (i == null)
return false;
types = new ItemType[] {new ItemType(i)};
}
return true;
}
示例13: onPlayerDropItem
import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
* Monitor PlayerDropItemEvents.
* <p>
* These events are monitored for the purpose of flagging sharable
* dropped items, as well as removing ability buffs from pickaxes
* and shovels.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack();
if (ItemUtils.isSharable(dropStack)) {
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
}
SkillUtils.removeAbilityBuff(dropStack);
}
示例14: onCatch
import org.bukkit.entity.Item; //导入方法依赖的package包/类
@EventHandler
public void onCatch(final PlayerFishEvent event) {
if (!(event.getCaught() instanceof Item))
return;
final Item caught = (Item)event.getCaught();
final ItemStack item = caught.getItemStack();
if (!Enchantments.getAllEnchantments(item).isEmpty()) {
Enchantments.removeAllEnchantments(item);
mechanics.generateEnchantments(event.getPlayer(), item, bookLevel, false, random.nextLong())
.getEnchantments().forEach((enchant, level) -> enchant.addToItem(item, level));
caught.setItemStack(item);
}
}
示例15: onPlayerPickupItem
import org.bukkit.entity.Item; //导入方法依赖的package包/类
/**
* Handle PlayerPickupItemEvents at the highest priority.
* <p>
* These events are used to handle item sharing between party members and
* are also used to handle item pickup for the Unarmed skill.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
Item drop = event.getItem();
ItemStack dropStack = drop.getItemStack();
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) {
event.setCancelled(true);
}
return;
}
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (event.isCancelled()) {
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
return;
}
}
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
event.setCancelled(cancel);
if (pickupSuccess) {
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.updateInventory();
return;
}
}
}