Necrify
Necrify 是一个专为目前
Velocity(以及
未来可能支持的 Paper/BungeeCord)设计的惩罚插件。
目录
- 插件安装
- 禁言(仅影响 Velocity)
- 持续时间
- 命令
- API
插件安装
您的服务器必须运行在 Java 25 或更高版本上。
- 下载最新版本的插件 或在此处下载开发构建
版本(可能不稳定或无法正常工作)
- 将下载的文件放入服务器的
plugins 文件夹中。
- (重新)启动服务器。
禁言
自 Minecraft 1.19.1 起,Minecraft 的聊天系统发生了更改(详细说明)。
从此之后,由于签名聊天的消息,不再可能通过 Velocity 的 ChatEvent 来阻止聊天消息。
因此,聊天监听器不再阻止任何消息,这意味着禁言功能实际上已失效。解决此问题的方法是开发一个用于实际游戏服务器的扩展插件,在该插件中取消这些消息仍然是可能的。该 Paper 插件的下载可在
发布页面 找到,也可以在 Jenkins 上的 开发构建 中找到。
有关 1.19.1 的更多信息,请参阅
官方发行说明
命令
所有命令均以 /necrify 为前缀注册。此外,通过将 allow-top-level-commands 设置为 true(默认即为 true),还可以注册顶级命令。
图例:
- <arg> 表示该参数是必需的
- [arg] 表示该参数是可选的
- 参数名为 player 表示需要玩家名称或 UUID
- reason 表示支持 MiniMessage 格式的原因说明
- duration 作为参数名表示 持续时间
命令概览
- /ban <player> [reason] 永久封禁玩家,使用给定或默认原因
- /mute <player> [reason] 永久禁言玩家,使用给定或默认原因
- /tempban <player> <duration> [reason] 根据给定的持续时间封禁玩家,使用给定或默认原因
- /tempmute <player> <duration> [reason] 根据给定的持续时间禁言玩家,使用给定或默认原因
- /unban <player> 解除对指定玩家的封禁
- /unmute <player> 解除对指定玩家的禁言
- /necrify user <player> <info|delete|whitelist> 显示有关玩家惩罚及其白名单状态的信息,删除该用户及其所有惩罚,或反转其白名单状态(从白名单变为黑名单,反之亦然)
- /necrify punishment <punishment id> <cancel|change|info|remove> 取消/移除、更改或显示有关给定惩罚(必须是 UUID)的信息
持续时间
要由 PunishmentDuration#parse(String) 解析,字符串必须遵循以下格式:
[0-9][s, m, h, d]
s - 秒
m - 分钟
h - 小时
d - 天
这些值可以组合,也可以全部省略。
示例:1d12h15m30s 表示持续时间为 1 天 12 小时 15 分钟 30 秒。
惩罚 API
安装
将 {version} 替换为当前版本号,例如 1.2.3。最新版本可在 此处 找到。
请注意,您只需使用 necrify-{platform}- 之后的字符串部分,并去除版本号后的构建编号。
Gradle (kotlin)
repositories {
mavenCentral()
}
depenencies {
implementation("de.jvstvshd.necrify:necrify-api:{version}")
}
Gradle (groovy)
repositories {
mavenCentral()
}
dependencies {
implementation 'de.jvstvshd.necrify:necrify-api:{version}'
}
Maven
<dependencies>
<dependency>
<groupId>de.jvstvshd.necrify</groupId>
<artifactId>necrify-api</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
您还可以依赖插件模块或公共模块。为此,请将 artifactId 替换为所需的模块名称。
请注意,API 模块之外的代码始终可能发生变化,且可能不稳定。它也不旨在允许插件本身之外进行访问和修改,并且通常没有文档记录。
用法
获取 API 实例
如果使用 插件,您可以使用以下代码片段获取 API 实例:
try {
Necrify api = (Necrify) server.getPluginManager().getPlugin("necrify").orElseThrow().getInstance().orElseThrow();
} catch(NoSuchElementException e) {
logger.error("Punishment API is not available");
}
对玩家执行惩罚
所有惩罚都是通过对目标用户发起的。例如,封禁玩家可以这样做:
//首先,获取用户实例
NecrifyUser user = api.getUserManager().getUser(uuid).orElseThrow(() -> new NoSuchElementException("未找到该用户"));
MiniMessage miniMessage = MiniMessage.miniMessage();
//临时封禁:
Ban temporaryBan = user.ban(PunishmentDuration.parse(miniMessage.deserialize("<red>你违反了服务器规则!不要作弊!"), PunishmentDuration.parse("1d"))).join();//1d 等于 1 天,持续时间相对于施加惩罚的当前时间。
//永久封禁:
Ban permanentBan = user.banPermanent(miniMessage.deserialize("<red>你又违反了服务器规则!你将不再被允许加入!")).join();
//通过 #join 获取的封禁实例即为已发出的惩罚。请注意,使用 #join 会阻塞当前线程,
//由于数据库操作需要一些时间才能完成,建议使用 #whenComplete 或其他异步方法。
//现在你可以使用该实例来更改或取消惩罚:
temporaryBan.cancel().whenComplete((punishment, throwable) -> {
if(throwable != null) {
logger.error("取消惩罚时发生错误", throwable);
return;
}
logger.info("惩罚已成功取消");
});
//#cancel 应始终返回调用该方法时所基于的同一实例
//即使对永久封禁发出了无限期的处罚,你仍然可以更改持续时间和原因:
permanentBan.change(PunishmentDuration.parse("300d"), miniMessage.deseriaize("<green>好的,你可以在 300 天后再次加入!")).whenComplete((punishment, throwable) -> {
if(throwable != null) {
logger.error("更改惩罚时发生错误", throwable);
return;
}
logger.info("惩罚已成功更改");
});
禁言玩家与此类似,只需将 'ban' 替换为 'mute'。
踢出玩家可以通过调用 user.kick(Reason).join(); 来完成,由于没有同步执行数据库查询,因此安全地调用 #join 是可行的。这种形式的惩罚无法更改或取消,因为它仅作用于瞬间。
Necrify
Necrify is a punishment plugin designed for currently
Velocity (and
maybe Paper/BungeeCord in the future).
Table of contents
- Plugin installation
- Mutes (only affects Velocity)
- Duration
- Commands
- API
Plugin installation
Your server must be running on Java 25 or higher.
- Download the latest version of the plugin or download dev
builds here (may be unstable or not working)
- Put the downloaded file into the
plugins folder of your server.
- (Re-)Start the server.
Mutes
With the 1.19.1, Minecraft's chat system got
changed (detailed explanation).
Since then, it is no longer possible to block chat messages in the ChatEvent of Velocity due to the signed chat
messages.
This is why the chat listener does not block any messages anymore which means mutes are effectively useless. A solution
to this problem is developing an extension plugin for the actual game servers where cancelling these messages is still
possible. Downloads for this paper plugin are found in
the releases and also
as dev builds on Jenkins.
For further information about 1.19.1, please refer to
the official release notes
Commands
All commands are registered with the prefix /necrify. Moreover, it is possible to register top-level commands too by
setting allow-top-level-commands to true (which is per default)
legend:
- <arg> means the argument is required
- [arg] means the argument is optional
- player as argument name means the a player name OR uuid is required
- reason means a reason that supports MiniMessage
- duration as argument name means a duration
Command overview
- /ban <player> [reason] bans a player permanently for the given or the default reason
- /mute <player> [reason] mutes a player permanently for the given or the default reason
- /tempban <player> <duration> [reason] bans a player for the given duration for the given or the default reason
- /tempmute <player> <duration> [reason] mutes a player for the given duration for the given or the default reason
- /unban <player> unbans the given player
- /unmute <player> unmutes the given player
- /necrify user <player> <info|delete|whitelist> shows either information about a player's punishments and his whitelist status,
deletes this user including all punishments or inverts his whitelist status (from whitelisted to blacklisted or vice versa)
- /necrify punishment <punishment id> <cancel|change|info|remove> cancels/removes, changes or shows information about the
given punishment(must be a uuid)
Duration
To be parsed by PunishmentDuration#parse(String), a string must follow this scheme:
[0-9][s, m, h, d]
s - second(s)
m - minute(s)
h - hour(s)
d - day(s)
These value can be composed, all of them can be omitted.
Example: 1d12h15m30s means a duration of 1 day, 12 hours, 15 minutes and 30 seconds.
Punishment API
Installation
Replace {version} with the current version, e.g. 1.2.3. The latest version can be found here.
Note that you only want to use the string after necrify-{platform}- and without the version build number.
Gradle (kotlin)
repositories {
mavenCentral()
}
depenencies {
implementation("de.jvstvshd.necrify:necrify-api:{version}")
}
Gradle (groovy)
repositories {
mavenCentral()
}
dependencies {
implementation 'de.jvstvshd.necrify:necrify-api:{version}'
}
Maven
<dependencies>
<dependency>
<groupId>de.jvstvshd.necrify</groupId>
<artifactId>necrify-api</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
You can also depend on the plugin modules or common module. In order to do so, replace the artifactId with the desired module name.
Note that code outside the API module is always subject to change and may not be stable. It is also not designed to allow
access and modifications from outside the plugin itself and is often not documented.
Usage
Obtaining an instance of the api
If the plugin is used, you can obtain an instance of the api using the following snippet:
try {
Necrify api = (Necrify) server.getPluginManager().getPlugin("necrify").orElseThrow().getInstance().orElseThrow();
} catch(NoSuchElementException e) {
logger.error("Punishment API is not available");
}
Punishing a player
All punishments are issued via the target user. For example, banning a player could be done this way:
//Firstly, obtain the user instance
NecrifyUser user = api.getUserManager().getUser(uuid).orElseThrow(() -> new NoSuchElementException("User not found"));
MiniMessage miniMessage = MiniMessage.miniMessage();
//temporary ban:
Ban temporaryBan = user.ban(PunishmentDuration.parse(miniMessage.deserialize("<red>You broke the server's rules! Don't cheat!"), PunishmentDuration.parse("1d"))).join();//1d equals 1 day, the duration is relative to the current time until the punishment is imposed.
//permanent ban:
Ban permanentBan = user.banPermanent(miniMessage.deserialize("<red>You broke the server's rules again! You are not allowed to join someday again!")).join();
//The ban instance you get via #join is the punishment that was issued. Note that using #join blocks the current
//Thread and since database operations take some time to complete, it is recommended to use #whenComplete or other.
//You can now use this instance to change or cancel the punishment:
temporaryBan.cancel().whenComplete((punishment, throwable) -> {
if(throwable != null) {
logger.error("An error occurred while cancelling the punishment", throwable);
return;
}
logger.info("The punishment was successfully cancelled");
});
//#cancel should always return the same instance that you called the method on
//Event tough a permanent ban was issued for an indefinite time, you can still change the duration and the reason:
permanentBan.change(PunishmentDuration.parse("300d"), miniMessage.deseriaize("<green>Okay, you may join again in 300 days!")).whenComplete((punishment, throwable) -> {
if(throwable != null) {
logger.error("An error occurred while changing the punishment", throwable);
return;
}
logger.info("The punishment was successfully changed");
});
Muting a player is similar, just replace 'ban' with 'mute'.
Kicking a player can be done by calling user.kick(Reason).join(); where it is safe to call #join since there is no
database query done synchronously. This form of punishment cannot be changed nor cancelled as it only lasts a single moment.
评论 0
登录后参与评分
还没有评论,来抢沙发吧