Backport 1.20 changes and improvements
This commit is contained in:
parent
e4b59167f6
commit
15bca9670b
87 changed files with 10114 additions and 587 deletions
|
@ -0,0 +1,76 @@
|
|||
package dev.zontreck.libzontreck.config.sections;
|
||||
|
||||
import dev.zontreck.libzontreck.config.ServerConfig;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
||||
public class DatabaseSection
|
||||
{
|
||||
public static final String TAG_NAME = "database";
|
||||
public static final String TAG_USER = "username";
|
||||
public static final String TAG_PASSWORD = "password";
|
||||
public static final String TAG_HOST = "host";
|
||||
public static final String TAG_DATABASE = "database";
|
||||
public static final String TAG_VERSION = "rev";
|
||||
|
||||
|
||||
public String user = "root";
|
||||
public String password = "";
|
||||
public String host = "localhost:3306"; // IP:port
|
||||
public String database = "";
|
||||
public int version;
|
||||
|
||||
public static final int VERSION = 1;
|
||||
|
||||
public static DatabaseSection deserialize(CompoundTag tag)
|
||||
{
|
||||
DatabaseSection ret = new DatabaseSection();
|
||||
ret.version = tag.getInt(TAG_VERSION);
|
||||
|
||||
if(ret.version == 0)
|
||||
{
|
||||
ret.version = VERSION;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if(ret.version >= 1)
|
||||
{
|
||||
ret.user = tag.getString(TAG_USER);
|
||||
ret.password = tag.getString(TAG_PASSWORD);
|
||||
ret.host = tag.getString(TAG_HOST);
|
||||
ret.database = tag.getString(TAG_DATABASE);
|
||||
}
|
||||
|
||||
|
||||
ret.version = VERSION;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public DatabaseSection(){
|
||||
|
||||
}
|
||||
|
||||
public DatabaseSection(String user, String password, String host, String database)
|
||||
{
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
this.host = host;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public String getAsSQLFileName()
|
||||
{
|
||||
return database + ".sql";
|
||||
}
|
||||
|
||||
public CompoundTag serialize()
|
||||
{
|
||||
CompoundTag tag = new CompoundTag();
|
||||
tag.putString(TAG_USER, user);
|
||||
tag.putString(TAG_PASSWORD, password);
|
||||
tag.putString(TAG_HOST, host);
|
||||
tag.putString(TAG_DATABASE, database);
|
||||
tag.putInt(TAG_VERSION, version);
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
Reference in a new issue