Search in sources :

Example 1 with Challenge

use of pixelssky.objects.Challenge in project PixelsSkyblock by dudullle.

the class IsCommand method onCommand.

@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2, String[] arg3) {
    // Sous commandes : go, h, home, spawn, l, level, lvl, sethome, top, rank, reset
    try {
        Player pl = (Player) arg0;
        SPlayer p = PlayersManager.getSPlayer(pl);
        if (arg3.length == 0) {
            if (p.getIsland() == null) {
                // ouvrir pour cr�er �le
                pl.openInventory(Inventories.getCreateIslandMenu(p));
                pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_XYLOPHONE, 100, 1000);
            } else {
                // Ouvrir inventaire de base
                pl.openInventory(Inventories.getIslandMenu(p));
                pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_GUITAR, 100, 100);
            }
        } else if (arg3[0].equals("create")) {
            if (p.getIsland() != null) {
                pl.openInventory(Inventories.getConfirmCreateIsland());
                pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_XYLOPHONE, 100, 1000);
            } else {
                pl.openInventory(Inventories.getCreateIslandMenu(p));
                pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_XYLOPHONE, 100, 1000);
            }
        } else if (arg3[0].equals("h")) {
            pl.sendTitle("�aBienvenue sur votre �le :)", "�cNe tombez pas !", 10, 20, 10);
            pl.teleport(p.getIsland().getSpawn());
        } else if (arg3[0].equals("sethome")) {
            pl.sendTitle("�aMise � jour effectu�e :)", "�cVotre home a chang� !", 10, 20, 10);
            p.getIsland().setHome(pl.getLocation());
        } else if (arg3[0].equals("top")) {
            pl.sendMessage("Is top : ");
            for (String i : Classement.getTop()) {
                pl.sendMessage("ISLAND : " + i);
            }
        } else if (arg3[0].equals("level")) {
            p.getIsland().calculateLevel(pl);
        } else if (arg3[0].equals("invite")) {
            pl.openInventory(Inventories.getPlayersInventory_invite(p));
        } else if (arg3[0].equals("accept")) {
            pl.sendTitle("�aVous venez d'accepter l'invation :p", "�cC'est parti!!!", 10, 20, 10);
            p.setIsland(IslandsManager.getIsland(p.getLastIsInvite()));
            p.getIsland().getMembers().add(p.getID());
            pl.teleport(p.getIsland().getSpawn());
            pl.playSound(pl.getLocation(), Sound.ENTITY_ENDERMEN_TELEPORT, 100, 100);
        } else if (arg3[0].equals("try")) {
            Challenge c = ChallengesManager.challenges.get(0).getSubChallenges().get(0);
            c.complete(pl, p.getIsland());
        }
    } catch (Exception ex) {
        System.out.println(ex.toString());
    }
    return true;
}
Also used : Player(org.bukkit.entity.Player) SPlayer(pixelssky.objects.SPlayer) SPlayer(pixelssky.objects.SPlayer) Challenge(pixelssky.objects.Challenge)

Example 2 with Challenge

use of pixelssky.objects.Challenge in project PixelsSkyblock by dudullle.

the class ChallengesManager method init_subChallenges.

public static void init_subChallenges() {
    for (Challenge categ : challenges) {
        File folder = new File("plugins/PixelsSky/Challenges/" + categ.getName());
        for (File f : folder.listFiles()) {
            if (!f.isDirectory()) {
                ArrayList<String> lines = FileManager.ReadAllText(f.getAbsolutePath());
                ArrayList<Objective> obj = new ArrayList<Objective>();
                ArrayList<Reward> rewards = new ArrayList<Reward>();
                String c_name = null;
                int type = -1;
                boolean can_redo = false;
                Material m = null;
                int subid = 0;
                boolean isUnlocked = false;
                for (String l : lines) {
                    if (l.split("=")[0].equals("name")) {
                        c_name = l.split("=")[1];
                    } else if (l.split("=")[0].equals("unlocked_by_default")) {
                        isUnlocked = Boolean.parseBoolean(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("type")) {
                        type = Integer.parseInt(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("material")) {
                        m = Material.getMaterial(Integer.parseInt(l.split("=")[1]));
                    } else if (l.split("=")[0].equals("subid")) {
                        subid = Integer.parseInt(l.split("=")[1]);
                    } else if (l.split("=")[0].equals("can_redo")) {
                        can_redo = Boolean.parseBoolean((l.split("=")[1]));
                    } else if (l.split("=")[0].equals("objective")) {
                        String[] s = l.split("=")[1].split(",");
                        if (s[0].equals("inventory")) {
                            obj.add(new InventoryObjective(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), s[4].equals("take")));
                        } else if (s[0].equals("onisland")) {
                            if (s[1].equals("block")) {
                                obj.add(new OnislandObjective(s[1].equals("entity"), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[4])));
                            } else {
                                obj.add(new OnislandObjective(s[1].equals("entity"), s[2], Integer.parseInt(s[3]), Integer.parseInt(s[4])));
                            }
                        } else if (s[0].equals("stats")) {
                            obj.add(new StatsObjective(s[1], s[2], s[3]));
                        }
                    } else if (l.split("=")[0].equals("reward")) {
                        String[] s = l.split("=")[1].split(",");
                        if (s[0].equals("give")) {
                            if (s[4].split(":").length > 1) {
                                TreeMap<String, Integer> e = new TreeMap<String, Integer>();
                                for (String ench : s[4].split(":")[1].split(";")) {
                                    e.put(ench.split("/")[0], Integer.parseInt(ench.split("/")[1]));
                                }
                                rewards.add(new GiveReward(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), e));
                            } else {
                                rewards.add(new GiveReward(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3])));
                            }
                        } else if (s[0].equals("command")) {
                            rewards.add(new CommandReward(s[1], s[2]));
                        } else if (s[0].equals("stats")) {
                            rewards.add(new StatsReward(s[1], s[2], s[3]));
                        }
                    }
                }
                categ.getSubChallenges().add(new Challenge(type, c_name, obj, rewards, can_redo, m, subid, isUnlocked));
            }
        }
    }
}
Also used : StatsObjective(pixelssky.objects.objectives.StatsObjective) GiveReward(pixelssky.rewards.GiveReward) ArrayList(java.util.ArrayList) OnislandObjective(pixelssky.objects.objectives.OnislandObjective) Material(org.bukkit.Material) StatsReward(pixelssky.rewards.StatsReward) TreeMap(java.util.TreeMap) Challenge(pixelssky.objects.Challenge) InventoryObjective(pixelssky.objects.objectives.InventoryObjective) Objective(pixelssky.objects.objectives.Objective) OnislandObjective(pixelssky.objects.objectives.OnislandObjective) InventoryObjective(pixelssky.objects.objectives.InventoryObjective) StatsObjective(pixelssky.objects.objectives.StatsObjective) CommandReward(pixelssky.rewards.CommandReward) CommandReward(pixelssky.rewards.CommandReward) StatsReward(pixelssky.rewards.StatsReward) GiveReward(pixelssky.rewards.GiveReward) Reward(pixelssky.rewards.Reward) File(java.io.File)

Example 3 with Challenge

use of pixelssky.objects.Challenge in project PixelsSkyblock by dudullle.

the class ChallengesManager method init.

public static void init() {
    File folder = new File("plugins/PixelsSky/Challenges");
    for (File f : folder.listFiles()) {
        if (!f.isDirectory()) {
            // Lire le fichier : NOTE -> A la racine : que des cat�gories
            ArrayList<String> lines = FileManager.ReadAllText(f.getAbsolutePath());
            String c_name = null;
            int type = -1;
            boolean isUnlocked = false;
            for (String l : lines) {
                if (l.split("=")[0].equals("name")) {
                    c_name = l.split("=")[1];
                } else if (l.split("=")[0].equals("type")) {
                    type = Integer.parseInt(l.split("=")[1]);
                } else if (l.split("=")[0].equals("unlocked_by_default")) {
                    isUnlocked = Boolean.parseBoolean(l.split("=")[1]);
                }
            }
            challenges.add(new Challenge(type, c_name, isUnlocked));
        }
    }
    init_subChallenges();
}
Also used : File(java.io.File) Challenge(pixelssky.objects.Challenge)

Aggregations

Challenge (pixelssky.objects.Challenge)3 File (java.io.File)2 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 Material (org.bukkit.Material)1 Player (org.bukkit.entity.Player)1 SPlayer (pixelssky.objects.SPlayer)1 InventoryObjective (pixelssky.objects.objectives.InventoryObjective)1 Objective (pixelssky.objects.objectives.Objective)1 OnislandObjective (pixelssky.objects.objectives.OnislandObjective)1 StatsObjective (pixelssky.objects.objectives.StatsObjective)1 CommandReward (pixelssky.rewards.CommandReward)1 GiveReward (pixelssky.rewards.GiveReward)1 Reward (pixelssky.rewards.Reward)1 StatsReward (pixelssky.rewards.StatsReward)1