Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm trying to make a money mod and I need to be able to store the variable in a file. Whats the best / easiest thing to use to do this, java db, yaml, or xml? Also I cant figure out how to use any of them to save and load data so any tutorials will be very helpful.

  • Author

I think im going to try java db, im trying to use http://docs.oracle.com/javadb/10.8.2.2/getstart/index.html , so far I have

package economy.common;

import java.sql.*;

public class Data {

public static void init() throws SQLException{

    String sqlCreate = "CREATE TABLE IF NOT EXISTS Economy"
            + "  (player           VARCHAR(20),"
            + "   amount            INTEGER)";

	try {
		Connection db = DriverManager.getConnection("jdbc:derby:Economy;create=true");
		db.createStatement().execute(sqlCreate);
		System.out.println("Economy successfully connected to the database");
		} 
	catch (Throwable e) {	
		System.out.println("Economy failed to connected to the database");
		}

}

public void load() throws SQLException {
	Connection db = DriverManager.getConnection("jdbc:derby:economy;create=true");



	db.close();
}


public void save(String player, String amount) throws SQLException {
	Connection db = DriverManager.getConnection("jdbc:derby:economy;create=true");



	db.close();
}

}

 

but it wont start and connect to the database. Why is it not starting it?

Why use a db? For minecraft servers that is more than you need, you just need packet handling and a local map. I recommended using minecraft's built in compressor for saving and loading. maps can be saved directly to the disk and reloaded:

http://www.minecraftforge.net/forum/index.php/topic,3211.msg21401.html#msg21401

 

That is the easiest option because after the save and load, you just use the map normally. Forge offers an event on the event bus so you can save when the world saves.

I am not going to hold your hand, look up how maps work, and learn how java works in general, and then maybe I will help.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.