====== 通知与提示 ====== ===== 简介 ===== 一个“通知”就是发送给玩家的一个消息,它可以通过BetonQuest、某个插件、或自定义“通知事件”发出。 你可以在''messages.yml''中自定义一个信息,它记录了各种消息以及对应的各种多国语言。 如果你想自定义发送某个通知消息的方式,你还可以通过编辑''custom.yml''去自定义一个NotifyIO。举个例子,你可以在玩家的日志有更新的时候弹出一个成就,亦或者是玩家在某个拆除方块的任务目标中弹出一个bossbar通知。 ===== 什么是NotifyIO通知提示系统? ===== NotifyIO指的是一些发送通知的方法。BetonQuest默认提供了一些,另外第三方插件也会提供额外的方法。 以下是一些默认提供的方法: * ''suppress'' - 不发送任何通知。在某些时候你可以用这个来取消某个通知。 * ''chat'' - (默认)在聊天框显示 * ''advancement'' - 在右上角弹出一个成就框显示通知 * ''actionbar''- 在动作栏(玩家物品栏上方)显示 * ''bossbar'' - 弹出一个boss血条栏显示 * ''title'' - 弹出一个标题显示 * ''subtitle'' - 弹出一个副标题显示 ===== 默认的NotifyIO通知方式 ===== 若不指定通知方式,默认通过聊天框''chat''显示。如果你想更改默认的通知提示方式,比如改成''actionbar'',你可以照如下修改''config.yml''配置文件: default_notify_IO: actionbar ===== 如何预先设置通知类型 ===== When a notification is generated it will usually have one or more categories assigned to it. These categories are searched for, in order, in all ''custom.yml'' files under the section ''notifications''. The first category found will be used to configured the notification. If none were found then a category of ''default'' will be search for. A typical custom.yml file may have the following: notifications: # A new journal entry has been added new_journal_entry: io: advancement frame: challenge icon: map # All infomation notifications info: io: chat sound: BLOCK_CHEST_CLOSE When a new journal entry is added, it will send a notification with the following categories: * new_journal_entry * info In the above file, it will find ''new_journal_entry'' first so will ignore ''info''. This defines the settings for the notification by using the ''advancement'' notifyIO with a challenge frame and a map for the icon. When a new changelog occurs it will send a notification using the following categories: * changelog * info In the above file, it will find ''info'' which defines that it should be sent via the chat with a specific sound played as well. ===== 通知类型 ===== Categories are a way of defining settings for a notification. BetonQuest uses many categories itself but you can define your own custom categories and use them through the ''notify'' event. In general a BetonQuest notification will use the same category name for a notification as it uses in ''messages.yml'' to define the language and text of the notification. It will also use more general categories to allow you to more broadly define settings and only provide specific settings for some notifications. Remember the categories are searched for in order so the first category will be used in preference to those later in the list. A list of categories used by BetonQuest are as follows: ^ Notification ^ Categories ^ | Pullback | pullback, error | | Command Blocked | command_blocked,error | | No Permission | no_permission,error | | Busy | busy,error | | Changelog | changelog,info | | Inventory Full | inventory_full,error | | Language Changed | language_changed,info | | Mobs to Kill | mobs_to_kill,info | | Money Given | money_given,info | | Money Taken | money_taken,info | | Quest Cancelled | quest_cancelled,quest_canceled,info | | Items Given | items_given,info | | New Journal Entry | new_journal_entry,info | | Items Taken | items_taken,info | | Blocks to Break | blocks_to_break,info | | Blocks to Place | blocks_to_place,info | | Animals to Breed | animals_to_breed,info | | Mobs to click | mobs_to_click,info | | Fish to catch | fish_to_catch,info | | Players to kill | players_to_kill,info | | Potions to brew | potions_to_brew,info | | Sheep to shear | sheep_to_shear,info | ===== NotifyIO通知方式 ===== 每一种NotifyIO都有各自的设置参数,通常这些参数都不是必填的,BetonQuest自带的NotifyIO的参数如下: ==== 静默: Suppress ==== 不显示任何通知。可用于阻止显示某个通知。 ==== 聊天框: Chat ==== 在玩家的聊天框显示通知。 ^ 参数 ^ 描述 ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | ==== 成就框: Advancement ==== 弹出一个成就框并显示通知。 ^ 参数 ^ 描述 ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | | frame | 什么类型的边框。可以是''challenge''、''goal''或''task'' | | icon | 用什么方块作为标志。必须填写Minecraft原生方块ID,比如''minecraft:map'' | ==== 动作栏: Actionbar ==== 在动作栏(在快捷物品栏上方)显示通知。 ^ 选项 ^ 描述 ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | ==== Boss血条: Bossbar ==== 在Boss血条显示通知。 ^ Option ^ Description ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | | barFlags | 添加额外Bossbar效果,效果列表请参见[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/boss/BarFlag.html|这里]]。 | barColor | 血条颜色。可选的颜色列表请参见[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/boss/BarColor.html|这里]]。 | | progress | 血条进度。小数,数值介于0.0(空)和1.0(满血)之间。 | | style | 血条款式。款式列表请参见[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/boss/BarStyle.html|这里]]。 | | stay | 血条在屏幕上的持续时间。单位ticks,默认值是70ticks(约等于3.5秒)。 | | countdown | 倒计时。如果设置了,血条长度会根据此数值递减。例如,当数值设置为10时,血条会在持续时间之内每次递减1/10。 | ==== 标题: Title ==== 通过标题显示通知。 ^ 选项 ^ 描述 ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | | fadeIn | 淡入时长。单位ticks,默认值是10。 | | stay | 持续时长。单位Ticks,默认值是70。 | | fadeOut | 淡出时长。单位Ticks,默认值是20。 | | subTitle | 副标题内容。如果不为空则额外再显示一个副标题,文字中的下划线''_''会被显示成空格。 | ==== 副标题: Subtitle ==== 在副标题显示通知。 ^ 选项 ^ 描述 ^ | sound | 播放什么声音,如果为空则不播放任何声音。请参考[[https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Sound.html|这个列表]]选找你需要播放的声音,或填写自定义资源包中的声音名字。 | | fadeIn | 淡入时长。单位ticks,默认值是10。 | | stay | 持续时长。单位Ticks,默认值是70。 | | fadeOut | 淡出时长。单位Ticks,默认值是20。 | ===== 自定义通知 ===== 通过''notify''事件,你还可以随时随地显示自定义通知。在''notify''事件中你可以引用custom.yml中预先定义的NotifyIO,或直接编写一个。请参考[[插件手册:betonquest:事件列表#显示通知notify|事件列表-显示通知]]章节查看具体编写格式。 ===== 例子 ===== ==== 例子 1 - 自定义通知 ==== 假设你的custom.yml文件如下: notifications: # 测试通知类别 test_suppress: io: suppress test_chat: io: chat sound: BLOCK_CHEST_CLOSE test_advancement: io: advancement sound: BLOCK_CHEST_CLOSE frame: challenge # challenge|goal|task icon: map test_actionbar: io: actionbar sound: BLOCK_CHEST_CLOSE test_bossbar: io: bossbar sound: BLOCK_CHEST_CLOSE #barFlags: create_fog,darken_sky,play_boss_music barColor: purple # blue|green|pink|purple|red|white progress: 0.0 # 0.0 - 1.0 style: solid # segmented_10|segmented_12|segmented_20|segmented_6|solid stay: 70 test_title: io: title sound: BLOCK_CHEST_CLOSE fadeIn: 10 stay: 70 fadeOut: 20 #subtitle: test_subtitle: io: subtitle sound: BLOCK_CHEST_CLOSE fadeIn: 10 stay: 70 fadeOut: 20 并且下列//事件//会按顺序执行: # 测试通知类别 notify_cat_suppress: notify Test Notify category:test_suppress notify_cat_chat: notify Test Notify category:test_chat notify_cat_advancement: notify Test Notify category:test_advancement notify_cat_actionbar: notify Test Notify category:test_actionbar notify_cat_bossbar: notify Test Notify category:test_bossbar notify_cat_title: notify Test Notify category:test_title notify_cat_subtitle: notify Test Notify category:test_subtitle # 测试通知类别 + 一些自定义参数 notify_catcus_title_sub: notify Test Notify category:test_title subtitle:"My SubTitle" notify_catcus_bossbar_red: notify Test Notify category:test_bossbar barColor:red sound:ENTITY_BAT_TAKEOFF style:segmented_10 progress:0.3 # 测试完全自定义参数+一些NotifyIO notify_cus_bossbar_green: notify Test Notify io:bossbar barColor:green stay:120 notify_cus_advancement: notify Test Notify io:advancement icon:hopper frame:goal 运行效果请参考[[https://www.youtube.com/watch?v=mmEfIXp4dxA|这个视频]] ==== 例子 2 - Boss血条倒计时 ==== 假设有下列//事件//按顺序执行: notify_cus_bossbar_countdown1: notify Countdown Test Bossbar io:bossbar stay:120 countdown:10 progress:1 notify_cus_bossbar_countdown2: notify Countdown Test Bossbar io:bossbar stay:120 countdown:120 progress:1 执行效果请参考[[https://i.imgur.com/x6Ihe7W.mp4|这个视频]] ==== 例子 3 - 对内置的默认通知使用静默 ==== 如果你不想对玩家显示''changelog''插件更新相关的通知,你可以使用“静默”''suppress''NotifyIO来强行关掉插件更新日志提示。 custom.yml例子: notifications: changelog: io: suppress