[Java][求助][Minecraft]spigot插件编写求助
如何监听玩家进入事件?比如说,如何做到玩家进服时检测UUID开头是不是abcdef,不是就踢出? 可以在他们注册前加个abcd 然后再进入时候做校验 或者使用redis实现 这你去mcbbs找啊,注册监听器,有玩家加入事件的,看看spigot的javadoc就行了
https://hub.spigotmc.org/javadocs/spigot/overview-summary.html
PlayerJoinEvent
Called when a player joins a server
PlayerLoginEvent
Stores details for players attempting to log in.
PlayerPreLoginEvent Deprecated.
This event causes synchronization from the login thread; AsyncPlayerPreLoginEvent is preferred to keep the secondary threads asynchronous.
不应该去什么别的论坛嘛。{:1_925:} hlrlqy 发表于 2020-3-1 16:00
这你去mcbbs找啊,注册监听器,有玩家加入事件的,看看spigot的javadoc就行了
https://hub.spigotmc.org/j ...
QwQ编译错误 MCBBS更适合你 huzpsb 发表于 2020-3-1 16:10
QwQ编译错误
review代码把,错误也不贴怎么帮你 lu_ 发表于 2020-3-1 16:12
MCBBS更适合你
说得像是我没有去过似的?我ID都是一样的欸 本帖最后由 Barnes 于 2020-5-13 15:48 编辑
新建一个class,什么名字都可以,我这里叫PlayerJoinListenerpublic class PlayerJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();//取得玩家
UUID uuid = player.getUniqueId();//取得UUID
if (!uuid.toString().startsWith("abcdef")) {//如果UUID不以abcdef开头
player.kickPlayer("UUID错误");//已UUID错误的理由踢出玩家
}
}
}
然后在主类里面写 @Override
public void onEnable() {
this.getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);//注册监听器
}
页:
[1]