mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
Small cleanup
This commit is contained in:
parent
ed9c86942b
commit
68f77205dd
@ -169,7 +169,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
dataProvider = new MySQLDataProvider();
|
dataProvider = new MySQLDataProvider();
|
||||||
|
|
||||||
if(getConfig().isConfigurationSection("default-playerdata"))
|
if(getConfig().isConfigurationSection("default-playerdata"))
|
||||||
dataProvider.getDataManager().setDefaults(getConfig().getConfigurationSection("default-playerdata"));
|
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null)
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null)
|
||||||
economy = new VaultEconomy();
|
economy = new VaultEconomy();
|
||||||
@ -377,7 +377,7 @@ public class MMOCore extends JavaPlugin {
|
|||||||
skillManager.reload();
|
skillManager.reload();
|
||||||
|
|
||||||
mineManager.clear();
|
mineManager.clear();
|
||||||
mineManager.reload(getConfig().getBoolean("protect-custom-mine"));
|
mineManager.reload();
|
||||||
|
|
||||||
fishingManager.clear();
|
fishingManager.clear();
|
||||||
alchemyManager.clear();
|
alchemyManager.clear();
|
||||||
|
@ -36,33 +36,47 @@ public class BlockListener implements Listener {
|
|||||||
String savedData = event.getBlock().getBlockData().getAsString();
|
String savedData = event.getBlock().getBlockData().getAsString();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
|
||||||
final boolean regen = MMOCore.plugin.mineManager.isRegenerating(block);
|
|
||||||
if(regen && !MMOCore.plugin.mineManager.isBlockRegistered(block)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if custom mining enabled, check for item breaking restrictions
|
* Check for custom mining in the current region first.
|
||||||
*/
|
*/
|
||||||
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player, block.getLocation());
|
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player, block.getLocation());
|
||||||
if (!customMine)
|
if (!customMine)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
/*
|
||||||
if (info == null) {
|
* If the block is a temporary block, immediately cancel the break event
|
||||||
if(MMOCore.plugin.mineManager.shouldProtect())
|
*/
|
||||||
|
if (MMOCore.plugin.mineManager.isTemporaryBlock(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the block has exp or drop tables
|
||||||
|
*/
|
||||||
|
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block);
|
||||||
|
if (info == null) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If players are prevented from breaking blocks in custom mining
|
||||||
|
* regions
|
||||||
|
*/
|
||||||
|
if (MMOCore.plugin.mineManager.shouldProtect())
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extra breaking conditions.
|
||||||
|
*/
|
||||||
if (!info.getBlock().breakRestrictions(block)) {
|
if (!info.getBlock().breakRestrictions(block)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calls the event and listen for cancel & for drops changes... also
|
* Calls the event and listen for cancel & for drops changes... also
|
||||||
* allows to apply tool durability & enchants to drops, etc.
|
* allows to apply tool durability & enchants to drops, etc.
|
||||||
*/
|
*/
|
||||||
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
|
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
|
||||||
@ -80,7 +94,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remove vanilla drops if needed
|
* Remove vanilla drops if needed
|
||||||
*/
|
*/
|
||||||
if (!info.hasVanillaDrops()) {
|
if (!info.hasVanillaDrops()) {
|
||||||
// event.setDropItems(false); // May not work
|
// event.setDropItems(false); // May not work
|
||||||
@ -89,7 +103,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* apply triggers, add experience info to the event so the other events
|
* Apply triggers, add experience info to the event so the other events
|
||||||
* can give exp to other TOOLS and display HOLOGRAMS
|
* can give exp to other TOOLS and display HOLOGRAMS
|
||||||
*/
|
*/
|
||||||
if (info.hasTriggers() && !block.hasMetadata("player_placed")) {
|
if (info.hasTriggers() && !block.hasMetadata("player_placed")) {
|
||||||
@ -107,7 +121,7 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* apply drop tables
|
* Apply drop tables
|
||||||
*/
|
*/
|
||||||
if (info.hasDropTable()) {
|
if (info.hasDropTable()) {
|
||||||
Location dropLocation = getSafeDropLocation(block,
|
Location dropLocation = getSafeDropLocation(block,
|
||||||
@ -118,10 +132,10 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* enable block regen.
|
* Finally enable block regen.
|
||||||
*/
|
*/
|
||||||
if (info.hasRegen())
|
if (info.hasRegen())
|
||||||
MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()), !regen);
|
MMOCore.plugin.mineManager.initialize(info.startRegeneration(Bukkit.createBlockData(savedData), block.getLocation()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -82,38 +82,56 @@ public class CustomBlockManager extends MMOManager {
|
|||||||
return new VanillaBlockType(block);
|
return new VanillaBlockType(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(RegeneratingBlock info, boolean schedule) {
|
public void initialize(RegeneratingBlock info) {
|
||||||
if(schedule) {
|
// if (schedule) {
|
||||||
active.add(info);
|
active.add(info);
|
||||||
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> regen(info, false), info.getRegeneratingBlock().getRegenerationInfo().getTime());
|
Bukkit.getScheduler().runTaskLater(MMOCore.plugin, () -> regen(info, false), info.getRegeneratingBlock().getRegenerationInfo().getTime());
|
||||||
}
|
// }
|
||||||
if (info.getRegeneratingBlock().getRegenerationInfo().hasTemporaryBlock())
|
if (info.getRegeneratingBlock().getRegenerationInfo().hasTemporaryBlock())
|
||||||
info.getRegeneratingBlock().getRegenerationInfo().getTemporaryBlock().place(info.getLocation(), info);
|
info.getRegeneratingBlock().getRegenerationInfo().getTemporaryBlock().place(info.getLocation(), info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a block regens, either due to regen timer or because the
|
||||||
|
* server shuts down.
|
||||||
|
*
|
||||||
|
* @param info
|
||||||
|
* Block which must be regened
|
||||||
|
* @param shutdown
|
||||||
|
* Must be set to true if the server is shutting down. When the
|
||||||
|
* server shuts down, it iterates through active blocks. This
|
||||||
|
* prevents any issue when editing lists being iterated
|
||||||
|
*/
|
||||||
private void regen(RegeneratingBlock info, boolean shutdown) {
|
private void regen(RegeneratingBlock info, boolean shutdown) {
|
||||||
Location infoLocation = info.getLocation();
|
Location infoLocation = info.getLocation();
|
||||||
|
|
||||||
// Get the chunk and load it async if needed.
|
// Get the chunk and load it async if needed.
|
||||||
PaperLib.getChunkAtAsync(infoLocation).whenComplete((chunk, ex) -> {
|
PaperLib.getChunkAtAsync(infoLocation).whenComplete((chunk, ex) -> {
|
||||||
info.getRegeneratingBlock().getBlock().place(infoLocation, info);
|
info.getRegeneratingBlock().getBlock().place(infoLocation, info);
|
||||||
info.getLocation().getBlock().getState().update();
|
info.getLocation().getBlock().getState().update();
|
||||||
if(!shutdown) active.remove(info);
|
if (!shutdown)
|
||||||
|
active.remove(info);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* called when the server disables so every mined block which was in timer
|
* Called when the server disables so every mined block which was in timer
|
||||||
* are reset and put back in place.
|
* are reset and put back in place.
|
||||||
*/
|
*/
|
||||||
public void resetRemainingBlocks() {
|
public void resetRemainingBlocks() {
|
||||||
active.forEach(info -> regen(info, true));
|
active.forEach(info -> regen(info, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegenerating(Block block) {
|
/**
|
||||||
|
* @param block
|
||||||
|
* Potentially vanilla block being broken by a player
|
||||||
|
* @return Returns if the block being broken is a temporary block. If it is,
|
||||||
|
* players should not be able to break it
|
||||||
|
*/
|
||||||
|
public boolean isTemporaryBlock(Block block) {
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
for (RegeneratingBlock info : active)
|
for (RegeneratingBlock info : active)
|
||||||
if(info.getLocation().getBlockX() == loc.getBlockX()
|
if (info.getLocation().getBlockX() == loc.getBlockX() && info.getLocation().getBlockY() == loc.getBlockY()
|
||||||
&& info.getLocation().getBlockY() == loc.getBlockY()
|
|
||||||
&& info.getLocation().getBlockZ() == loc.getBlockZ())
|
&& info.getLocation().getBlockZ() == loc.getBlockZ())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -125,7 +143,8 @@ public class CustomBlockManager extends MMOManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEnabled(Entity entity, Location loc) {
|
public boolean isEnabled(Entity entity, Location loc) {
|
||||||
if(customMineConditions.isEmpty()) return false;
|
if (customMineConditions.isEmpty())
|
||||||
|
return false;
|
||||||
|
|
||||||
ConditionInstance conditionEntity = new ConditionInstance(entity, loc);
|
ConditionInstance conditionEntity = new ConditionInstance(entity, loc);
|
||||||
for (Condition condition : customMineConditions)
|
for (Condition condition : customMineConditions)
|
||||||
@ -144,19 +163,19 @@ public class CustomBlockManager extends MMOManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If block breaking should be denied in custom mining regions
|
||||||
|
*/
|
||||||
public boolean shouldProtect() {
|
public boolean shouldProtect() {
|
||||||
return protect;
|
return protect;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reload(boolean protect) {
|
|
||||||
this.protect = protect;
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
customMineConditions.clear();
|
customMineConditions.clear();
|
||||||
|
|
||||||
|
this.protect = MMOCore.plugin.getConfig().getBoolean("protect-custom-mine");
|
||||||
|
|
||||||
for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions"))
|
for (String key : MMOCore.plugin.getConfig().getStringList("custom-mine-conditions"))
|
||||||
try {
|
try {
|
||||||
customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
customMineConditions.add(MMOCore.plugin.loadManager.loadCondition(new MMOLineConfig(key)));
|
||||||
|
@ -17,8 +17,7 @@ import net.Indyuce.mmocore.api.player.PlayerData;
|
|||||||
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
import net.mmogroup.mmolib.api.player.MMOPlayerData;
|
||||||
|
|
||||||
public abstract class PlayerDataManager {
|
public abstract class PlayerDataManager {
|
||||||
// private final Map<UUID, PlayerData> map = new HashMap<>();
|
private DefaultPlayerData defaultData = new DefaultPlayerData();
|
||||||
private DefaultPlayerData defaults = new DefaultPlayerData();
|
|
||||||
|
|
||||||
public PlayerData get(OfflinePlayer player) {
|
public PlayerData get(OfflinePlayer player) {
|
||||||
return get(player.getUniqueId());
|
return get(player.getUniqueId());
|
||||||
@ -39,7 +38,7 @@ public abstract class PlayerDataManager {
|
|||||||
public void setup(Player player) {
|
public void setup(Player player) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* setup playerData based on loadData method to support both MySQL and
|
* Setup playerData based on loadData method to support both MySQL and
|
||||||
* YAML data storage
|
* YAML data storage
|
||||||
*/
|
*/
|
||||||
MMOPlayerData mmoData = MMOPlayerData.get(player);
|
MMOPlayerData mmoData = MMOPlayerData.get(player);
|
||||||
@ -47,39 +46,43 @@ public abstract class PlayerDataManager {
|
|||||||
PlayerData generated = new PlayerData(mmoData);
|
PlayerData generated = new PlayerData(mmoData);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* loads player data and ONLY THEN refresh the player statistics and
|
* Loads player data and ONLY THEN refresh the player statistics and
|
||||||
* calls the load event on the MAIN thread
|
* calls the load event on the MAIN thread
|
||||||
*/
|
*/
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
Bukkit.getScheduler().runTaskAsynchronously(MMOCore.plugin, () -> {
|
||||||
loadData(generated, defaults);
|
loadData(generated);
|
||||||
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(generated)));
|
Bukkit.getScheduler().runTask(MMOCore.plugin, () -> Bukkit.getPluginManager().callEvent(new PlayerDataLoadEvent(generated)));
|
||||||
generated.getStats().updateStats();
|
generated.getStats().updateStats();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DefaultPlayerData getDefaultData() {
|
||||||
|
return defaultData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadDefaultData(ConfigurationSection config) {
|
||||||
|
defaultData = new DefaultPlayerData(config);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isLoaded(UUID uuid) {
|
public boolean isLoaded(UUID uuid) {
|
||||||
return MMOPlayerData.isLoaded(uuid) && MMOPlayerData.get(uuid).getMMOCore() != null;
|
return MMOPlayerData.isLoaded(uuid) && MMOPlayerData.get(uuid).getMMOCore() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection<PlayerData> getLoaded() {
|
public Collection<PlayerData> getLoaded() {
|
||||||
return MMOPlayerData.getLoaded().stream().filter(data -> data.getMMOCore() != null).map(data -> data.getMMOCore()).collect(Collectors.toSet());
|
return MMOPlayerData.getLoaded().stream().filter(data -> data.getMMOCore() != null).map(data -> data.getMMOCore())
|
||||||
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void loadData(PlayerData data, DefaultPlayerData defaults);
|
public abstract void loadData(PlayerData data);
|
||||||
|
|
||||||
public abstract void saveData(PlayerData data);
|
public abstract void saveData(PlayerData data);
|
||||||
|
|
||||||
public abstract void remove(PlayerData data);
|
public abstract void remove(PlayerData data);
|
||||||
|
|
||||||
public void setDefaults(ConfigurationSection config) {
|
|
||||||
defaults = new DefaultPlayerData(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class DefaultPlayerData {
|
public class DefaultPlayerData {
|
||||||
private final int level, classPoints, skillPoints,
|
private final int level, classPoints, skillPoints, attributePoints, attrReallocPoints;
|
||||||
attributePoints, attrReallocPoints;
|
|
||||||
|
|
||||||
public DefaultPlayerData(ConfigurationSection config) {
|
public DefaultPlayerData(ConfigurationSection config) {
|
||||||
level = config.getInt("level", 1);
|
level = config.getInt("level", 1);
|
||||||
@ -96,5 +99,25 @@ public abstract class PlayerDataManager {
|
|||||||
attributePoints = 0;
|
attributePoints = 0;
|
||||||
attrReallocPoints = 0;
|
attrReallocPoints = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSkillPoints() {
|
||||||
|
return skillPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getClassPoints() {
|
||||||
|
return classPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttributeReallocationPoints() {
|
||||||
|
return attrReallocPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAttributePoints() {
|
||||||
|
return attributePoints;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,17 +33,16 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadData(PlayerData data, DefaultPlayerData defaults) {
|
public void loadData(PlayerData data) {
|
||||||
ResultSet result = provider
|
ResultSet result = provider.getResult("SELECT * FROM mmocore_playerdata WHERE uuid = '" + data.getUniqueId() + "';");
|
||||||
.getResult("SELECT * FROM mmocore_playerdata WHERE uuid = '" + data.getUniqueId() + "';");
|
|
||||||
|
|
||||||
// player data not initialized yet
|
// player data not initialized yet
|
||||||
if (result.size() < 1) {
|
if (result.size() < 1) {
|
||||||
data.setLevel(defaults.getLevel());
|
data.setLevel(getDefaultData().getLevel());
|
||||||
data.setClassPoints(defaults.getClassPoints());
|
data.setClassPoints(getDefaultData().getClassPoints());
|
||||||
data.setSkillPoints(defaults.getSkillPoints());
|
data.setSkillPoints(getDefaultData().getSkillPoints());
|
||||||
data.setAttributePoints(defaults.getAttributePoints());
|
data.setAttributePoints(getDefaultData().getAttributePoints());
|
||||||
data.setAttributeReallocationPoints(defaults.getAttrReallocPoints());
|
data.setAttributeReallocationPoints(getDefaultData().getAttributeReallocationPoints());
|
||||||
data.setExperience(0);
|
data.setExperience(0);
|
||||||
data.setMana(data.getStats().getStat(StatType.MAX_MANA));
|
data.setMana(data.getStats().getStat(StatType.MAX_MANA));
|
||||||
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
||||||
@ -67,8 +66,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
data.setStamina(data.getStats().getStat(StatType.MAX_STAMINA));
|
||||||
data.setStellium(data.getStats().getStat(StatType.MAX_STELLIUM));
|
data.setStellium(data.getStats().getStat(StatType.MAX_STELLIUM));
|
||||||
if (!isEmpty(row.getString("guild")))
|
if (!isEmpty(row.getString("guild")))
|
||||||
data.setGuild(MMOCore.plugin.dataProvider.getGuildManager().stillInGuild(data.getUniqueId(),
|
data.setGuild(MMOCore.plugin.dataProvider.getGuildManager().stillInGuild(data.getUniqueId(), row.getString("guild")));
|
||||||
row.getString("guild")));
|
|
||||||
if (!isEmpty(row.getString("attributes")))
|
if (!isEmpty(row.getString("attributes")))
|
||||||
data.getAttributes().load(row.getString("attributes"));
|
data.getAttributes().load(row.getString("attributes"));
|
||||||
if (!isEmpty(row.getString("professions")))
|
if (!isEmpty(row.getString("professions")))
|
||||||
@ -97,16 +95,14 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
Validate.notNull(profess, "Could not find class '" + entry.getKey() + "'");
|
Validate.notNull(profess, "Could not find class '" + entry.getKey() + "'");
|
||||||
data.applyClassInfo(profess, new SavedClassInformation(entry.getValue().getAsJsonObject()));
|
data.applyClassInfo(profess, new SavedClassInformation(entry.getValue().getAsJsonObject()));
|
||||||
} catch (IllegalArgumentException exception) {
|
} catch (IllegalArgumentException exception) {
|
||||||
MMOCore.log(Level.WARNING,
|
MMOCore.log(Level.WARNING, "Could not load class info '" + entry.getKey() + "': " + exception.getMessage());
|
||||||
"Could not load class info '" + entry.getKey() + "': " + exception.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEmpty(String s) {
|
private boolean isEmpty(String s) {
|
||||||
return s.equalsIgnoreCase("null") || s.equalsIgnoreCase("{}") || s.equalsIgnoreCase("[]")
|
return s.equalsIgnoreCase("null") || s.equalsIgnoreCase("{}") || s.equalsIgnoreCase("[]") || s.equalsIgnoreCase("");
|
||||||
|| s.equalsIgnoreCase("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,10 +120,8 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
|||||||
sql.updateData("guild", data.hasGuild() ? data.getGuild().getId() : null);
|
sql.updateData("guild", data.hasGuild() ? data.getGuild().getId() : null);
|
||||||
|
|
||||||
sql.updateJSONArray("waypoints", data.getWaypoints());
|
sql.updateJSONArray("waypoints", data.getWaypoints());
|
||||||
sql.updateJSONArray("friends",
|
sql.updateJSONArray("friends", data.getFriends().stream().map(uuid -> uuid.toString()).collect(Collectors.toList()));
|
||||||
data.getFriends().stream().map(uuid -> uuid.toString()).collect(Collectors.toList()));
|
sql.updateJSONArray("bound_skills", data.getBoundSkills().stream().map(skill -> skill.getSkill().getId()).collect(Collectors.toList()));
|
||||||
sql.updateJSONArray("bound_skills",
|
|
||||||
data.getBoundSkills().stream().map(skill -> skill.getSkill().getId()).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
sql.updateJSONObject("skills", data.mapSkillLevels().entrySet());
|
sql.updateJSONObject("skills", data.mapSkillLevels().entrySet());
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ import net.Indyuce.mmocore.manager.data.PlayerDataManager;
|
|||||||
public class YAMLPlayerDataManager extends PlayerDataManager {
|
public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadData(PlayerData data, DefaultPlayerData defaults) {
|
public void loadData(PlayerData data) {
|
||||||
FileConfiguration config = new ConfigFile(data.getPlayer()).getConfig();
|
FileConfiguration config = new ConfigFile(data.getPlayer()).getConfig();
|
||||||
|
|
||||||
data.setClassPoints(config.getInt("class-points", defaults.getClassPoints()));
|
data.setClassPoints(config.getInt("class-points", getDefaultData().getClassPoints()));
|
||||||
data.setSkillPoints(config.getInt("skill-points", defaults.getSkillPoints()));
|
data.setSkillPoints(config.getInt("skill-points", getDefaultData().getSkillPoints()));
|
||||||
data.setAttributePoints(config.getInt("attribute-points", defaults.getAttributePoints()));
|
data.setAttributePoints(config.getInt("attribute-points", getDefaultData().getAttributePoints()));
|
||||||
data.setAttributeReallocationPoints(config.getInt("attribute-realloc-points", defaults.getAttrReallocPoints()));
|
data.setAttributeReallocationPoints(config.getInt("attribute-realloc-points", getDefaultData().getAttributeReallocationPoints()));
|
||||||
data.setLevel(config.getInt("level", defaults.getLevel()));
|
data.setLevel(config.getInt("level", getDefaultData().getLevel()));
|
||||||
data.setExperience(config.getInt("experience"));
|
data.setExperience(config.getInt("experience"));
|
||||||
if (config.contains("class"))
|
if (config.contains("class"))
|
||||||
data.setClass(MMOCore.plugin.classManager.get(config.getString("class")));
|
data.setClass(MMOCore.plugin.classManager.get(config.getString("class")));
|
||||||
|
Loading…
Reference in New Issue
Block a user