Jump to content

Recommended Posts

Posted

As the title says. This is the only thing I've found:

world.getWorldInfo().getWorldName()

, which only returns the worlds name.

Thanks in advance.

No 5 row long documentation = account on the help forums

Posted

Haha I had the exact same problem just this morning :) I figured it out though, so don't worry.

 

Explanation via words:

First, you're going to need to get the server instance from ModLoader ( ModLoader.getMinecraftServerInstance() ). Then, you're going to need to get the folder name of the server instance ( .getFolderName() ). Store that for later. Next, get the ISaveFormat from the server instance ( .getActiveAnvilConverter() ). After that, obtain the SaveHandler from the ISaveFormat and give it the folder name we stored earlier as well as a boolean as to whether or not to mkdirs for the player folder (I just use false) ( .getSaveLoader(folderName, false) ). Then, just get the saveDirectory from the SaveHandler ( .getSaveDirectory() ).

 

Explanation via code:

MinecraftServer mcServerInstance = ModLoader.getMinecraftServerInstance();
String folderName = mcServerInstance.getFolderName();
ISaveFormat saveFormat = mcServerInstance.getActiveAnvilConverter();
SaveHandler saveHandler = (SaveHandler)saveFormat.getSaveLoader(folderName, false); // You will have to typecast here
File saveDir = saveHandler.getSaveDirectory();

 

Hope this helps! Ask any questions if you have them and I'll try to answer them.

Posted

Haha I had the exact same problem just this morning :) I figured it out though, so don't worry.

 

Explanation via words:

First, you're going to need to get the server instance from ModLoader ( ModLoader.getMinecraftServerInstance() ). Then, you're going to need to get the folder name of the server instance ( .getFolderName() ). Store that for later. Next, get the ISaveFormat from the server instance ( .getActiveAnvilConverter() ). After that, obtain the SaveHandler from the ISaveFormat and give it the folder name we stored earlier as well as a boolean as to whether or not to mkdirs for the player folder (I just use false) ( .getSaveLoader(folderName, false) ). Then, just get the saveDirectory from the SaveHandler ( .getSaveDirectory() ).

 

Explanation via code:

MinecraftServer mcServerInstance = ModLoader.getMinecraftServerInstance();
String folderName = mcServerInstance.getFolderName();
ISaveFormat saveFormat = mcServerInstance.getActiveAnvilConverter();
SaveHandler saveHandler = (SaveHandler)saveFormat.getSaveLoader(folderName, false); // You will have to typecast here
File saveDir = saveHandler.getSaveDirectory();

 

Hope this helps! Ask any questions if you have them and I'll try to answer them.

Thanks a lot for your answer. However I still got an error, and after printing the file path I saw it contained

a folder called MpServer. So I check when that occurs and return null, works so I'm happy.

No 5 row long documentation = account on the help forums

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.