Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.5 kB
2
Indexable
Never
@Override
    public void setRealmRewards(Reward[] rewards) //Reads rewards from config file
    {
        Reward[] temp= new Reward[rewards.length];
        String path;
        RealmColor realmColor=getRealmColor();
        switch(realmColor)
        {
            case RED:path="src\\main\\resources\\config\\EmberfallDominionRewards.properties";break;
            case GREEN:path="src\\main\\resources\\config\\TerrasHeartlandRewards.properties";break;
            case BLUE:path="src\\main\\resources\\config\\TideAbyssRewards.properties";break;
            case MAGENTA:path="src\\main\\resources\\config\\MysticalSkyRewards.properties";break;
            default:path="src\\main\\resources\\config\\RadiantSvannaRewards.properties";break;
        }

        String[] string=new String[rewards.length];
        int s=0;
        try{
            BufferedReader reader = new BufferedReader(new FileReader(path));
            String line;
            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