Magic

Magic

190k Downloads

Implement SkillPoints with API

Shilodabing opened this issue · 1 comments

commented

Hi nathan!
After weeks I'm here again! , I tried to solve my error about to give the skillPoints to the author of the book but when I try to move or modify the value
Mage m = main.api.getMage(p);
to
Mage m = main.api.getMage(author);

]------------------------------------[Update]-------------------------------------{
Was a little error by me ,first I defined "author" with the value of the author of the book, next I defined author with the value of name and I assigned to mage the author and is the value "name" , I tested and works 100% , so.. I think i dont have more question about implements the SkillPoints :)

This is the new code, more clear, short and efficient i think

		if(args.length == 1){
			if(args[0].length() == 1) {
				if(mano != null && mano.getType() != Material.AIR){
					if(mano.getType() == Material.WRITTEN_BOOK) {
						BookMeta bm = (BookMeta) is.getItemMeta();
						String autor = bm.getAuthor();
						Player nombre = Bukkit.getPlayer(autor);
						String calificar = args[0];
						Mage alumno = main.api.getMage(nombre);
						Map<String, Integer> myMap = new HashMap<String, Integer>();
						myMap.put("A", 15);
						myMap.put("B", 10);
						myMap.put("C", 5 );
						myMap.put("D", 0 );
						if(myMap.get(calificar) != null) {
							ItemMeta catlm = is.getItemMeta();
							catlm.setLore(Arrays.asList(ChatColor.GREEN + "Has obtenido una " + calificar));
							is.setItemMeta(catlm);	
							alumno.addSkillPoints((myMap.get(calificar)));
						}
						nombre.getInventory().addItem(mano);
						nombre.sendMessage(ChatColor.AQUA + "Tu tarea de clase ha sido evaluada!.");
						player.getInventory().remove(mano);
						return true;
					}
					player.sendMessage(ChatColor.RED + "No puedes calificar un libro no firmado");
					return true;		
				}
				player.sendMessage(ChatColor.RED + "Debes sostener un cuaderno para poder calificar");
				return true;
			}
			player.sendMessage(ChatColor.RED + "El uso correcto es /calificar <calificación>");
			return true;
		}
commented

I'm glad you got it working! Feel free to open another issue if you run into trouble.