本文整理汇总了Java中org.bukkit.Material.GOLDEN_APPLE属性的典型用法代码示例。如果您正苦于以下问题:Java Material.GOLDEN_APPLE属性的具体用法?Java Material.GOLDEN_APPLE怎么用?Java Material.GOLDEN_APPLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.GOLDEN_APPLE属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: anvilStuff
@SuppressWarnings("deprecation")
@EventHandler
public void anvilStuff(PlayerInteractEvent e){
if(e.getClickedBlock() == null)return;
if(e.getClickedBlock().getType().equals(Material.ANVIL)){
e.setCancelled(true);
Player p = e.getPlayer();
String uuid = p.getUniqueId().toString();
long tokens = getTokens(uuid);
if(p.getItemInHand().getType() == Material.AIR ||
p.getItemInHand().getType() == Material.GOLDEN_APPLE ||
p.getItemInHand().getType() == Material.ARROW ||
p.getItemInHand().getType() == Material.POTION){
p.sendMessage(tag + ChatColor.RED + "You can\'t repair that!");
}else{
if(tokens < 1){
p.sendMessage(tag + ChatColor.RED + "You need at least 1 token to repair things!!");
}else{
if(p.getItemInHand().getDurability() > 0){
p.getItemInHand().setDurability((short) 0);
setTokens(uuid, getTokens(uuid)-1);
p.sendMessage(tag + ChatColor.BLUE + "Your item has been repaired");
}else{
p.sendMessage(tag + ChatColor.RED + "This item isn\'t broken");
}
}
}
}
}
示例2: onItemConsume
/**
* Increase the Regeneration boost when a golden apple is eaten
*
* @param event Event
*/
@EventHandler
public void onItemConsume(PlayerItemConsumeEvent event)
{
if (this.game instanceof RunBasedGame && event.getItem().getType() == Material.GOLDEN_APPLE)
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 10 * 20, 1));
}
示例3: onPlayerConsume
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerConsume(PlayerItemConsumeEvent event) {
ItemStack stack = event.getItem();
if (stack != null && stack.getType() == Material.GOLDEN_APPLE && stack.getDurability() == 1) {
Player player = event.getPlayer();
if (setCooldown(player, player.getUniqueId(), defaultCooldown, false, new Predicate<Long>() {
@Override
public boolean apply(@Nullable Long value) {
return false;
}
})) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588\u2588\u2588&c\u2588\u2588\u2588"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588&e\u2588\u2588&c\u2588\u2588\u2588"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', ("&c\u2588\u2588\u2588&e\u2588&c\u2588\u2588\u2588\u2588 &6&l " + this.name + ": ")));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588&6\u2588\u2588\u2588\u2588&c\u2588\u2588 &7 Consumed"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588\u2588&f\u2588&6\u2588&6\u2588\u2588&c\u2588"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588&f\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588 &6 Cooldown Remaining:"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', ("&c\u2588&6\u2588\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588 &7 " + DurationFormatter.getRemaining(getRemaining(player), true, false))));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588&6\u2588\u2588&6\u2588&6\u2588&6\u2588\u2588&c\u2588"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588&6\u2588\u2588\u2588\u2588&c\u2588\u2588"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c\u2588\u2588\u2588\u2588\u2588&c\u2588\u2588\u2588"));
} else {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You still have a " + getDisplayName() + ChatColor.RED + " cooldown for another " + ChatColor.BOLD
+ DurationFormatter.getRemaining(getRemaining(player), true, false) + ChatColor.RED + '.');
}
}
}
示例4: onEat
@EventHandler
public void onEat(PlayerItemConsumeEvent event){
String type = MinecraftUtils.getExtraType(event.getItem());
FoodStatus food = ExtraManager.foods.get(type);
if( food == null )
if(event.getItem().getType() == Material.GOLDEN_APPLE){
if(event.getItem().getDurability() == 1){
type = "napple";
}else{
type = "apple";
}
food = ExtraManager.foods.get(type);
}
if( food == null )
return;
event.setCancelled(true);
VPPlayer playerPlus = VanillaPlusCore.getPlayerManager().getPlayer(event.getPlayer());
VPPConsumeFoodEvent e = new VPPConsumeFoodEvent(playerPlus, food, type);
Bukkit.getServer().getPluginManager().callEvent(e);
if(e.isCancelled())
return;
ItemStack item = event.getItem();
if(item.getAmount() == 1)
event.getPlayer().setItemInHand(null);
else{
item.setAmount(item.getAmount()-1);
event.getPlayer().setItemInHand(item);
}
food.apply(e.getPlayer());
}
示例5: getIcon
@Override
public ItemStack getIcon()
{
return new ItemStack(Material.GOLDEN_APPLE, 1);
}
示例6: clearJunk
public void clearJunk(){
World world = Bukkit.getWorld("kaospvp");
List<Entity> list = world.getEntities();
for(Entity e : list){
if(e instanceof Item){
Item it = (Item) e;
if( it.getItemStack().getType() == Material.POTION &&
it.getItemStack().getDurability() == 16453){
e.remove();
}
if( it.getItemStack().getType() == Material.GOLDEN_APPLE &&
it.getItemStack().getDurability() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.ARROW){
e.remove();
}
if( it.getItemStack().getType() == Material.GLASS_BOTTLE){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_BOOTS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_LEGGINGS &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_CHESTPLATE &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_HELMET &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.DIAMOND_SWORD &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.BOW &&
it.getItemStack().getEnchantments().size() == 0){
e.remove();
}
if( it.getItemStack().getType() == Material.WOOD_AXE ||
it.getItemStack().getType() == Material.STONE_AXE ||
it.getItemStack().getType() == Material.GOLD_AXE ||
it.getItemStack().getType() == Material.IRON_AXE ||
it.getItemStack().getType() == Material.DIAMOND_AXE){
e.remove();
}
}
}
}
示例7: shopInvent
public Inventory shopInvent(){
Inventory inv = Bukkit.createInventory(null, 36, shopName);
ItemStack str = new ItemStack(Material.POTION, 1, (short) 8201);
ItemMeta strM = str.getItemMeta();
List<String> strL = new ArrayList<String>();
strM.setDisplayName(ChatColor.RED + "Strength");
strL.add(ChatColor.GOLD + "120 Tokens");
strM.setLore(strL);
str.setItemMeta(strM);
inv.addItem(str);
ItemStack gaps = new ItemStack(Material.GOLDEN_APPLE, 2, (short) 1);
ItemMeta gapsM = gaps.getItemMeta();
List<String> gapsL = new ArrayList<String>();
gapsM.setDisplayName(ChatColor.RED + "Golden Apple");
gapsL.add(ChatColor.GOLD + "10 Tokens");
gapsM.setLore(gapsL);
gaps.setItemMeta(gapsM);
inv.addItem(gaps);
for(int i = 0; i < 6; i++){
inv.addItem(getItemSpacer());
}
ItemStack ljm = new ItemStack(Material.DAYLIGHT_DETECTOR);
ItemMeta ljmM = ljm.getItemMeta();
List<String> ljmL = new ArrayList<String>();
ljmM.setDisplayName(ChatColor.RED + "Leave/Join Messages");
ljmL.add(ChatColor.GOLD + "400 Tokens");
ljmM.setLore(ljmL);
ljm.setItemMeta(ljmM);
inv.addItem(ljm);
ItemStack exp = new ItemStack(Material.EXP_BOTTLE,20);
ItemMeta expM = exp.getItemMeta();
List<String> expL = new ArrayList<String>();
expM.setDisplayName(ChatColor.RED + "Experience Bottles");
expL.add(ChatColor.GOLD + "1 Token");
expM.setLore(expL);
exp.setItemMeta(expM);
inv.addItem(exp);
// remove the item spacers
inv.remove(Material.STAINED_GLASS_PANE);
return inv;
}
示例8: shopClick
@EventHandler
public void shopClick(InventoryClickEvent e){
if(e.getInventory().getName().equals(shopName) && e.getRawSlot() > 36){
e.setCancelled(true);
return;
}
if(e.getClickedInventory() == null){
e.setCancelled(true);
return;
}
if(e.getClickedInventory().getName() == null){
e.setCancelled(true);
return;
}
if(e.getClickedInventory().getName().equals(shopName)){
Player p = (Player) e.getWhoClicked();
String uuid = p.getUniqueId().toString();
long tokens = getTokens(uuid);
e.setCancelled(true);
if(! e.getCurrentItem().hasItemMeta()) return;
String name = e.getCurrentItem().getItemMeta().getDisplayName();
if(name.equals(ChatColor.RED + "Strength")){
if(tokens < 120){
p.sendMessage(tag + ChatColor.RED + "You don\'t have enough tokens!");
p.closeInventory();
}else{
ItemStack str = new ItemStack(Material.POTION, 1, (short) 8201);
p.getInventory().addItem(str);
setTokens(uuid, getTokens(uuid) - 120);
p.sendMessage(tag + ChatColor.BLUE + "Your purchase was a success");
}
}
if(name.equals(ChatColor.RED + "Golden Apple")){
if(tokens < 10){
p.sendMessage(tag + ChatColor.RED + "You don\'t have enough tokens!");
p.closeInventory();
}else{
ItemStack gaps = new ItemStack(Material.GOLDEN_APPLE, 2, (short) 1);
p.getInventory().addItem(gaps);
setTokens(uuid, getTokens(uuid) - 10);
p.sendMessage(tag + ChatColor.BLUE + "Your purchase was a success");
}
}
if(name.equals(ChatColor.RED + "Leave/Join Messages")){
if(tokens < 400){
p.sendMessage(tag + ChatColor.RED + "You don\'t have enough tokens!");
p.closeInventory();
}else{
if(isSjm(uuid)){
p.sendMessage(tag + ChatColor.RED + "You already have this!");
p.closeInventory();
}else{
setSjm(uuid, true);
setTokens(uuid, getTokens(uuid) - 400);
p.sendMessage(tag + ChatColor.BLUE + "Your purchase was a success");
}
}
}
if(name.equals(ChatColor.RED + "Experience Bottles")){
if(tokens < 1){
p.sendMessage(tag + ChatColor.RED + "You don\'t have enough tokens!");
p.closeInventory();
}else{
ItemStack exp = new ItemStack(Material.EXP_BOTTLE,20);
p.getInventory().addItem(exp);
setTokens(uuid, getTokens(uuid) - 1);
p.sendMessage(tag + ChatColor.BLUE + "Your purchase was a success");
}
}
}
}
示例9: onCraftItem
private static void onCraftItem(Recipe recipe, CraftingInventory inventory)
{
if (recipe.getResult().getType() == Material.GOLDEN_APPLE && recipe.getResult().getDurability() == 1)
inventory.setResult(new ItemStack(Material.AIR));
}
示例10: BasicKitHandler
public BasicKitHandler()
{
this.kits = new HashSet<>();
if (MWAPI.getConfig().isDefaultKitsEnabled())
{
// *** FIGHTER KIT *** //
// Fighter Armor
ItemStack fighterHelmet = new ItemStack(Material.IRON_HELMET, 1);
fighterHelmet.addEnchantment(Enchantment.DAMAGE_ALL, 1);
KitItem fighterHelmetKitItem = MWAPI.getKitItemBuilder()
.stack(fighterHelmet)
.drop(false)
.unbreakable(true)
.create();
ItemStack fighterChestplate = new ItemStack(Material.IRON_CHESTPLATE, 1);
fighterChestplate.addEnchantment(Enchantment.DAMAGE_ALL, 1);
KitItem fighterChestplateKitItem = MWAPI.getKitItemBuilder()
.stack(fighterChestplate)
.drop(false)
.unbreakable(true)
.create();
ItemStack fighterPants = new ItemStack(Material.IRON_LEGGINGS, 1);
fighterPants.addEnchantment(Enchantment.DAMAGE_ALL, 1);
KitItem fighterPantsKitItem = MWAPI.getKitItemBuilder()
.stack(fighterPants)
.drop(false)
.unbreakable(true)
.create();
ItemStack fighterBoots = new ItemStack(Material.IRON_BOOTS, 1);
fighterBoots.addEnchantment(Enchantment.DAMAGE_ALL, 1);
KitItem fighterBootsKitItem = MWAPI.getKitItemBuilder()
.stack(fighterPants)
.drop(false)
.unbreakable(true)
.create();
// Fighter Items
ItemStack fighterSword = new ItemStack(Material.IRON_SWORD, 1);
fighterSword.addEnchantment(Enchantment.DAMAGE_ALL, 2);
KitItem fighterSwordKitItem = MWAPI.getKitItemBuilder()
.stack(fighterSword)
.drop(false)
.unbreakable(true)
.create();
ItemStack fighterFood = new ItemStack(Material.GOLDEN_APPLE, 10);
KitItem fighterFoodKitItem = MWAPI.getKitItemBuilder()
.stack(fighterSword)
.drop(true)
.unbreakable(true)
.create();
registerKit(MWAPI.getKitBuilder("Fighter")
.setBoots(fighterBootsKitItem)
.setPants(fighterPantsKitItem)
.setChestPlate(fighterChestplateKitItem)
.setHelmet(fighterHelmetKitItem)
.setItemAt(0, fighterSwordKitItem)
.setItemAt(1, fighterFoodKitItem)
.create());
}
}