public HelloCommand(Main plugin) {
this.plugin = plugin;
plugin.getCommand("tptest").setExecutor(this);
}
private static ItemStack createSkull(String url) {
@SuppressWarnings("deprecation")
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1, (short) 3);
if (url.isEmpty())
return head;
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", url));
try {
Field profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
head.setItemMeta(headMeta);
return head;
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players may execute this command!");
return true;
}
Player player = (Player) sender;
if (player.hasPermission("testplugin.test")) {
player.sendMessage("Perms are loaded!");
/*ItemStack item = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta)item.getItemMeta();
meta.setOwningPlayer(Bukkit.getPlayer(UUID.fromString("23077a1b-183a-438c-bc14-e01a8d0381a1")));
meta.setDisplayName("Urn");
item.setItemMeta(meta);
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.YELLOW + "an urn!");
player.getInventory().addItem(item);*/
player.getInventory().addItem(createSkull("c4fe135c311f7086edcc5e6dbc4ef4b23f819fddaa42f827dac46e3574de2287"));
return true;
} else {
player.sendMessage("You do not have permission to execute this command!");
}
return false;
}
I followed this tutorial: https://www.spigotmc.org/threads/using-custom-head-textures.311562/ since I couldn't find any other similar thing to what I wanted to do.
My error maven error:
[ERROR] PATH(HIDDEN)/HelloCommand.java:[37,53] cannot find symbol
[ERROR] symbol: class Property
[ERROR] location: class me.testwebsite.testplugin.commands.HelloCommand
Does anyone have any solution for this? I want to be able to get a custom head using this website: https://minecraft-heads.com/custom-heads/decoration/35007-ultimate-solar-generator to place on a block then use later. I am having issues with getting the head object.
Solution was not reading the entire error and not importing mojang in the pom.xml file.