-
Notifications
You must be signed in to change notification settings - Fork 1
Flyコマンドの実装 #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
Merged
The head ref may contain hidden characters: "kimchi/spa-36-fly\u6A29\u9650\u306E\u4F5C\u6210"
Merged
Flyコマンドの実装 #272
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be4e7a4
Flyコマンドの実装(初期はOP以外入力不可)
kimchi5005 8dd44ba
Flyコマンドの実装(初期はOP以外入力不可)
kimchi5005 50d8be5
FlySystem に rename
m1sk9 712e67f
クラスの rename
m1sk9 eb4cc10
Merge remote-tracking branch 'origin/main' into kimchi/spa-36-fly権限の作成
m1sk9 340755d
ログアウト時に飛行が解除されるように
m1sk9 b4ae356
今の実装に合わせて書き直し
m1sk9 ad04e82
Revert "ログアウト時に飛行が解除されるように"
m1sk9 f41e579
Import の修正
m1sk9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/java/space/yurisi/universecorev2/subplugins/flysystem/Fly.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package space.yurisi.universecorev2.subplugins.flysystem; | ||
|
|
||
| import space.yurisi.universecorev2.UniverseCoreV2; | ||
| import space.yurisi.universecorev2.subplugins.SubPlugin; | ||
| import space.yurisi.universecorev2.subplugins.flysystem.command.FlyCommand; | ||
|
|
||
| public final class Fly implements SubPlugin { | ||
|
|
||
| @Override | ||
| public void onEnable(UniverseCoreV2 core) { | ||
| core.getCommand("fly").setExecutor(new FlyCommand()); | ||
| } | ||
|
|
||
| @Override | ||
| public void onDisable() { | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "fly"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getVersion() { | ||
| return "1.0.0"; | ||
| } | ||
| } | ||
52 changes: 52 additions & 0 deletions
52
src/main/java/space/yurisi/universecorev2/subplugins/flysystem/command/FlyCommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package space.yurisi.universecorev2.subplugins.flysystem.command; | ||
|
|
||
| import org.bukkit.command.Command; | ||
| import org.bukkit.command.CommandExecutor; | ||
| import org.bukkit.command.CommandSender; | ||
| import org.bukkit.entity.Player; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import java.util.Locale; | ||
|
|
||
| public class FlyCommand implements CommandExecutor { | ||
|
|
||
| @Override | ||
| public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
| // 実行者がプレイヤーか確認 サーバーなどプレイヤー以外ならエラーを出す | ||
| if (!(sender instanceof Player player)) { | ||
| sender.sendMessage("このコマンドはゲーム内から実行してください。"); | ||
| return false; | ||
| } | ||
|
|
||
| // 権限を確認 (fly という権限を持っているか) | ||
| // OPは最初から持っているが、Luckparmsで他のプレイヤーにも付与も可能 | ||
| if (!player.hasPermission("fly")) { | ||
| player.sendMessage("§cこのコマンドを実行する権限がありません。"); | ||
| return false; | ||
| } | ||
|
|
||
| // /fly のみだった場合 (onやoffなどの文字が入っていない場合) | ||
| if (args.length == 0) { | ||
| player.sendMessage("§c使い方が正しくありません: /fly <on|off>"); | ||
| return false; | ||
| } | ||
|
|
||
| // flymodeという変数を作ってそのコマンドを全て小文字にして返す | ||
| String flyMode = args[0].toLowerCase(Locale.ROOT); | ||
|
|
||
| switch (flyMode) { | ||
| case "on" -> { | ||
| player.setAllowFlight(true); | ||
| player.sendMessage("§a飛行モードを有効にしました。"); | ||
| } | ||
| case "off" -> { | ||
| player.setAllowFlight(false); | ||
| player.setFlying(false); // 飛行中にoffにした場合、その場で落下 | ||
| player.sendMessage("§a飛行モードを無効にしました。"); | ||
| } | ||
| default -> { | ||
| player.sendMessage("§cコマンドは on または off を指定してください。"); | ||
| } | ||
| } | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,3 +168,7 @@ commands: | |
| #cooking: | ||
| cooking: | ||
| description: レシピを編集します | ||
|
|
||
| #fly | ||
| fly: | ||
| description: 飛行モードを切り替えます | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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っていう命名規則は多分違う