Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import space.yurisi.universecorev2.subplugins.elevator.Elevator;
import space.yurisi.universecorev2.subplugins.evolutionitem.EvolutionItem;
import space.yurisi.universecorev2.subplugins.fishingsystem.FishingSystem;
import space.yurisi.universecorev2.subplugins.flysystem.Fly;
import space.yurisi.universecorev2.subplugins.gacha.Gacha;
import space.yurisi.universecorev2.subplugins.itemhat.ItemHat;
import space.yurisi.universecorev2.subplugins.freemarket.FreeMarket;
Expand Down Expand Up @@ -101,6 +102,8 @@ private void registerPlugin() {
this.subPlugins.add(new UniverseSlot());
this.subPlugins.add(new SpaceShip());
this.subPlugins.add(new Cooking());
this.subPlugins.add(new Fly());

}

public void onEnable() {
Expand Down
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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

プラグインの名前が FlySystem なのに Fly っていう命名規則は多分違う


@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";
}
}
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;
}
}
4 changes: 4 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,7 @@ commands:
#cooking:
cooking:
description: レシピを編集します

#fly
fly:
description: 飛行モードを切り替えます