Closed Lumine1909 closed 6 days ago
或许v姐准备1206改包名
你先别改包名。
删掉了包名更改,添加了一些实现上的变动(
或许在BotCreateEvent中添加Source Enum类去标明创建来源会更具有可拓展性 例如分为API,Player,Console等
或许在BotCreateEvent中添加Source Enum类去标明创建来源会更具有可拓展性 例如分为API,Player,Console等
而不是单独来一个CreateByPlayerEvent
或许在BotCreateEvent中添加Source Enum类去标明创建来源会更具有可拓展性 例如分为API,Player,Console等
而不是单独来一个CreateByPlayerEvent 收到,确实是更好的想法 (edit) 我又想了一下,如果这样的话又变的麻烦了,监听玩家创建需要先判断是否来自玩家再获取,否则还有可能产生npe或者cce 看v姐怎么想吧(
或许在BotCreateEvent中添加Source Enum类去标明创建来源会更具有可拓展性 例如分为API,Player,Console等
而不是单独来一个CreateByPlayerEvent 收到,确实是更好的想法 (edit) 我又想了一下,如果这样的话又变的麻烦了,监听玩家创建需要先判断是否来自玩家再获取,否则还有可能产生npe或者cce 看v姐怎么想吧(
我认为这样是正确的,或许可以
event.getIfSource<Player>(Source.Player)
为什么不直接用已有的ConsoleSender和Player来区分呢
为什么不直接用已有的ConsoleSender和Player来区分呢
因为不一定是sender创建的 可能是api
conflict了 等1.21release我再开始搞吧( 外群来的不要急qwq 现在可以用小黑的方法 监听CommandPreProcess事件然后处理即可
新的版本加了reason和xxer两个字段 现在可以直接用类似bukkit command的形式判断了
private final Map<String, UUID> botOwnerMap = new HashMap<>();
@EventHandler
public void onBotCreate(BotCreateEvent e) {
if (e.getCreator().isPresent() && e.getCreator().get() instanceof Player player) {
botOwnerMap.put(e.getBot(), player.getUniqueId());
}
}
@EventHandler
public void onBotRemove(BotRemoveEvent e) {
if (e.getRemover().isPresent() && e.getRemover().get() instanceof Player player) {
if (!botOwnerMap.get(e.getBot().getName()).equals(player.getUniqueId())) {
player.sendMessage(ChatColor.RED + "You can't remove it because it is not your bot!");
}
}
}
重写BotCreateEvent 添加BotRemoveEvent