Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.0 kB
4
Indexable
Never
@Override
    public void setRealmRewards(Reward[] rewards) //Reads rewards from config file
    {
        Reward[] temp= new Reward[rewards.length];
        String path = "src\\main\\resources\\config\\RadiantSvannaRewards.properties";
        String[] string=new String[rewards.length];
        int s=0;
        try (BufferedReader reader = new BufferedReader(new FileReader(path))){
            String line;
            line=reader.readLine();
            while (((line=reader.readLine())) != null) {
                String[] splitter = line.split("=");
                string[s++]=splitter[1].trim();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        for(int i=0;i<string.length;i++)
        {
            String value=string[i];
            switch (value) {
                case "RedBonus":
                    temp[i]=new Bonus(RealmColor.RED);rewards[i]=temp[i];break;
                case "GreenBonus":
                    temp[i]=new Bonus(RealmColor.GREEN);rewards[i]=temp[i];break;
                case "BlueBonus":
                    temp[i]=new Bonus(RealmColor.BLUE);rewards[i]=temp[i];break;
                case "MagentaBonus":
                    temp[i]=new Bonus(RealmColor.MAGENTA);rewards[i]=temp[i];break;
                case "YellowBonus":
                    temp[i]=new Bonus(RealmColor.YELLOW);rewards[i]=temp[i];break;
                case "ArcaneBoost":
                    temp[i]=new ArcaneBoost();rewards[i]=temp[i];break;
                case "EssenceBonus":
                    temp[i]=new EssenceBonus();rewards[i]=temp[i];break;
                case "ElementalCrest":
                    temp[i]=new ElementalCrest();rewards[i]=temp[i];break;
                case "TimeWarp":
                    temp[i]=new TimeWarp();rewards[i]=temp[i];break;
                default:
                    temp[i]=null;rewards[i]=temp[i];break;
            }
            
        }
    }
Leave a Comment