-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
添加两个bot事件 #210
base: master
Are you sure you want to change the base?
添加两个bot事件 #210
Conversation
或许v姐准备1206改包名 |
你先别改包名。 |
删掉了包名更改,添加了一些实现上的变动( |
private String joinMessage; | ||
private Location createLocation; | ||
private boolean cancel = false; | ||
+ private final boolean isAsync; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我没有看明白为什么要存这个。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
防止有人异步操作bukkitapi
BotCreateState有同步和异步两个创建方法 /bot命令是异步创建
监听命令产生的创建事件并使用bkapi可能导致某些问题
有了这个就可以在监听器判断异步,避免上述问题了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
举个例子。?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
防止有人异步操作bukkitapi BotCreateState有同步和异步两个创建方法 /bot命令是异步创建 监听命令产生的创建事件并使用bkapi可能导致某些问题
有了这个就可以在监听器判断异步,避免上述问题了
这种应该分成两个事件(吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我没想明白什么情况下会出问题。
当然我觉得最优雅的解法是.then()传入lambda然后创建后调用(写js写的)。
而且应该是创建时而不是发送命令时发事件吧,真的有区别吗。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要不你给我描述下什么场景需要判断是否async做出不同行为。能不能全部按async算。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
要不你给我描述下什么场景需要判断是否async做出不同行为。能不能全部按async算。
举个例子,需要在假人创建时清空附近353的空间并在假人脚下创建一个3*3黑曜石平台
旧版的api根本不知道是否是主线程创建的,而操作世界必须在主线程,否则会有奇奇怪怪的bug和线程安全问题
唯一的解法就是用BukkitRunnable(但是真的所有人都会考虑到这里吗?
当然混用是没问题的,因为就算在同步事件用BkRunnable在下一刻处理也不会有什么大问题(除非有需要精细时序的内容)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那么是否async的处理的区别是什么。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那么是否async的处理的区别是什么。
像我说的,一旦有精细时序的需要,BkRunnable可能会有问题
你可以去看一下bkapi(尤其是paper),包含异步操作的内容都做了异步事件处理
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不应该单独作为一个patch,应该合并回0010-Fakeplayer-support.patch
2a93e5a
to
27634dd
Compare
或许在BotCreateEvent中添加Source Enum类去标明创建来源会更具有可拓展性 |
而不是单独来一个CreateByPlayerEvent |
|
我认为这样是正确的,或许可以
|
|
BotCreateByPlayerEvent
BotRemoveEvent
@MC-XiaoHei (doge
idea的refactor默认会删掉import(悲
https://intellij-support.jetbrains.com/hc/en-us/community/posts/17685814752530-Why-does-Refactor-suddenly-remove-unused-imports