本文整理汇总了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());
}
}
}
示例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()));
}
}
}
}
示例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);
}
}