BillyGalbreath / Pl3xMap

Pl3xMap is a minimalistic and lightweight world map viewer for Minecraft servers using the vanilla Minecraft rendering style
https://modrinth.com/plugin/pl3xmap
MIT License
3 stars 4 forks source link

[Enhancement] Hide players on map under conditions #173

Closed 42Willow closed 1 year ago

42Willow commented 1 year ago
BillyGalbreath commented 1 year ago

Sounds like a perfect addon if someone wants to make it.

Here's my initial untested thoughts on how one could possibly implement it:

    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
        if (!getConfig().getBoolean("hide-if-under-blocks")) {
            return; // feature disabled
        }
        Location from = event.getFrom();
        Location to = event.getTo();
        if (from.getWorld().equals(to.getWorld()) &&
                from.getBlockX() == to.getBlockX() &&
                from.getBlockY() == to.getBlockY() &&
                from.getBlockZ() == to.getBlockZ()) {
            return; // did not move
        }
        boolean underBlocks = to.getWorld().getHighestBlockYAt(to) > to.getBlockY() + 1;
        Pl3xMap.api().getPlayerRegistry().optional(event.getPlayer().getUniqueId())
                .ifPresent(player -> player.setHidden(underBlocks, false));
    }

    @EventHandler
    public void onPlayerSneak(PlayerToggleSneakEvent event) {
        if (!getConfig().getBoolean("hide-if-sneaking")) {
            return; // feature disabled
        }
        Pl3xMap.api().getPlayerRegistry().optional(event.getPlayer().getUniqueId())
                .ifPresent(player -> player.setHidden(event.isSneaking(), false));
    }
42Willow commented 1 year ago

Thanks time to learn java use github copilot

I'll work on this.

JasperTheMinecraftDev commented 1 year ago

Thanks time to ~learn java~ use github copilot

I'll work on this.

That's a lazy method of doing itπŸ˜› But hey, instead of relying solely on GitHub Copilot, why not dive into learning Java yourself? Trust me, AI can be a little mischievous at times and might lead you down a confusing path. Let's come together and conquer Java by truly understanding it, making mistakes, and learning from them. United we stand, united we learn Java like true champions! πŸ˜„πŸš€

(I'm not only kidding here, you should seriously learn java.)

42Willow commented 1 year ago

Thanks time to ~learn java~ use github copilot I'll work on this.

That's a lazy method of doing itπŸ˜› But hey, instead of relying solely on GitHub Copilot, why not dive into learning Java yourself? Trust me, AI can be a little mischievous at times and might lead you down a confusing path. Let's come together and conquer Java by truly understanding it, making mistakes, and learning from them. United we stand, united we learn Java like true champions! πŸ˜„πŸš€

(I'm not only kidding here, you should seriously learn java.)

I'll try it :)

maybe if someone doesn't do it for me :/