63 lines
1.5 KiB
Java
63 lines
1.5 KiB
Java
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<String> rewardList;
|
|
|
|
private List<String> 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<String> 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);
|
|
}
|
|
}
|
|
}
|
|
}
|