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


Java Material.REDSTONE_COMPARATOR屬性代碼示例

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


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

示例1: onWalkieTalkieInteract

@EventHandler
public void onWalkieTalkieInteract(PlayerInteractEvent e) {
	if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR)
		return;
	if (e.getHand() == EquipmentSlot.OFF_HAND)
		return;

	WalkieTalkie wt = new WalkieTalkie(main,
			main.getPlayerManager().getPlayer(e.getPlayer()).getCurrentWalkieTalkieFrequency());

	// Left click to tune frequency.
	if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
		if (e.getPlayer().isSneaking()) {
			wt.decreaseFrequency(e.getPlayer());
		} else {
			wt.increaseFrequency(e.getPlayer());
		}
	}

}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:20,代碼來源:WalkieTalkieListener.java

示例2: onWalkieTalkieChat

@EventHandler
public void onWalkieTalkieChat(AsyncPlayerChatEvent e) {
	// Comparator as temporary walkie talkie
	if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR)
		return;

	e.setCancelled(true);

	Player sender = e.getPlayer();
	Frequency senderFreq = main.getPlayerManager().getPlayer(sender).getCurrentWalkieTalkieFrequency();

	// Search for players with walkie talkie in their inv.
	for (Player p : sender.getWorld().getPlayers()) {
		if (p.getInventory().contains(Material.REDSTONE_COMPARATOR)) {

			// Are walkie talkies on the same frequency.
			Player recipient = p;
			Frequency recipientFreq = main.getPlayerManager().getPlayer(recipient)
					.getCurrentWalkieTalkieFrequency();
			if (recipientFreq.getChannel() == senderFreq.getChannel()) {

				if (p != recipient) {
					if (main.getPlayerManager().getPlayer(recipient).receiveNotificationSound())
						p.playSound(recipient.getLocation(), Sound.BLOCK_NOTE_CHIME, 5, 1);
				}
				
				p.sendMessage(MortuusTerraChat.WALKIETALKIE_PREFIX + color("&8&l[&e" + sender.getName()
						+ "&8&l] &eCh." + senderFreq.getChannel() + ">&7 " + e.getMessage()));
			}
		}
	}
}
 
開發者ID:kadeska,項目名稱:MT_Communication,代碼行數:32,代碼來源:WalkieTalkieListener.java

示例3: 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


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