Search in sources :

Example 6 with PlayerDataManager

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

the class InventoryManager method storeInventory.

public void storeInventory(Player player) {
    Validate.notNull(player, "player must not be null!");
    if (player.hasMetadata("NPC")) {
        throw new IllegalArgumentException("player must not be an NPC!");
    }
    PlayerInventory playerInventory = player.getInventory();
    StoredInventory storedInventory = StoredInventory.createFrom(playerInventory);
    UUID playerId = player.getUniqueId();
    this.storedInventoryMap.put(playerId, storedInventory);
    PlayerDataManager playerDataManager = getPlayerDataManager();
    YamlConfiguration configuration = playerDataManager.get(player);
    ConfigurationSection section = configuration.createSection("citizens-compatibility.stored-inventory");
    CitizensExpansion expansion = getExpansion();
    storedInventory.save(expansion, section);
    playerDataManager.save(player);
}
Also used : StoredInventory(combatlogx.expansion.compatibility.citizens.object.StoredInventory) PlayerInventory(org.bukkit.inventory.PlayerInventory) 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)

Example 7 with PlayerDataManager

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

the class ActionBarUpdater method isDisabled.

private boolean isDisabled(Player player) {
    if (isGlobalEnabled()) {
        PlayerDataManager playerDataManager = getPlayerDataManager();
        YamlConfiguration playerData = playerDataManager.get(player);
        return !playerData.getBoolean("actionbar", true);
    }
    return true;
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 8 with PlayerDataManager

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

the class CommandCombatLogXToggle method toggleValue.

private void toggleValue(Player player, String value) {
    ICombatLogX plugin = getCombatLogX();
    PlayerDataManager playerDataManager = plugin.getPlayerDataManager();
    LanguageManager languageManager = getLanguageManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    boolean currentValue = playerData.getBoolean(value, true);
    playerData.set(value, !currentValue);
    playerDataManager.save(player);
    boolean status = playerData.getBoolean(value, true);
    String statusPath = ("placeholder.toggle." + (status ? "enabled" : "disabled"));
    String statusString = languageManager.getMessage(player, statusPath, null, true);
    Replacer replacer = message -> message.replace("{status}", statusString);
    String messagePath = ("command.combatlogx.toggle-" + value);
    sendMessageWithPrefix(player, messagePath, replacer, true);
}
Also used : Arrays(java.util.Arrays) List(java.util.List) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager) Replacer(com.github.sirblobman.api.language.Replacer) Locale(java.util.Locale) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) LanguageManager(com.github.sirblobman.api.language.LanguageManager) CombatLogPlayerCommand(com.github.sirblobman.combatlogx.api.command.CombatLogPlayerCommand) Player(org.bukkit.entity.Player) Collections(java.util.Collections) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) LanguageManager(com.github.sirblobman.api.language.LanguageManager) ICombatLogX(com.github.sirblobman.combatlogx.api.ICombatLogX) Replacer(com.github.sirblobman.api.language.Replacer) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager)

Example 9 with PlayerDataManager

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

the class ListenerDeath method onJoin.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onJoin(PlayerJoinEvent e) {
    ConfigurationManager configurationManager = getPluginConfigurationManager();
    YamlConfiguration configuration = configurationManager.get("punish.yml");
    String killTime = configuration.getString("kill-time");
    if (killTime == null || !killTime.equalsIgnoreCase("join")) {
        return;
    }
    Player player = e.getPlayer();
    PlayerDataManager playerDataManager = getPlayerDataManager();
    YamlConfiguration playerData = playerDataManager.get(player);
    if (!playerData.getBoolean("kill-on-join", false)) {
        return;
    }
    playerData.set("kill-on-join", false);
    playerDataManager.save(player);
    add(player);
    player.setHealth(0.0D);
}
Also used : Player(org.bukkit.entity.Player) YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) ConfigurationManager(com.github.sirblobman.api.configuration.ConfigurationManager) PlayerDataManager(com.github.sirblobman.api.configuration.PlayerDataManager) EventHandler(org.bukkit.event.EventHandler)

Example 10 with PlayerDataManager

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

the class CustomScoreboardManager method isDisabled.

private boolean isDisabled(Player player) {
    if (isGlobalEnabled()) {
        PlayerDataManager playerDataManager = getPlayerDataManager();
        YamlConfiguration configuration = playerDataManager.get(player);
        return !configuration.getBoolean("scoreboard", true);
    }
    return true;
}
Also used : YamlConfiguration(org.bukkit.configuration.file.YamlConfiguration) 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