-
Notifications
You must be signed in to change notification settings - Fork 1
Flyコマンドの実装(初期はOP以外入力不可) #272
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
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "kimchi/spa-36-fly\u6A29\u9650\u306E\u4F5C\u6210"
Conversation
src/main/java/space/yurisi/universecorev2/subplugins/flysystem/command/FlyCommand.java
Outdated
Show resolved
Hide resolved
| // OPは最初から持っているが、Luckparmsで他のプレイヤーにも付与も可能 | ||
| if (!player.hasPermission("fly")) { | ||
| player.sendMessage("§cこのコマンドを実行する権限がありません。"); | ||
| return true; |
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.
エラーのときはfalseを返すらしい
メルとバチバチに議論してくれ
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.
falseにしちゃうとusageが表示されちゃうからどうしようかとおもってたらusageを元から書いてなかった
めるとバチバチになってきます
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.
ここではっきりさせておくか.
Spigot / Bukkit の onCommand の返り値 true / false は内部的に次のような挙動をするのね.
true: Spigot / Bukkit はプレイヤーが実行したコマンドを 成功 として見なす.つまり「プラグイン側でメッセージも含めて全部処理し終わった」という合図として扱われる.false: Spigot / Bukkit はプレイヤーが実行したコマンドを 失敗 として見なす.usageが指定されている場合はプログラマーに変わって送ってあげる
usage を引数の表示として使う人が多いし,それは問題ないが,引数エラー以外のエラーを表現したいなら最初から usage を使わずに sendMessage() で引数を教えたほうが合理的だと思う.
|
|
||
| // 権限を確認 (fly という権限を持っているか) | ||
| // OPは最初から持っているが、Luckparmsで他のプレイヤーにも付与も可能 | ||
| if (!player.hasPermission("fly")) { |
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.
パーミッションは基本的に別プラグインと同じ名前空間 (入れ物みたいなもの) を使うので,名前衝突 (同じ値同士で衝突する) の可能性が存在する. fly というよくある単語を UniverseCoreV2 で独占するのは良くない.
それに LuckPerms で管理するのが目的なら尚更何のプラグインの何のパーミッションなのかを明示的にしてほしい.
例えば,universecorev2.player.fly とかね.LunaticChat とかがいい例になると思う.
それと基本的には plugin.yml でパーミッションを指定しないと LuckPerms が認識しないです.
指定し忘れないようにしてほしい.
( Paper プラグインの場合は別の方法があるけど, UniverseCoreV2 は Spigot / Bukkit コマンドとして開発してるので,基本はその作法に従うべき)
| // OPは最初から持っているが、Luckparmsで他のプレイヤーにも付与も可能 | ||
| if (!player.hasPermission("fly")) { | ||
| player.sendMessage("§cこのコマンドを実行する権限がありません。"); | ||
| return true; |
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.
ここではっきりさせておくか.
Spigot / Bukkit の onCommand の返り値 true / false は内部的に次のような挙動をするのね.
true: Spigot / Bukkit はプレイヤーが実行したコマンドを 成功 として見なす.つまり「プラグイン側でメッセージも含めて全部処理し終わった」という合図として扱われる.false: Spigot / Bukkit はプレイヤーが実行したコマンドを 失敗 として見なす.usageが指定されている場合はプログラマーに変わって送ってあげる
usage を引数の表示として使う人が多いし,それは問題ないが,引数エラー以外のエラーを表現したいなら最初から usage を使わずに sendMessage() で引数を教えたほうが合理的だと思う.
| import space.yurisi.universecorev2.subplugins.SubPlugin; | ||
| import space.yurisi.universecorev2.subplugins.flysystem.command.FlyCommand; | ||
|
|
||
| public final class Fly implements SubPlugin { |
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.
プラグインの名前が FlySystem なのに Fly っていう命名規則は多分違う
| import org.jetbrains.annotations.NotNull; | ||
| import java.util.Locale; | ||
|
|
||
| public class FlyCommand implements CommandExecutor { |
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.
スペース入ってる

Flyコマンドを実装します。
サバイバルモードでもFlyが使えるようになります
初期はOPのみが入力可能ですが
LuckPermsで入力可能な人を指定できます
Fly中落下ダメージを食らいません。
ログアウト時Flyは自動的に解除されます。