forked from Upstream/mmocore
Added default values for playerdata in config.yml
This means you can now set the starting amount of most points, etc. without having to run commands on first player join!
This commit is contained in:
parent
529f805a1d
commit
ed9c86942b
@ -44,10 +44,6 @@
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.indyuce.mmocore.shaded.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.jasync.sql.db</pattern>
|
||||
<shadedPattern>eu.asangarin.sqltest</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -90,6 +86,12 @@
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
|
386
pom.xml
386
pom.xml
@ -1,199 +1,205 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.4.7</version>
|
||||
<name>MMOCore</name>
|
||||
<description>Offer your players a brand new RPG experience.</description>
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOCore</artifactId>
|
||||
<version>1.4.7</version>
|
||||
<name>MMOCore</name>
|
||||
<description>Offer your players a brand new RPG experience.</description>
|
||||
|
||||
<properties>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
<downloadSources>false</downloadSources>
|
||||
<downloadJavadocs>false</downloadJavadocs>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
<properties>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
<downloadSources>false</downloadSources>
|
||||
<downloadJavadocs>false</downloadJavadocs>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Releases</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Snapshots</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Releases</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<name>Lumine Snapshots</name>
|
||||
<url>http://mvn.lumine.io/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.indyuce.mmocore.shaded.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>${basedir}/src/main/resources/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-ea -Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
<shadedPattern>net.indyuce.mmocore.shaded.paperlib</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
|
||||
<!-- MMOs -->
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
<version>6.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- MMOs -->
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>mmoitems</artifactId>
|
||||
<version>6.1.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOItems.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- Minecraft -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R1-1.16-R2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- Minecraft -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R1-1.16-R2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/spigot.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!-- APIs -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- APIs -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>19.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.5</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Other Plugins -->
|
||||
<dependency>
|
||||
<groupId>com.bekvon.bukkit</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>4.8.7.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Residence.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.Zrips</groupId>
|
||||
<artifactId>CMI</artifactId>
|
||||
<version>8.6.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/CMI.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sainttx.holograms</groupId>
|
||||
<artifactId>holograms</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Holograms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost</groupId>
|
||||
<artifactId>HolographicDisplays</artifactId>
|
||||
<version>6.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/HolographicDisplays.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MythicMobs.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.25-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.7</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- Other Plugins -->
|
||||
<dependency>
|
||||
<groupId>com.bekvon.bukkit</groupId>
|
||||
<artifactId>Residence</artifactId>
|
||||
<version>4.8.7.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Residence.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.Zrips</groupId>
|
||||
<artifactId>CMI</artifactId>
|
||||
<version>8.6.5.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/CMI.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sainttx.holograms</groupId>
|
||||
<artifactId>holograms</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Holograms.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.gmail.filoghost</groupId>
|
||||
<artifactId>HolographicDisplays</artifactId>
|
||||
<version>6.9.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/HolographicDisplays.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.lumine.xikage</groupId>
|
||||
<artifactId>MythicMobs</artifactId>
|
||||
<version>4.8.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MythicMobs.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizens</artifactId>
|
||||
<version>2.0.25-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Citizens.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.7</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/PlaceholderAPI.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.12</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -161,13 +161,16 @@ public class MMOCore extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
new SpigotPlugin(70575, this).checkForUpdate();
|
||||
new Metrics(this);
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
if (getConfig().contains("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||
dataProvider = new MySQLDataProvider();
|
||||
|
||||
if(getConfig().isConfigurationSection("default-playerdata"))
|
||||
dataProvider.getDataManager().setDefaults(getConfig().getConfigurationSection("default-playerdata"));
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null)
|
||||
economy = new VaultEconomy();
|
||||
|
||||
@ -247,7 +250,6 @@ public class MMOCore extends JavaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
saveDefaultConfig();
|
||||
reloadPlugin();
|
||||
|
||||
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
|
||||
|
@ -6,8 +6,10 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.event.PlayerDataLoadEvent;
|
||||
import net.Indyuce.mmocore.api.player.OfflinePlayerData;
|
||||
@ -16,6 +18,7 @@ import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||
|
||||
public abstract class PlayerDataManager {
|
||||
// private final Map<UUID, PlayerData> map = new HashMap<>();
|
||||
private DefaultPlayerData defaults = new DefaultPlayerData();
|
||||
|
||||
public PlayerData get(OfflinePlayer player) {
|
||||
return get(player.getUniqueId());
|
||||
@ -48,7 +51,7 @@ public abstract class PlayerDataManager {
|
||||
* calls the load event on the MAIN thread
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||
loadData(generated);
|
||||
loadData(generated, defaults);
|
||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(generated)));
|
||||
generated.getStats().updateStats();
|
||||
});
|
||||
@ -63,9 +66,35 @@ public abstract class PlayerDataManager {
|
||||
return MMOPlayerData.getLoaded().stream().filter(data -> data.getMMOCore() != null).map(data -> data.getMMOCore()).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
public abstract void loadData(PlayerData data);
|
||||
public abstract void loadData(PlayerData data, DefaultPlayerData defaults);
|
||||
|
||||
public abstract void saveData(PlayerData data);
|
||||
|
||||
public abstract void remove(PlayerData data);
|
||||
|
||||
public void setDefaults(ConfigurationSection config) {
|
||||
defaults = new DefaultPlayerData(config);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public class DefaultPlayerData {
|
||||
private final int level, classPoints, skillPoints,
|
||||
attributePoints, attrReallocPoints;
|
||||
|
||||
public DefaultPlayerData(ConfigurationSection config) {
|
||||
level = config.getInt("level", 1);
|
||||
classPoints = config.getInt("class-points");
|
||||
skillPoints = config.getInt("skill-points");
|
||||
attributePoints = config.getInt("attribute-points");
|
||||
attrReallocPoints = config.getInt("attribute-realloc-points");
|
||||
}
|
||||
|
||||
public DefaultPlayerData() {
|
||||
level = 1;
|
||||
classPoints = 0;
|
||||
skillPoints = 0;
|
||||
attributePoints = 0;
|
||||
attrReallocPoints = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmocore.manager.data.mysql;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
@ -27,7 +28,7 @@ public class MySQLDataProvider implements DataProvider {
|
||||
config = new MySQLConfig(MMOCore.plugin.getConfig().getConfigurationSection("mysql"));
|
||||
connection = MySQLConnectionBuilder.createConnectionPool(config.getConnectionString());
|
||||
|
||||
executeUpdate("CREATE TABLE IF NOT EXISTS mmocore_playerdata (uuid VARCHAR(36),class_points INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,level INT(11) DEFAULT 0,experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,attributes JSON,professions JSON,quests JSON,waypoints JSON,friends JSON,skills JSON,bound_skills JSON,class_info JSON,PRIMARY KEY (uuid));");
|
||||
executeUpdate("CREATE TABLE IF NOT EXISTS mmocore_playerdata (uuid VARCHAR(36),class_points INT(11) DEFAULT 0,skill_points INT(11) DEFAULT 0,attribute_points INT(11) DEFAULT 0,attribute_realloc_points INT(11) DEFAULT 0,level INT(11) DEFAULT 1,experience INT(11) DEFAULT 0,class VARCHAR(20),guild VARCHAR(20),last_login LONG,attributes JSON,professions JSON,quests JSON,waypoints JSON,friends JSON,skills JSON,bound_skills JSON,class_info JSON,PRIMARY KEY (uuid));");
|
||||
}
|
||||
|
||||
public ResultSet getResult(String sql) {
|
||||
@ -35,6 +36,7 @@ public class MySQLDataProvider implements DataProvider {
|
||||
CompletableFuture<QueryResult> future = connection.sendPreparedStatement(sql);
|
||||
return future.get().getRows();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
MMOCore.log(Level.SEVERE, "MySQL Operation Failed!");
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -44,6 +46,7 @@ public class MySQLDataProvider implements DataProvider {
|
||||
try {
|
||||
connection.sendPreparedStatement(sql).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
MMOCore.log(Level.SEVERE, "MySQL Operation Failed!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -33,19 +33,26 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(PlayerData data) {
|
||||
public void loadData(PlayerData data, DefaultPlayerData defaults) {
|
||||
ResultSet result = provider
|
||||
.getResult("SELECT * FROM mmocore_playerdata WHERE uuid = '" + data.getUniqueId() + "';");
|
||||
if (result == null) {
|
||||
MMOCore.log(Level.SEVERE,
|
||||
"Failed to load playerdata of '" + data.getPlayer().getName() + "' from MySQL server");
|
||||
|
||||
// player data not initialized yet
|
||||
if (result.size() < 1) {
|
||||
data.setLevel(defaults.getLevel());
|
||||
data.setClassPoints(defaults.getClassPoints());
|
||||
data.setSkillPoints(defaults.getSkillPoints());
|
||||
data.setAttributePoints(defaults.getAttributePoints());
|
||||
data.setAttributeReallocationPoints(defaults.getAttrReallocPoints());
|
||||
data.setExperience(0);
|
||||
data.setMana(data.getStats().getStat(StatType.MAX_MANA));
|
||||
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
||||
data.setStellium(data.getStats().getStat(StatType.MAX_STELLIUM));
|
||||
data.getQuestData().updateBossBar();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// player data not initialized yet
|
||||
if (result.size() < 1)
|
||||
return;
|
||||
|
||||
RowData row = result.get(0);
|
||||
|
||||
data.setClassPoints(row.getInt("class_points"));
|
||||
@ -66,9 +73,8 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
data.getAttributes().load(row.getString("attributes"));
|
||||
if (!isEmpty(row.getString("professions")))
|
||||
data.getCollectionSkills().load(row.getString("professions"));
|
||||
String quests = row.getString("quests");
|
||||
if (!isEmpty(quests))
|
||||
data.getQuestData().load(quests);
|
||||
if (!isEmpty(row.getString("quests")))
|
||||
data.getQuestData().load(row.getString("quests"));
|
||||
data.getQuestData().updateBossBar();
|
||||
if (!isEmpty(row.getString("waypoints")))
|
||||
data.getWaypoints().addAll(getJSONArray(row.getString("waypoints")));
|
||||
@ -191,10 +197,9 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
level = row.getInt("level");
|
||||
lastLogin = row.getLong("last_login");
|
||||
profess = row.getString("class").equalsIgnoreCase("null")
|
||||
? MMOCore.plugin.classManager.getDefaultClass()
|
||||
profess = isEmpty(row.getString("class")) ? MMOCore.plugin.classManager.getDefaultClass()
|
||||
: MMOCore.plugin.classManager.get(row.getString("class"));
|
||||
if (!row.getString("friends").equalsIgnoreCase("null"))
|
||||
if (!isEmpty(row.getString("friends")))
|
||||
getJSONArray(row.getString("friends")).forEach(str -> friends.add(UUID.fromString(str)));
|
||||
else
|
||||
friends = new ArrayList<UUID>();
|
||||
|
@ -21,14 +21,14 @@ import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
||||
public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
@Override
|
||||
public void loadData(PlayerData data) {
|
||||
public void loadData(PlayerData data, DefaultPlayerData defaults) {
|
||||
FileConfiguration config = new ConfigFile(data.getPlayer()).getConfig();
|
||||
|
||||
data.setClassPoints(config.getInt("class-points"));
|
||||
data.setSkillPoints(config.getInt("skill-points"));
|
||||
data.setAttributePoints(config.getInt("attribute-points"));
|
||||
data.setAttributeReallocationPoints(config.getInt("attribute-realloc-points"));
|
||||
data.setLevel(config.getInt("level"));
|
||||
data.setClassPoints(config.getInt("class-points", defaults.getClassPoints()));
|
||||
data.setSkillPoints(config.getInt("skill-points", defaults.getSkillPoints()));
|
||||
data.setAttributePoints(config.getInt("attribute-points", defaults.getAttributePoints()));
|
||||
data.setAttributeReallocationPoints(config.getInt("attribute-realloc-points", defaults.getAttrReallocPoints()));
|
||||
data.setLevel(config.getInt("level", defaults.getLevel()));
|
||||
data.setExperience(config.getInt("experience"));
|
||||
if (config.contains("class"))
|
||||
data.setClass(MMOCore.plugin.classManager.get(config.getString("class")));
|
||||
|
@ -14,6 +14,15 @@ mysql:
|
||||
user: mmolover
|
||||
pass: ILoveAria
|
||||
|
||||
# The default values for all playerdata
|
||||
# All new players will start with these values
|
||||
default-playerdata:
|
||||
level: 1
|
||||
class-points: 0
|
||||
skill-points: 0
|
||||
attribute-points: 0
|
||||
attribute-realloc-points: 0
|
||||
|
||||
# The list of all conditions which must be met for the
|
||||
# BLOCK REGEN and BLOCK RESTRICTIONS to apply. Set to
|
||||
# 'custom-mine-conditions: []' to disable custom mining entirely.
|
||||
|
Loading…
Reference in New Issue
Block a user