#NPC Action Bug ?

1 messages · Page 1 of 1 (latest)

cloud yew
#

I create an NPC here in my lobby system when I execute the action by clicking on it everything works but a second player comes on the server and clicks on the NPC nothing happens with the 2nd player and the 1st player is sent to the server what is the problem?

#
    public void spawnCityBuildNpc(Player player) {
        NpcData data = new NpcData("citybuild", player.getUniqueId(), locationManager.getLocation("lobby", "citybuild_npc").get());
        data.setSkin("Maaxxs_");
        data.setGlowing(true);
        data.setGlowingColor(NamedTextColor.GREEN);
        data.setDisplayName("<b><gradient:#00aa00:#55ff55>CityBuild</b>");
        data.setInteractionCooldown(5);
        data.setTurnToPlayer(true);

        data.setOnClick(clicker -> {
            connectToService(player,"CityBuild-1");
        });
        if (FancyNpcsPlugin.get().getNpcManager().getNpc(data.getName()) == null) {
            Npc npc = FancyNpcsPlugin.get().getNpcAdapter().apply(data);
            FancyNpcsPlugin.get().getNpcManager().registerNpc(npc);
            npc.create();

            Bukkit.getScheduler().runTaskAsynchronously(CoreSpigotPlugin.getInstance(), npc::spawnForAll);
        }
    }

here is my code

#

I think it's because I make NpcData data = new NpcData(“citybuild”, player.getUniqueId(), locationManager.getLocation(‘lobby’, “citybuild_npc”).get()); but I have to do that because he wants to have a CreatorUUID or how can I do it differently

main kite
#

You only need to spawn one npc at all, not one per player.

#

Change this:

data.setOnClick(clicker -> {
            connectToService(player,"CityBuild-1");
        });

to

data.setOnClick(clicker -> {
            connectToService(clicker,"CityBuild-1");
        });
cloud yew
#

its works thanks