Get Integer list from one file

239 views Asked by At

This script checks skills from the config file and allows using only them (in order stop hacking).

Here is the process of how to work my script works:

#1 There is special .ini configuration file with this skill list:

CommunityAvailableBuffs = 11517,11522;

#2 File config.java gets a list from the config file and convert to the integer:

public static List<Integer> COMMUNITY_AVAILABLE_BUFFS;

final String[] allowedBuffs = 
CommunityBoard.getString("CommunityAvailableBuffs", "").split(",");
COMMUNITY_AVAILABLE_BUFFS = new ArrayList<>(allowedBuffs.length);
    for (String s : allowedBuffs)
    {
        COMMUNITY_AVAILABLE_BUFFS.add(Integer.parseInt(s));
    }

#3 File HomeBoard.java get this list from config.java file and check skills from this list.

if (!Config.COMMUNITY_AVAILABLE_BUFFS.contains(skill.getId()))
{
    continue;
}

My question is how to paste skill list directly in HomeBoard.java file without using config and config.java files, I tried to use something like this:

List<Integer> allallowedBuffs = "11517,11522";
final String[] allowedBuffs = CommunityBoard.getString(allallowedBuffs, "").split(",");
allallowedBuffs = new ArrayList<>(allowedBuffs.length);
for (String s : allowedBuffs)
{
    allallowedBuffs.add(Integer.parseInt(s));
}

if (!allowedBuffsend.contains(skill.getId()))
{
    continue;
}

But unfortunately, it doesn't work.

2

There are 2 answers

1
emptak On

If i understand your question correctly you can simply use following line to fill allallowedBuffs with some hardcoded data.

List<Integer> allallowedBuffs = Arrays.asList(11517,11522);
0
Maistrenko Vitalii On

Try this, if it is Java8

List<Integer> allallowedBuffs = List.of(11517, 11522);