Search in sources :

Example 16 with PlayerDataManager

use of com.github.sirblobman.api.configuration.PlayerDataManager in project CombatLogX by SirBlobman.

the class ProtectionManager method isProtected.

public boolean isProtected(Player player) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        return false;
    }
    ICombatLogX plugin = this.expansion.getPlugin();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    if (!configuration.getBoolean("newbie-helper.protected")) {
        return false;
    }
    long expireTime = configuration.getLong("newbie-helper.protection-expire-time", 0L);
    long systemTime = System.currentTimeMillis();
    if (systemTime < expireTime) {
        return true;
    }
    setProtected(player, false);
    LanguageManager languageManager = this.expansion.getPlugin().getLanguageManager();
    languageManager.sendMessage(player, "expansion.newbie-helper.protection-disabled.expired", null, true);
    return false;
}
Also used : LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 17 with PlayerDataManager

use of com.github.sirblobman.api.configuration.PlayerDataManager in project CombatLogX by SirBlobman.

the class CombatNpcManager method saveData.

public void saveData(OfflinePlayer player) {
    ICombatLogX plugin = getCombatLogX();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    playerDataManager.save(player);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 18 with PlayerDataManager

use of com.github.sirblobman.api.configuration.PlayerDataManager in project CombatLogX by SirBlobman.

the class InventoryManager method getStoredInventory.

@Nullable
public StoredInventory getStoredInventory(OfflinePlayer player) {
    Validate.notNull(player, "player must not be null!");
    UUID playerId = player.getUniqueId();
    if (this.storedInventoryMap.containsKey(playerId)) {
        return this.storedInventoryMap.get(playerId);
    }
    PlayerDataManager playerDataManager = getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    String storagePath = ("citizens-compatibility.stored-inventory");
    ConfigurationSection section = configuration.getConfigurationSection(storagePath);
    if (section == null) {
        return null;
    }
    CitizensExpansion expansion = getExpansion();
    return StoredInventory.createFrom(expansion, section);
}
Also used : UUID(java.util.UUID) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) CitizensExpansion(combatlogx.expansion.compatibility.citizens.CitizensExpansion) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with PlayerDataManager

use of com.github.sirblobman.api.configuration.PlayerDataManager in project CombatLogX by SirBlobman.

the class InventoryManager method removeStoredInventory.

public void removeStoredInventory(OfflinePlayer player) {
    Validate.notNull(player, "player must not be null!");
    UUID playerId = player.getUniqueId();
    this.storedInventoryMap.remove(playerId);
    PlayerDataManager playerDataManager = getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    String storagePath = ("citizens-compatibility.stored-inventory");
    configuration.set(storagePath, null);
    playerDataManager.save(player);
}
Also used : UUID(java.util.UUID) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 20 with PlayerDataManager

use of com.github.sirblobman.api.configuration.PlayerDataManager in project CombatLogX by SirBlobman.

the class CombatNpcManager method getData.

public YamlConfiguration getData(OfflinePlayer player) {
    ICombatLogX plugin = getCombatLogX();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    return playerDataManager.get(player);
}
Also used : ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Aggregations

PlayerDataManager (com.github.sirblobman.api.configuration.PlayerDataManager)20 YamlConfiguration (org.bukkit.configuration.file.YamlConfiguration)17 ICombatLogX (com.github.sirblobman.combatlogx.api.ICombatLogX)8 ConfigurationManager (com.github.sirblobman.api.configuration.ConfigurationManager)6 UUID (java.util.UUID)5 Player (org.bukkit.entity.Player)4 EventHandler (org.bukkit.event.EventHandler)3 LanguageManager (com.github.sirblobman.api.language.LanguageManager)2 Replacer (com.github.sirblobman.api.language.Replacer)2 CitizensExpansion (combatlogx.expansion.compatibility.citizens.CitizensExpansion)2 Collections (java.util.Collections)2 List (java.util.List)2 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)2 LivingEntity (org.bukkit.entity.LivingEntity)2 WorldXYZ (com.github.sirblobman.api.object.WorldXYZ)1 CombatLogPlayerCommand (com.github.sirblobman.combatlogx.api.command.CombatLogPlayerCommand)1 PlayerPunishEvent (com.github.sirblobman.combatlogx.api.event.PlayerPunishEvent)1 PlayerUntagEvent (com.github.sirblobman.combatlogx.api.event.PlayerUntagEvent)1 Expansion (com.github.sirblobman.combatlogx.api.expansion.Expansion)1 ExpansionListener (com.github.sirblobman.combatlogx.api.expansion.ExpansionListener)1