当前位置: 首页>>代码示例>>Java>>正文


Java SlimefunItem.getByItem方法代码示例

本文整理汇总了Java中me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.getByItem方法的典型用法代码示例。如果您正苦于以下问题:Java SlimefunItem.getByItem方法的具体用法?Java SlimefunItem.getByItem怎么用?Java SlimefunItem.getByItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem的用法示例。


在下文中一共展示了SlimefunItem.getByItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isEnabled

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
public static boolean isEnabled(Player p, ItemStack item, boolean message)
{
    String world = p.getWorld().getName();
    SlimefunItem sfItem = SlimefunItem.getByItem(item);
    if(sfItem == null)
        return !SlimefunItem.isDisabled(item);
    if(SlimefunStartup.getWhitelist().contains((new StringBuilder(String.valueOf(world))).append(".enabled").toString()))
    {
        if(SlimefunStartup.getWhitelist().getBoolean((new StringBuilder(String.valueOf(world))).append(".enabled").toString()))
        {
            if(!SlimefunStartup.getWhitelist().contains((new StringBuilder(String.valueOf(world))).append(".enabled-items.").append(sfItem.getName()).toString()))
                SlimefunStartup.getWhitelist().setDefaultValue((new StringBuilder(String.valueOf(world))).append(".enabled-items.").append(sfItem.getName()).toString(), Boolean.valueOf(true));
            if(SlimefunStartup.getWhitelist().getBoolean((new StringBuilder(String.valueOf(world))).append(".enabled-items.").append(sfItem.getName()).toString()))
                return true;
            if(message)
                Messages.local.sendTranslation(p, "messages.disabled-in-world", true, new Variable[0]);
            return false;
        }
        if(message)
            Messages.local.sendTranslation(p, "messages.disabled-in-world", true, new Variable[0]);
        return false;
    } else
    {
        return true;
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:27,代码来源:Slimefun.java

示例2: onBlockRegister

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockRegister(BlockPlaceEvent e) {
	if (BlockStorage.hasBlockInfo(e.getBlock())) {
		e.setCancelled(true);
		return;
	}
	ItemStack item = e.getItemInHand();
	if (item != null && item.getType() == Material.INK_SACK) return;
	SlimefunItem sfItem = SlimefunItem.getByItem(item);
	if (sfItem != null && !(sfItem instanceof NotPlaceable)){
		BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
		if (SlimefunItem.blockhandler.containsKey(sfItem.getID())) {
			SlimefunItem.blockhandler.get(sfItem.getID()).onPlace(e.getPlayer(), e.getBlock(), sfItem);
		}
	}
	else {
		for (ItemHandler handler: SlimefunItem.getHandlers("BlockPlaceHandler")) {
			if (((BlockPlaceHandler) handler).onBlockPlace(e, item)) break;
		}
	}
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:22,代码来源:ToolListener.java

示例3: hasUnlocked

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
/**
 * Checks if this player can use this item.
 *
 * @param  p        the player to check, not null
 * @param  item     the item to check, not null
 * @param  message  whether a message should be sent to the player or not
 *
 * @return <code>true</code> if the item is a SlimefunItem, enabled, researched and if the player has the permission to use it,
 *         <code>false</code> otherwise.
 */
public static boolean hasUnlocked(Player p, ItemStack item, boolean message) {
	SlimefunItem sfItem = SlimefunItem.getByItem(item);
	State state = SlimefunItem.getState(item);
	if (sfItem == null) {
		if (state != State.ENABLED) {
			if (message && state != State.VANILLA) Messages.local.sendTranslation(p, "messages.disabled-item", true);
			return false;
		}
		else return true;
	}
	else if (isEnabled(p, item, message) && hasPermission(p, sfItem, message)) {
		if (sfItem.getResearch() == null) return true;
		else if (sfItem.getResearch().hasUnlocked(p)) return true;
		else {
			if (message && !(sfItem instanceof VanillaItem)) Messages.local.sendTranslation(p, "messages.not-researched", true);
			return false;
		}
	}
	else return false;
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:31,代码来源:Slimefun.java

示例4: isEnabled

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
/**
 * Checks if this item is enabled in the world this player is in.
 *
 * @param  p        the player to get the world he is in, not null
 * @param  item     the item to check, not null
 * @param  message  whether a message should be sent to the player or not
 *
 * @return <code>true</code> if the item is a SlimefunItem and is enabled in the world the player is in,
 *         <code>false</code> otherwise.
 */
public static boolean isEnabled(Player p, ItemStack item, boolean message) {
	String world = p.getWorld().getName();
	SlimefunItem sfItem = SlimefunItem.getByItem(item);
	if (sfItem == null) return !SlimefunItem.isDisabled(item);
	if (SlimefunStartup.getWhitelist().contains(world + ".enabled")) {
		if (SlimefunStartup.getWhitelist().getBoolean(world + ".enabled")) {
			if (!SlimefunStartup.getWhitelist().contains(world + ".enabled-items." + sfItem.getID())) SlimefunStartup.getWhitelist().setDefaultValue(world + ".enabled-items." + sfItem.getID(), true);
			if (SlimefunStartup.getWhitelist().getBoolean(world + ".enabled-items." + sfItem.getID())) return true;
			else {
				if (message) Messages.local.sendTranslation(p, "messages.disabled-in-world", true);
				return false;
			}
		}
		else {
			if (message) Messages.local.sendTranslation(p, "messages.disabled-in-world", true);
			return false;
		}
	}
	else return true;
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:31,代码来源:Slimefun.java

示例5: hasUnlocked

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
public static boolean hasUnlocked(Player p, ItemStack item, boolean message)
{
    SlimefunItem sfItem = SlimefunItem.getByItem(item);
    me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.State state = SlimefunItem.getState(item);
    if(sfItem == null)
        if(state != me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.State.ENABLED)
        {
            if(message && state != me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.State.VANILLA)
                Messages.local.sendTranslation(p, "messages.disabled-item", true, new Variable[0]);
            return false;
        } else
        {
            return true;
        }
    if(isEnabled(p, item, message) && hasPermission(p, sfItem, message))
    {
        if(sfItem.getResearch() == null)
            return true;
        if(sfItem.getResearch().hasUnlocked(p))
            return true;
        if(message && !(sfItem instanceof VanillaItem))
            Messages.local.sendTranslation(p, "messages.not-researched", true, new Variable[0]);
        return false;
    } else
    {
        return false;
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:29,代码来源:Slimefun.java

示例6: onCraft

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onCraft(CraftItemEvent e) {
    for (ItemStack item: e.getInventory().getContents()) {
    	if (SlimefunItem.getByItem(item) != null && !(SlimefunItem.getByItem(item).isReplacing())) {
    		e.setCancelled(true);
    		Messages.local.sendTranslation((Player) e.getWhoClicked(), "workbench.not-enhanced", true);
    		break;
    	}
    }
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:11,代码来源:ItemListener.java

示例7: onAnvil

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
  public void onAnvil(InventoryClickEvent e) {
      if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.ANVIL) {
if (SlimefunManager.isItemSimiliar(e.getInventory().getContents()[0], SlimefunItems.ELYTRA, true)) return;

      	if (SlimefunItem.getByItem(e.getInventory().getContents()[0]) != null && !SlimefunItem.isDisabled(e.getInventory().getContents()[0])) {
          	e.setCancelled(true);
              Messages.local.sendTranslation((Player) e.getWhoClicked(), "anvil.not-working", true);
          }
      }
  }
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:12,代码来源:ItemListener.java

示例8: onBowUse

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
public void onBowUse(EntityShootBowEvent e)
{
    if(!(e.getEntity() instanceof Player) || !(e.getProjectile() instanceof Arrow))
        return;
    if(SlimefunItem.getByItem(e.getBow()) != null)
        Variables.arrows.put(e.getProjectile().getUniqueId(), e.getBow());
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:8,代码来源:BowListener.java

示例9: onItemDrop

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent e) {
	if (Variables.backpack.containsKey(e.getPlayer().getUniqueId())){
		ItemStack item = e.getItemDrop().getItemStack();
		SlimefunItem sfItem = SlimefunItem.getByItem(item);
		if (sfItem instanceof SlimefunBackpack) e.setCancelled(true);
	}
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:9,代码来源:BackpackListener.java

示例10: store

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
public static void store(Block block, ItemStack item) {
	SlimefunItem sfitem = SlimefunItem.getByItem(item);
	if (sfitem != null) addBlockInfo(block, "id", sfitem.getID(), true);
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:5,代码来源:BlockStorage.java

示例11: onEat

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onEat(PlayerItemConsumeEvent e) {
	if (e.getItem() != null) {
		final Player p = e.getPlayer();
		ItemStack item = e.getItem();
		if (Slimefun.hasUnlocked(p, item, true)) {
			if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MONSTER_JERKY, true)) {
				e.setCancelled(true);
				if (SlimefunManager.isItemSimiliar(p.getInventory().getItemInOffHand(), SlimefunItems.MONSTER_JERKY, true)) {
					p.getInventory().setItemInOffHand(InvUtils.decreaseItem(p.getInventory().getItemInOffHand(), 1));
				}
				else{
					p.getInventory().setItemInMainHand(InvUtils.decreaseItem(p.getInventory().getItemInMainHand(), 1));
				}
				PlayerInventory.update(p);
				p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION, 5, 0));
			}
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.FORTUNE_COOKIE, true)) p.sendMessage(ChatColor.translateAlternateColorCodes('&', Messages.local.getTranslation("messages.fortune-cookie").get(CSCoreLib.randomizer().nextInt(Messages.local.getTranslation("messages.fortune-cookie").size()))));
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.BEEF_JERKY, true)) p.setSaturation((Integer) Slimefun.getItemValue("BEEF_JERKY", "Saturation"));
			else if (SlimefunManager.isItemSimiliar(item, SlimefunItems.MEDICINE, true)) {
				if (p.hasPotionEffect(PotionEffectType.POISON)) p.removePotionEffect(PotionEffectType.POISON);
				if (p.hasPotionEffect(PotionEffectType.WITHER)) p.removePotionEffect(PotionEffectType.WITHER);
				if (p.hasPotionEffect(PotionEffectType.SLOW)) p.removePotionEffect(PotionEffectType.SLOW);
				if (p.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) p.removePotionEffect(PotionEffectType.SLOW_DIGGING);
				if (p.hasPotionEffect(PotionEffectType.WEAKNESS)) p.removePotionEffect(PotionEffectType.WEAKNESS);
				if (p.hasPotionEffect(PotionEffectType.CONFUSION)) p.removePotionEffect(PotionEffectType.CONFUSION);
				if (p.hasPotionEffect(PotionEffectType.BLINDNESS)) p.removePotionEffect(PotionEffectType.BLINDNESS);
				p.setFireTicks(0);
			}
			else if (item.getType() == Material.POTION) {
				SlimefunItem sfItem = SlimefunItem.getByItem(item);
				if (sfItem != null && sfItem instanceof Juice) {
					int mode = 0;
					
					if (SlimefunManager.isItemSimiliar(item, p.getInventory().getItemInMainHand(), true)) {
						if (p.getInventory().getItemInMainHand().getAmount() == 1) {
							mode = 0;
						}
						else {
							mode = 2;
						}
					}
					else if (SlimefunManager.isItemSimiliar(item, p.getInventory().getItemInOffHand(), true)) {
						if (p.getInventory().getItemInOffHand().getAmount() == 1) {
							mode = 1;
						}
						else {
							mode = 2;
						}
					}
					
					final int m = mode;
					
					Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
						
						
		                @Override
		                public void run() {
		                    if (m == 0) {
		                    	p.getInventory().setItemInMainHand(null);
		                    }
		                    else if (m == 1) {
		                    	p.getInventory().setItemInOffHand(null);
		                    }
		                    else if (m == 2) {
		                    	p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1));
		                    }
		                }
		                
		            }, 1L);
				}
			}
		}
		else e.setCancelled(true);
	}
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:77,代码来源:ItemListener.java

示例12: onPlace

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
public void onPlace(BlockPlaceEvent e) {
	SlimefunItem item = SlimefunItem.getByItem(e.getItemInHand());
	if (item != null && (item instanceof EGPlant) && e.getItemInHand().getType() == Material.SKULL_ITEM) e.setCancelled(true);
}
 
开发者ID:TheBusyBiscuit,项目名称:ExoticGarden,代码行数:6,代码来源:FoodListener.java

示例13: onEquip

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onEquip(InventoryClickEvent e) {
	if (e.getSlotType() != SlotType.ARMOR) return;
	SlimefunItem item = SlimefunItem.getByItem(e.getCursor());
	if (item != null && (item instanceof EGPlant) && e.getCursor().getType() == Material.SKULL_ITEM) e.setCancelled(true);
}
 
开发者ID:TheBusyBiscuit,项目名称:ExoticGarden,代码行数:7,代码来源:FoodListener.java

示例14: onDamage

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority=EventPriority.MONITOR)
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player && !e.isCancelled()) {
		Player p = (Player) e.getEntity();
		for (ItemStack armor: p.getInventory().getArmorContents()) {
			if (armor != null && SlimefunItem.getByItem(armor) != null) {
				if (SlimefunItem.getByItem(armor).isItem(SlimefunItems.ENDER_BOOTS) && Slimefun.hasUnlocked(p, SlimefunItems.ENDER_BOOTS, true)) {
					if (e instanceof EntityDamageByEntityEvent) {
						if (((EntityDamageByEntityEvent) e).getDamager() instanceof EnderPearl) e.setCancelled(true);
					}
				}
				else if (SlimefunItem.getByItem(armor).isItem(SlimefunItems.SLIME_BOOTS) && Slimefun.hasUnlocked(p, SlimefunItems.SLIME_BOOTS, true)) {
					if (e.getCause() == DamageCause.FALL) e.setCancelled(true);
				}
				else if (SlimefunItem.getByItem(armor).isItem(SlimefunItems.BOOTS_OF_THE_STOMPER) && Slimefun.hasUnlocked(p, SlimefunItems.BOOTS_OF_THE_STOMPER, true)) {
					if (e.getCause() == DamageCause.FALL) {
						e.setCancelled(true);
						p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, 2F, 2F);
						p.setVelocity(new Vector(0.0, 0.7, 0.0));
						for (Entity n: p.getNearbyEntities(4, 4, 4)) {
							if (n instanceof LivingEntity && !n.getUniqueId().toString().equalsIgnoreCase(p.getUniqueId().toString())) {
								n.setVelocity(n.getLocation().toVector().subtract(p.getLocation().toVector()).normalize().multiply(1.4));
								if (p.getWorld().getPVP()) {
									EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, e.getDamage() / 2);
									Bukkit.getPluginManager().callEvent(event);
									if (!event.isCancelled()) ((LivingEntity) n).damage(e.getDamage() / 2);
								}
							}
						}
						for (int i = 0; i < 2; i++) {
							for (BlockFace face: BlockFace.values()) {
								p.getWorld().playEffect(p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face).getLocation(), Effect.STEP_SOUND, p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face).getType());
							}
						}
					}
				}
				else if (SlimefunItem.getByItem(armor).isItem(SlimefunItems.SLIME_BOOTS_STEEL) && Slimefun.hasUnlocked(p, SlimefunItems.SLIME_BOOTS_STEEL, true)) {
					if (e.getCause() == DamageCause.FALL) e.setCancelled(true);
				}
			}
		}
	}
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:45,代码来源:ArmorListener.java

示例15: onBowUse

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; //导入方法依赖的package包/类
@EventHandler
public void onBowUse(EntityShootBowEvent e) {
	if (!(e.getEntity() instanceof Player) || !(e.getProjectile() instanceof Arrow)) return;
	if (SlimefunItem.getByItem(e.getBow()) != null) Variables.arrows.put(e.getProjectile().getUniqueId(), e.getBow());
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:6,代码来源:BowListener.java


注:本文中的me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem.getByItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。