mirror of
https://github.com/WiIIiam278/HuskSync.git
synced 2025-12-26 10:09:10 +00:00
Added Synchronisation options
This commit is contained in:
@@ -2,6 +2,7 @@ package me.william278.crossserversync.bukkit;
|
||||
|
||||
import me.william278.crossserversync.CrossServerSyncBukkit;
|
||||
import me.william278.crossserversync.PlayerData;
|
||||
import me.william278.crossserversync.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
@@ -21,18 +22,29 @@ public class PlayerSetter {
|
||||
*/
|
||||
public static void setPlayerFrom(Player player, PlayerData data) {
|
||||
try {
|
||||
setPlayerInventory(player, DataSerializer.itemStackArrayFromBase64(data.getSerializedInventory()));
|
||||
setPlayerEnderChest(player, DataSerializer.itemStackArrayFromBase64(data.getSerializedEnderChest()));
|
||||
player.setHealth(data.getHealth());
|
||||
player.setMaxHealth(data.getMaxHealth());
|
||||
player.setFoodLevel(data.getHunger());
|
||||
player.setSaturation(data.getSaturation());
|
||||
player.setExhaustion(data.getSaturationExhaustion());
|
||||
player.getInventory().setHeldItemSlot(data.getSelectedSlot());
|
||||
player.setTotalExperience(data.getExperience());
|
||||
|
||||
//todo potion effects not working
|
||||
setPlayerPotionEffects(player, DataSerializer.potionEffectArrayFromBase64(data.getSerializedEffectData()));
|
||||
if (Settings.syncInventories) {
|
||||
setPlayerInventory(player, DataSerializer.itemStackArrayFromBase64(data.getSerializedInventory()));
|
||||
player.getInventory().setHeldItemSlot(data.getSelectedSlot());
|
||||
}
|
||||
if (Settings.syncEnderChests) {
|
||||
setPlayerEnderChest(player, DataSerializer.itemStackArrayFromBase64(data.getSerializedEnderChest()));
|
||||
}
|
||||
if (Settings.syncHealth) {
|
||||
player.setHealth(data.getHealth());
|
||||
player.setMaxHealth(data.getMaxHealth());
|
||||
}
|
||||
if (Settings.syncHunger) {
|
||||
player.setFoodLevel(data.getHunger());
|
||||
player.setSaturation(data.getSaturation());
|
||||
player.setExhaustion(data.getSaturationExhaustion());
|
||||
}
|
||||
if (Settings.syncExperience) {
|
||||
player.setTotalExperience(data.getExperience());
|
||||
}
|
||||
if (Settings.syncPotionEffects) {
|
||||
// todo not working ?
|
||||
setPlayerPotionEffects(player, DataSerializer.potionEffectArrayFromBase64(data.getSerializedEffectData()));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to deserialize PlayerData", e);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,13 @@ public class ConfigLoader {
|
||||
Settings.redisHost = config.getString("redis_settings.host", "localhost");
|
||||
Settings.redisPort = config.getInt("redis_settings.port", 6379);
|
||||
Settings.redisPassword = config.getString("redis_settings.password", "");
|
||||
|
||||
Settings.syncInventories = config.getBoolean("synchronisation_settings.inventories", true);
|
||||
Settings.syncEnderChests = config.getBoolean("synchronisation_settings.ender_chests", true);
|
||||
Settings.syncHealth = config.getBoolean("synchronisation_settings.health", true);
|
||||
Settings.syncHunger = config.getBoolean("synchronisation_settings.hunger", true);
|
||||
Settings.syncExperience = config.getBoolean("synchronisation_settings.experience", true);
|
||||
Settings.syncPotionEffects = config.getBoolean("synchronisation_settings.potion_effects", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user