當前位置: 首頁>>代碼示例>>Java>>正文


Java Material.WATCH屬性代碼示例

本文整理匯總了Java中org.bukkit.Material.WATCH屬性的典型用法代碼示例。如果您正苦於以下問題:Java Material.WATCH屬性的具體用法?Java Material.WATCH怎麽用?Java Material.WATCH使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.bukkit.Material的用法示例。


在下文中一共展示了Material.WATCH屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerSpeak

@EventHandler
public void onPlayerSpeak(AsyncPlayerChatEvent e) {
  if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.WATCH)
    return;
  
  e.setCancelled(true);
  playerSpeaksOnCellPhone(e.getPlayer(), e.getMessage());
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:8,代碼來源:CellularPhoneListener.java

示例2: onCellPhoneInteract

@EventHandler
public void onCellPhoneInteract(PlayerInteractEvent e) {
  Player p = e.getPlayer();
  
  if (p.getInventory().getItemInMainHand().getType() != Material.WATCH)
    return;
  
  e.setCancelled(true);
  
  CellularPhone phone = new CellularPhone(main);
  
  // Left click for recipient toggle
  if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.getNextContact(p);
      
    } else {
      phone.getPreviousContact(p);
      
    }
  }
  
  // Right click for text messages
  if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.checkTextMessages(p);
      
    } else {
      phone.deleteTextMessage(p);
      
    }
  }
  
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:34,代碼來源:CellularPhoneListener.java

示例3: i_MedicKit

private ItemStack i_MedicKit()
{
	ItemStack i_medicKit = new ItemStack(Material.WATCH, 1);
     	//ItemMeta medicKitMeta= i_medicKit.getItemMeta();
     	//medicKitMeta.setDisplayName(ChatColor.RESET + Survival.Words.get("Medical Kit"));
     	//i_medicKit.setItemMeta(medicKitMeta);
     	
     	return i_medicKit;
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:9,代碼來源:MedicKit.java

示例4: onChatEvent

@EventHandler
private void onChatEvent(AsyncPlayerChatEvent e) {
 // Watch is the temporary cell phone
 if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.WATCH)
  return;
 // Walkie Talkie
 if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.REDSTONE_COMPARATOR)
  return;
 
 e.setCancelled(true);

  String message = e.getMessage();
  Player sender = e.getPlayer();
  String format = ("&b" + sender.getName() + "&8&l >> &r");

  for (Player recipient : e.getRecipients()) {
  	
    // Check if players are in the same world.
    if (!sender.getWorld().equals(recipient.getWorld()))
      continue;
    
    // Sender counts as recipient so send him his unscrambled message.
    if (sender.equals(recipient)) {
      recipient.sendMessage(StringUtilities.color(format + message));
      continue;
    }
    
    // If message sent by admin/op don#t scramble
    if (sender.hasPermission("mtcom.unscrambled")) {
  	  recipient.sendMessage(StringUtilities.color(format + message));
        continue;
    }
    
    String scrambled = main.getMessageScrambler().scramble(message, sender, recipient);
    // 'Scrambled' will be null if the distance is > 100 (send no message to recipient).
    if (scrambled == null)
      continue;

    String scrambledMessage = StringUtilities.color(format + scrambled);
    recipient.sendMessage(scrambledMessage);
  }
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:42,代碼來源:PlayerChatListener.java

示例5: onSelfClick

@SuppressWarnings("deprecation")
@EventHandler
public void onSelfClick(PlayerInteractEvent event)
{
	if(event.hasItem() && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK))
	{
		final Player player = event.getPlayer();
		ItemStack mainItem = player.getInventory().getItemInMainHand();
		if(mainItem != null && mainItem.getType() == Material.WATCH)
		{
			if(healing.getScore(player).getScore() <= 0)
			{
				if(player.isSneaking())
				{
					healing.getScore(player).setScore(1);
					player.sendMessage(Survival.Words.get("�aHealing �ryourself") + Survival.Words.get("�a, keep ") + ChatColor.DARK_GREEN + Survival.Words.get("Medical Kit") + Survival.Words.get("�a on hand"));
					
					healTimes.getScore(player).setScore(5);
					final Runnable task = new Runnable()
					{
						public void run()
						{
							int times = healTimes.getScore(player).getScore();
							if(player.getInventory().getItemInMainHand().getType() == Material.WATCH && healing.getScore(player).getScore() > 0)
							{
								if(times-- > 0)
								{													
									Random rand = new Random();
									
									player.removePotionEffect(PotionEffectType.SLOW);
			                        player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 20, 6, true, false));
			                        player.removePotionEffect(PotionEffectType.JUMP);
			                        player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 20, 199, true, false));
			                        
			                        player.getWorld().playSound(player.getLocation(), Sound.ENTITY_LEASHKNOT_PLACE, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
									player.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0));
									
									Location particleLoc = player.getLocation();
			                        particleLoc.setY(particleLoc.getY() + 1);
			                        ParticleEffect.VILLAGER_HAPPY.display(0.5f, 0.5f, 0.5f, 0, 10, particleLoc, 64);

									Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 20L);
									healTimes.getScore(player).setScore(times);
								}

								else
								{
									healing.getScore(player).setScore(0);
									
									player.sendMessage(ChatColor.DARK_GREEN + Survival.Words.get("Healing complete"));
									
									player.getInventory().removeItem(i_MedicKit());
								}
							}
							else
							{
								healing.getScore(player).setScore(0);
								
								player.sendMessage(ChatColor.DARK_RED + Survival.Words.get("Healing interrupted"));
								
								player.getInventory().removeItem(i_MedicKit());
							}
						}
					};
					
					Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1L);
				}
			}
		}
	}
}
 
開發者ID:FattyMieo,項目名稱:SurvivalPlus,代碼行數:71,代碼來源:MedicKit.java


注:本文中的org.bukkit.Material.WATCH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。