Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class achievementsUtils {
- private Player user;
- public achievementsUtils(Player p){
- user = p;
- }
- public void unlock(String shortName){
- if (check(shortName) == false){
- return;
- }
- if (custom().contains("achievements." + user.getName() + "." + shortName)){
- return;
- }
- credits credits = new credits();
- achievements achievements = Main.getInstance().achStore.get(shortName);
- if (achievements == null){
- return;
- }
- user.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "+-------------------------------------------+");
- user.sendMessage(ChatColor.WHITE + "");
- user.sendMessage(ChatColor.AQUA + "Unlocked Achievement: " + achievements.name);
- user.sendMessage(ChatColor.GRAY + "" + ChatColor.ITALIC + achievements.description);
- user.sendMessage(ChatColor.WHITE + "");
- user.sendMessage(ChatColor.GREEN + "+" + achievements.credits + " credits");
- user.sendMessage(ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "+-------------------------------------------+");
- credits.setCoins(user,achievements.credits);
- File f = new File("plugins/HpWave2", "achievements.yml");
- FileConfiguration c = YamlConfiguration.loadConfiguration(f);
- c.set("achievements." + user.getName() + "." + achievements.shortName, true);
- try {
- c.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public boolean check(String shortName){
- if (Main.getInstance().achStore.containsKey(shortName)){
- return true;
- }else{
- return false;
- }
- }
- public double percent() {
- float unlocked = 0.0F;
- if (custom().contains("achievements." + user.getName())) {
- for (String ach : custom().getConfigurationSection("achievements." + user.getName()).getKeys(false)) {
- unlocked += 1.0F;
- }
- double num = unlocked / Main.getInstance().achStore.size();
- num *= 100.0D;
- return Math.round(num);
- }
- return 0.0D;
- }
- public void menu(){
- int count = 0;
- Inventory menu = Bukkit.createInventory(null, 36, "§7Achievements");
- for (String key : Main.getInstance().achStore.keySet()) {
- if (check(key) == false){
- user.sendMessage("nope");
- return;
- }
- achievements achievement = Main.getInstance().achStore.get(key);
- ItemStack is;
- if (custom().contains("achievements." + user.getName() + "." + achievement.shortName)){
- is = new ItemStack(Material.LIME_DYE);
- ItemMeta im = is.getItemMeta();
- im.setDisplayName(ChatColor.GREEN + "✓ " + achievement.name);
- ArrayList<String> lore = new ArrayList<String>();
- lore.add("§7" + achievement.description);
- im.setLore(lore);
- is.setItemMeta(im);
- menu.setItem(count,is);
- count++;
- }else{
- is = new ItemStack(Material.GRAY_DYE);
- ItemMeta im = is.getItemMeta();
- im.setDisplayName(ChatColor.RED + "✖ ????");
- ArrayList<String> lore = new ArrayList<String>();
- lore.add("§7????");
- im.setLore(lore);
- is.setItemMeta(im);
- menu.setItem(count,is);
- count++;
- }
- }
- user.openInventory(menu);
- }
- public FileConfiguration custom(){
- File f = new File("plugins/HpWave2", "achievements.yml");
- FileConfiguration c = YamlConfiguration.loadConfiguration(f);
- return c;
- }
- }
- ============
- ============
- public class achievements {
- String shortName;
- String name;
- String description;
- Integer credits;
- public achievements(String shortName, String name, String description, Integer Credits){
- this.shortName = shortName;
- this.name = name;
- this.description = description;
- this.credits = Credits;
- }
- public void store(){
- Main.getInstance().achStore.put(this.shortName,this);
- }
- }
- ============
- ============
- public class saving {
- public saving(){}
- public void load(){
- new achievements("welcome","Joining McAmusement", "Enter the gates of McAmusement",50).store();
- new achievements("disneyland", "Where it all started", "Visit Disneyland!", 10).store();
- new achievements("dca","2nd gate","Visit Disney California Adventure!",10).store();
- new achievements("epcot","The future", "Visit Epcot!",10).store();
- new achievements("mgm","Lights...Camera...ACTION","Visit MGM studios",10).store();
- new achievements("woc","Carousel of Color","That's a lot of water.",20).store();
- new achievements("gotg","Mission BREAKOUT", "Hey I can see thanooooooosssssssssssss",20).store();
- System.out.println(ChatColor.AQUA + "[HpCore] All achievements have been registered.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement