Jump to content

Server side integer saving?


deadrecon98

Recommended Posts

I am going to try this again(even though last time it just ended up in a fit of frustration) to get something to save server-side. I have tried many many times to get this to work but no matter how hard I try I cannot get it to work properly. But as the title says, is all I need is to save an integer to the server(and for the client to get). I am going to say however that if you had helped me before on this and I was being mean to you I want to say sorry. Like I said I was just very frustrated that I could not get it to work and I am sorry for that. But other than that please feel free to post your solution!

Link to comment
Share on other sites

  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

What do you mean by "save an integer"?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Use java and a text file simple as that.

I am sorry but I do not see how that would work seeing that I need the server to be able to read and write to the same file.

 

You only need to read at one point:

When the server starts

You only need to write at one point:

When the server stops

 

(There's one additional write operation: if the file to read doesn't exist, initialize it).

 

There's no reason to be reading and writing to the same file at the same time (although you can).

 

That said:

Take a look at this post.  It will allow you to create and read an arbitrary NBT data file.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Use java and a text file simple as that.

I am sorry but I do not see how that would work seeing that I need the server to be able to read and write to the same file.

 

You only need to read at one point:

When the server starts

You only need to write at one point:

When the server stops

 

(There's one additional write operation: if the file to read doesn't exist, initialize it).

 

There's no reason to be reading and writing to the same file at the same time (although you can).

 

That said:

Take a look at this post.  It will allow you to create and read an arbitrary NBT data file.

 

Well the thing is that it will be constantly be edited.

Link to comment
Share on other sites

Editing the integer is not a problem at all. Even then the two points in time that you'll have to save/write to the file is when the server shuts down/starts up.

 

Because the rest of the time it's just a variable in memory! :D

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yes, but how would I get the server to save it?

 

Take a look at this post.  It will allow you to create and read an arbitrary NBT data file.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yes, but how would I get the server to save it?

 

Take a look at this post.  It will allow you to create and read an arbitrary NBT data file.

Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor

on NBTTagCompound compound = CompressedStreamTools.read(stream);

 

Does the same on every class.

Link to comment
Share on other sites

Send a PM to Veovis.  He's the one who figured it out and has a working codebase.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor

on NBTTagCompound compound = CompressedStreamTools.read(stream);

 

Does the same on every class.

...Handle the IOException.

 

[spoiler=Hint]

try/catch

 

 

Link to comment
Share on other sites

Default constructor cannot handle exception type IOException thrown by implicit super constructor. Must define an explicit constructor

on NBTTagCompound compound = CompressedStreamTools.read(stream);

 

Does the same on every class.

...Handle the IOException.

 

[spoiler=Hint]

try/catch

 

 

 

The code still does not work, it is not able to be used outside of the try/catch method.

Link to comment
Share on other sites

outside

 

*Cough*

 

Did you try inside the try/catch?

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Why not?

 

Because the code I need cannot be used. Let me explain..

 

try{

compound = whatever;

}catch{

//Exception Here

}

 

I cannot use compound anywhere else except for the try/catch statement.

 

Initiliaze the variable outside of the try catch like this

NBT compound = null;

 

try{

compound = CompressedStreamTools.read(stream);

}catch(Exception e){//handle}

 

now you can access the compound variable anywhere.

 

compound.whatEverTheHellYouNeed();

 

*******

 

If it helps toss me a thank you.

Link to comment
Share on other sites

Why not?

 

Because the code I need cannot be used. Let me explain..

 

try{

compound = whatever;

}catch{

//Exception Here

}

 

I cannot use compound anywhere else except for the try/catch statement.

 

Initiliaze the variable outside of the try catch like this

NBT compound = null;

 

try{

compound = CompressedStreamTools.read(stream);

}catch(Exception e){//handle}

 

now you can access the compound variable anywhere.

 

compound.whatEverTheHellYouNeed();

 

*******

 

If it helps toss me a thank you.

 

Yes! Thank you! I can now access it from outside of the try/catch. :D

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.




×
×
  • Create New...

Important Information

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