Jump to content

Recommended Posts

Posted

I am trying to use World Capabilities to save data for all Players. It is currently working fine on the Client side. However, when I run it on a Dedicated Server, the event is never called. I even put a print statement to make sure that the event wasn't running. Is there another event I should use? How should I go about this?
 

   @SubscribeEvent
    public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
        System.out.println("Player Logged in"); 

		ServerPlayerEntity player = (ServerPlayerEntity) event.getPlayer();
        ServerWorld world = player.getServerWorld();
        LazyOptional<ICrystalLevel> crystalLevelCapability = world.getCapability(CrystalLevelProvider.CRYSTAL_LEVEL_CAPABILITY);
        ICrystalLevel crystalLevelInstance = crystalLevelCapability.orElse(new CrystalLevelInstance());
        crystalLevelInstance.setCrystalLevel(crystalLevel);
        
        player.getPersistentData().putInt("crystal_level", crystalLevel);
        SendAffinityToClientPlayer msg = new SendAffinityToClientPlayer(player.getUniqueID().toString(), crystalLevel);
        EtherGems.simpleChannel.send(PacketDistributor.PLAYER.with(() -> player), msg);
    }

 

Posted
57 minutes ago, sirfredrick said:

However, when I run it on a Dedicated Server, the event is never called

Strange, because the PlayerLoggedInEvent fires for me when I log on to a dedicated server. What version are you running? And how are you registering your event listener?

  • Thanks 1
Posted

Thanks I just needed someone else to check it! I was using a Docker container to run it before. I ran a fresh server and it worked perfectly! It must have been something with the Docker container or a setting in the config file! Thanks for helping!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.