Jump to content

In-game change game mode


bkvaluemeal

Recommended Posts

You have to realize that there can always be multiple players. So you need to decide how to determine from the TickHandler which player's gamemode to change.

When exactly should the change happen?

 

I knew I would have to do that soon. I was planning on getting an array of all the online players and sorting through them one by one. I have it set to every 20 ticks to get the player's coordinates and compare them with a polygon. If you're inside it, then set the game mode to X.

Link to comment
Share on other sites

Good news! I made it work, and it is working just like I imagined. Although, the player gets spammed constantly with "your game mode has been changed" because of the tick handler. Any ideas how I could make it silent?

 

This is how I change the player's game mode.

MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername("username").setGameType(EnumGameType.SURVIVAL)

Link to comment
Share on other sites

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.