package com.yaohun.levelreward.data; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import java.util.List; public class RewardData { private String rewardKey; private int slot; private String base64; private int needLevel; private List rewardList; private List commandList; public RewardData(String rewardKey, ConfigurationSection section){ this.rewardKey = rewardKey; this.slot = section.getInt(rewardKey+".slot"); this.needLevel = section.getInt(rewardKey+".level"); this.base64 = section.getString(rewardKey+".base64","default"); this.rewardList = section.getStringList(rewardKey+".reward"); this.commandList = section.getStringList(rewardKey+".commands"); } public String getRewardKey() { return rewardKey; } public int getSlot() { return slot; } public String getBase64() { return base64; } public List getRewardList() { return rewardList; } public int getNeedLevel() { return needLevel; } public void carryOutCommands(Player player){ String playerName = player.getName(); for(String command : commandList) { if (command.contains("msg:")) { player.sendMessage(command.replace("msg:", "")); } else { command = command.replace("%p%", playerName); player.performCommand(command); } } } }