StrippedBroadcast 是对 Plugin RawMsg 的复刻。
该插件的主要目的是在聊天栏发送一条类似于 broadcast 命令的消息。然而,发送时消息不会带有前缀,且发送者可以指定一个玩家组来接收该消息。它还提供了一个可供任何开发者使用的 API。
命令
StrippedBroadcast 的主要且唯一的命令是,正如你所猜到的,/sbc(即 /simplebroadcast 的缩写)。其语法为:
/sbc <targets> <message>
正如插件自身在执行命令时所解释的那样,第一个参数应代表广播的目标。这些目标可以是:
- all,用于服务器上的所有在线玩家;
- <player> 或 player=<player>,仅指定的一名用户将看到该消息;
- me,命令执行者的别名;
- world=<world>,用于存在于该世界中的所有玩家;
- perm=<permission>,用于拥有该权限的任何玩家;
- op 或 perm=op,用于服务器上的所有 OP 玩家;
- group=<group>;StrippedBroadcast 与 LuckPerms 兼容,因此“group”参数允许用户指定特定的玩家组;
- item=<item>;用于服务器中持有该物品的所有玩家;
- effect=<effect>;用于拥有指定效果的所有玩家;
- gamemode=<gamemode>;用于处于该游戏模式的所有玩家;
- money=<money>;用于拥有该金额金币的所有玩家。
表达式
StrippedBroadcast 还能将表达式作为目标。用户可以指定某些条件,这些条件将返回一个兼容玩家的列表。
每个表达式都应括在括号内,但也可以在一个括号内嵌套更多括号。
示例:
/sbc (world=world_the_nether && (perm=bukkit.* || perm=minecraft.*)) Looks like you are the king of hell!
你还会注意到,表达式接受关键字 AND (&&) 和 OR (||)。它们的功能非常简单:
- 在上述示例中,OR 关键字用于获取拥有权限 "bukkit.*" 或 权限 "minecraft.*" 的所有玩家;
- 然后使用 AND 关键字来获取身处下界且拥有上述两个权限之一的玩家。
此外,该插件支持 Tab 补全功能,这将有助于提醒用户关闭括号或插入特定关键字。
权限
StrippedBroadcast 唯一的权限是 "sbc.main",它将允许用户执行 /sbc 命令。
颜色
自 Minecraft 1.16 更新以来,游戏中添加了十六进制颜色。现在,StrippedBroadcast 不仅能够使用默认的 Minecraft 颜色代码("&"),还能使用字符 # 来自定义颜色。如果你使用的是 1.16 或更高版本,当输入 "#" 时,插件会建议所有可用于颜色代码的有效字母和数字。此外,还有一种新的彩虹效果可用。要使用它,只需在消息前键入 [RAINBOW] 即可。示例:
/sbc all [RAINBOW] StrippedBroadcast v1.2 is an amazing plugin!
BungeeCord
最近发布了一个与 BungeeCord 兼容的 StrippedBroadcast 版本。它使用了与 Spigot 版本相同的功能,但部分参数有所变化:
- all,用于服务器中所有在线的玩家;
- player,唯一将看到该消息的用户;
- 服务器("server=<server>"),用于存在于该服务器中的玩家;
- 权限("perm=<permission>"),用于拥有该权限的任何玩家;
- 组("group=<group>"),用于属于该组的任何玩家(需要 LUCKPERMS)。
BungeeCord 也提供了 API,其命名方式与 Spigot API 相同,后加一个 "B"(例如 PlayerUtilsB 是插件 BungeeCord 部分的 PlayerUtils)。主类可通过名称 StrippedBroadcastBungee 访问,其中包含向玩家列表发送消息的所有方法。
API
老实说,我不确定这个插件 API 将如何被实现,但我非常好奇开发者们能创造出什么。无论如何,在你的项目中导入该插件后,你就可以开始使用了。有两个类是你需要关注的:
StrippedBroadcast
StrippedBroadcast 类包含静态方法 sendStrippedBroadcast。这会将给定的消息(它可以是字符串、字符串列表甚至数组)发送给指定的玩家列表。示例如下:
String[] strings = new String[]{"This", "is", "a", "cool", "message"};
StrippedBroadcastEvent.sendStrippedBroadcast(Bukkit.getOnlinePlayers(), strings);
StrippedBroadcastEvent 和 StrippedBroadcastEventB
StrippedBroadcastEvent 和 StrippedBroadcastEventB 是在使用插件命令或方法发送消息时调用的事件。它们包含两个变量:涉及的玩家列表和发送的消息。
@EventHandler
public void onMessageSent(StrippedBroadcastEvent event) {
event.getMessage();
}
@EventHandler
public void onBungeeMessageSent(StrippedBroadcastEventB event) {
event.getMessage();
}
PlayersUtil
PlayersUtil 类包含所有可用于根据特定输入获取玩家列表的方法。就像 /sbc 命令一样,PlayersUtil 支持任何类型的输入值,从世界、权限、游戏模式、玩家名称等等...
若要获取所有可用方法的更准确列表,你可以查看 GitHub 页面:
StrippedBroadcast is a recreation of the Plugin RawMsg.
The main purpose of the Plugin is to send a message in chat just like the command broadcast. However, when sent, the message will not dispose of a prefix and the sender can specify a group of players to send the message to. It also has an API available for any developer to be used.
Commands
The main and only command of StrippedBroadcast is, you guessed it, /sbc (short for /simplebroadcast). Its syntax is:
/sbc <targets> <message>
As explained by the Plugin itself when trying to execute the command, the first argument should represent the targets of the broadcast. These could be:
- all, for every player online on the server;
- <player> or player=<player>, the only user who will see the message;
- me, an alias for the command issuer;
- world=<world>, for every player present in that world;
perm=<permission>, for any player who has the permission;
- op or perm=op, for every op player in the server;
- group=<group>; StrippedBroadcast is compatible with LuckPerms, so the argument "group" will allow the user to specify a certain group of players;
- item=<item>; for every player who has that item in the server;
- effect=<effect>; for every player who the specified effect;
- gamemode=<gamemode>; for every player in that gamemode;
- money=<money>; for every player that has that amount of money.
Expressions
StrippedBroadcast is also able to understand expressions as target. The user will be able to specify certain conditions that will return a list of compatible players.
Every expression should be expressed in parenthesis, but there is possibility to put more parenthesis inside one.
Example:
/sbc (world=world_the_nether && (perm=bukkit.* || perm=minecraft.*)) Looks like you are the king of hell!
You will also notice that expressions accept the keywords AND (&&) and OR (||). Their functioning is really simple:
- in the above example, the OR keyword is used to get every player who has the permission "bukkit.*" or the permission "minecraft.*";
- the AND keyword is then used to get every player who is in the nether and has one of the two permissions.
Also, the plugin uses Tab Completition, so it will be very helpful at remembering the user to close parenthesis or insert certain keywords.
Permissions
The only permission for StrippedBroadcast is "sbc.main", which will allow the user to execute the /sbc command.
Colors
Since the Minecraft 1.16 update, Hex Colors were added to the game. Now, StrippedBroadcast is able not only to use the default Minecraft colors ("&"), but also custom ones using the character #. If you are on 1.16 or higher, when typing "#", the plugin will suggest all the valid letters and numbers to be used as color codes. Also, there is a new rainbow effect available. To use it, just type [RAINBOW] in front of your message. Example:
/sbc all [RAINBOW] StrippedBroadcast v1.2 is an amazing plugin!
BungeeCord
Recently a version of StrippedBroadcast compatible with BungeeCord was released. It uses the same functionalities as the Spigot one, however some argument do change:
- all, for every player online in the server;
- a player, the only user who will see the message;
- a server ("server=<server>"), for every player present in that server;
- a permission ("perm=<permission>"), for any player who has the permission;
- a group ("group=<group>"), for any player who is in that group (REQUIRES LUCKPERMS).
An API is available also for BungeeCord, that uses the same names as the Spigot API followed by a "B" (e.g. PlayerUtilsB is the PlayerUtils for the BungeeCord part of the Plugin). The Main Class is accessible by the name StrippedBroadcastBungee and it contains all of the methods to send a message to a list of players.
API
I honestly have no idea of how this Plugin API could be implemented, but I'm very curious to see what the developers will be able to create. Anyway, after importing the Plugin into your project, you are ready to begin. Two classes will be of your interest:
StrippedBroadcast
The class StrippedBroadcast contains the static method sendStrippedBroadcast. This will send the given message (it can be a string, a list of strings or even an array) to the list of players specified. An example is:
String[] strings = new String[]{"This", "is", "a", "cool", "message"};
StrippedBroadcastEvent.sendStrippedBroadcast(Bukkit.getOnlinePlayers(), strings);
StrippedBroadcastEvent and StrippedBroadcastEventB
The StrippedBroadcastEvent and StrippedBroadcastEventB are events called anytime a message is sent using the Plugin Command or the Methods. They contain two variables: a list of involved players and the message sent.
@EventHandler
public void onMessageSent(StrippedBroadcastEvent event) {
event.getMessage();
}
@EventHandler
public void onBungeeMessageSent(StrippedBroadcastEventB event) {
event.getMessage();
}
PlayersUtil
The PlayersUtil class contains all the methods that can be used to get list of players using certain input. Just like the /sbc command, PlayersUtil supports any kind of input value, from a world, to a permission, a gamemode, a player name and so on...
To get a more accurate list of all the available methods, you can check the GitHub page.
评论 0
登录后参与评分
还没有评论,来抢沙发吧