Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Feb 11, 2023

システムが完成しました。
デバッグを行っていないため、バグは不明

@ghost ghost requested a review from kigawa01 February 11, 2023 10:49
@kigawa01
Copy link
Member

建築範囲は全員同じなので一か所にRangeを保存しておくほうがいいと思います
プレーヤー参加時にロードするのではなくてプラグイン初期化時にロードしてそれを参照できないですか?

@ghost
Copy link
Author

ghost commented Feb 11, 2023

建築範囲は全員同じなので一か所にRangeを保存しておくほうがいいと思います プレーヤー参加時にロードするのではなくてプラグイン初期化時にロードしてそれを参照できないですか?

指摘ありがとうございます。申し訳ないです、建築範囲の自分の中での解釈が違いました。修正しておきます。


public void setup() {
File file = new File(plugin.getDataFolder() + "/PlayerData/", "");
File file = new File(plugin.getDataFolder().toURI());
Copy link
Member

Choose a reason for hiding this comment

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

File file = plugin.getDataFolder();

でいけますよ

setMaxLoc(locMaxClone);
}

public boolean isPlayerWithinBound(Location loc) {
Copy link
Member

Choose a reason for hiding this comment

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

確認するのがplayerに限らないのでisInBoundとかのほうがわかりやすいと思います

}

if (strings[0].equals("info")) {
p.sendMessage(infoLoc());
Copy link
Member

Choose a reason for hiding this comment

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

範囲が未登録の場合エラーが出ました

}

}

Copy link
Member

Choose a reason for hiding this comment

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

こんな感じでブロックの破戒の対応とディスペンサーとピストンと溶岩と水による精製もキャンセルしてほしいです!

    @EventHandler
    public void onBlockEvent(BlockPlaceEvent e) {
        blockEvent(e, e.getPlayer());
    }

    @EventHandler
    public void onBlockEvent(BlockBreakEvent e) {
        blockEvent(e, e.getPlayer());
    }
  
    private void blockEvent(@NotNull BlockEvent blockEvent, @Nullable Player player) {
        final var block = blockEvent.getBlock();
        if (!(blockEvent instanceof Cancellable cancellable)) return;

        if (!block.getWorld().getName().equals(HakoniwaCore.getWorldName())) return;

        if (player != null && player.getGameMode().equals(GameMode.CREATIVE)) return;

        Location blockLocation = block.getLocation();

        if (!HakoniwaCore.getRange().getBound().isPlayerWithinBound(blockLocation)) {
            cancellable.setCancelled(true);
            if (player != null) player.sendMessage(Utils.message("§cここにブロックを置くことは出来ません"));
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant