面向插件开发者:易于使用的 API
以下是一个小示例,展示如何在您自己的插件中使用此功能,在告示牌上显示针对特定玩家的数据。
1.) 首先:将 IndividualSigns jar 添加到您的构建路径中(就像添加 bukkit.jar 一样)
2.) 然后,您可以创建一个监听器来监听 SignSendEvent(创建方式与为 Bukkit 事件创建监听器相同):每当服务器即将更新某个玩家的告示牌内容时,都会调用此事件。
3.) 该事件提供了简便的方法来获取当前的告示牌文本并进行修改:
- getPlayer() - 获取接收告示牌数据包的玩家。
- getLocation() - 获取正在发送文本的告示牌的位置。
- getLine(int index) - 获取指定索引处(0-3)的文本行。这些行采用 JSON 格式。
- setLine(int index, String line) - 设置指定索引处的文本行。必须采用正确的 JSON 格式。
- isModified() - 检查此事件是否已被某个插件修改。
- setCancelled(boolean cancelled) - 如果事件被取消,受影响玩家的告示牌内容将不会更新,保留其当前内容(如果所有 SignSendEvent 都被取消,则保持空白)。
- isCancelled() - 检查是否有插件已经取消了此事件。
使用该事件将 "[PLAYER]" 替换为玩家姓名的示例用法:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public class SignSendListener implements Listener { |
就是这样。 InSigns-Plugin 将为您处理所有必要的数据包操作。
InSigns 提供的其他一些实用工具包括:
- SimpleChanger 类,可用于轻松创建监听器,以便在制作告示牌时进行简单的键值替换和权限检查。内置 [PLAYER] -> playerName 替换的示例如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
@Override |
使用 InSigns 的插件
- Paintball War Edition - 提供个性化的彩弹射击统计数据告示牌。
- ScoreboardStats - 提供一些通用的个人统计数据告示牌。
如果你的插件使用了 InSigns 并希望在此处被提及,请告诉我。
统计信息
本插件使用 bStats 来收集匿名使用统计数据,以确定有多少服务器正在使用该插件,以及在哪些 Minecraft 版本中使用最为广泛。所有收集到的信息均可在此公开查看:
你可以通过编辑文件 plugins/bStats/config.yml 来禁用服务器上所有插件的 bStats,或者通过在 InSigns 的配置中将 'metrics-stats' 设置为 'false' 来仅禁用 IndividualSigns 的 bStats。
捐赠
如果你喜欢这个插件,请考虑通过以下方式进行 捐赠 以支持其开发。
提前感谢!
For plugin developers: easy-to-use API
Here is a small example of how you can use this in your own plugin to display player-specific values on signs.
1.) First of all: add the IndividualSigns jar to your build path (just like you do it with the bukkit.jar)
2.) You can then create a listener which listens for the SignSendEvent (just like you create listeners for bukkit events): This event gets called every time the server is about to update the sign contents for a player.
3.) The event provides easy methods to get the current sign text and to change it:
- getPlayer() - Gets the player which receives the sign packet.
- getLocation() - Gets the location of the sign which text is being sent.
- getLine(int index) - Gets the line of text at the specified index (0-3). The lines are in json format.
- setLine(int index, String line) - Sets the line of text at the specified index. Has to be in proper json format.
- isModified() - Whether or not this event was modified by some plugin.
- setCancelled(boolean cancelled) - If the event is cancelled the sign contents won't get updated for the affected player, leaving it at their current content (blank if all SignSendEvents get cancelled).
- isCancelled() - Checks whether or not some plugin cancelled this event already.
Example usage of the event to replace "[PLAYER]" with the player's name:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
public class SignSendListener implements Listener { |
That's it. The InSigns-Plugin will handle all the needed packet manipulation for you.
Some other useful utilities provided by InSigns are:
- The SimpleChanger class which can be used to easily create a listener for simple key->value replacements and permission checks during sign creation. Example for the built-in [PLAYER] -> playerName replacement:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
@Override public void onEnable() { Plugin insignsPlugin = getServer().getPluginManager().getPlugin("InSigns"); if ((insignsPlugin != null) && insignsPlugin.isEnabled()) { // Replaces "[PLAYER]" with the player's name on signs and checks for the 'insigns.create.player' permission whenever a player tries to create a sign with "[PLAYER]" on it new SimpleChanger(this, "[PLAYER]", "insigns.create.player") { @Override public String getValue(Player player, Location location) { return player.getName(); } }; getLogger().info("Plugin 'InSigns' found. Using it now."); } else { getLogger().info("Plugin 'InSigns' not found. Additional sign features disabled."); } } |
Plugins using InSigns
- Paintball War Edition - Offering individual paintball statistics signs.
- ScoreboardStats - Offering some individual general statistics signs.
Let me know if your plugin uses InSigns and you want to be mentioned here.
Statistics
This plugin uses bStats to collect anonymous usage statistics to determine the how many servers are using the plugin and with which minecraft versions it is used with the most. All collected information can be publicly viewed here:
You can disable bStats for all plugins on your server by editing the file plugins/bStats/config.yml, or alternatively disable it only for IndividualSigns by setting 'metrics-stats' to 'false' inside InSigns' config.
Donations
If you like this plugin, consider supporting its development by making a donation.
Thanks in advance!
下载 Individual Signs
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Individual Signs
下载 Individual Signs
下载 Individual Signs
下载 Individual Signs
下载 Individual Signs
下载 Individual Signs
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 Individual Signs
下载 Individual Signs
下载 Individual Signs
IndividualSigns v2.9.2 for MC 1.21.1 - 1.20.1
- 更新以支持 Spigot 1.20.1 及更高版本(感谢 Brokkonaut)。此版本不兼容旧版 Bukkit。
捐赠
如果您喜欢这个插件,请考虑给予捐赠。
谢谢!
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
通过对话框或铁砧界面帮助你的 Anthme
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
用于绘制游戏内地图或在浏览器中随探索实时进行地图绘制的实时地图。
评论 0
登录后参与评分
还没有评论,来抢沙发吧