gpt4 book ai didi

java - Spigot/Bukkit插件开发1.15.2自定义播放器头部报错找不到符号

转载 作者:行者123 更新时间:2023-12-01 16:34:43 26 4
gpt4 key购买 nike

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;
}

我遵循了本教程:https://www.spigotmc.org/threads/using-custom-head-textures.311562/因为我找不到任何其他与我想做的事情类似的事情。

我的错误maven错误:

[ERROR] PATH(HIDDEN)/HelloCommand.java:[37,53] cannot find symbol
[ERROR] symbol: class Property
[ERROR] location: class me.testwebsite.testplugin.commands.HelloCommand

有人有解决办法吗?我希望能够使用此网站获得自定义头部:https://minecraft-heads.com/custom-heads/decoration/35007-ultimate-solar-generator放置在 block 上然后使用。我在获取头部对象时遇到问题。

最佳答案

解决方案没有读取整个错误,也没有在 pom.xml 文件中导入 mojang。

关于java - Spigot/Bukkit插件开发1.15.2自定义播放器头部报错找不到符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61984984/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com