Posted November 13, 201212 yr 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. I made the night vision mining hats mod. http://www.minecraftforum.net/topic/1830713-152forge-night-vision-mining-hats/
November 13, 201212 yr 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? I made the night vision mining hats mod. http://www.minecraftforum.net/topic/1830713-152forge-night-vision-mining-hats/
November 14, 201212 yr 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.
November 15, 201212 yr Author Could you give me the link to a tutorial because I can't find any. I made the night vision mining hats mod. http://www.minecraftforum.net/topic/1830713-152forge-night-vision-mining-hats/
November 15, 201212 yr The code I posted is everything you need to know. If you need more info, your issue stems deeper than this...
November 15, 201212 yr Author that not what I was looking for I need to save the player names and how much money they have into the file and I need to load the file then change the amount of money and save it again. I made the night vision mining hats mod. http://www.minecraftforum.net/topic/1830713-152forge-night-vision-mining-hats/
November 17, 201212 yr 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.
November 19, 201212 yr Author If you didn't want to help then please don't post I made the night vision mining hats mod. http://www.minecraftforum.net/topic/1830713-152forge-night-vision-mining-hats/
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.