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

问题描述 投票:0回答:1
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/,因为找不到与我想做的事情类似的事情。

我的错误行家错误:

[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放置在块上,然后再使用。我在获取头部对象时遇到问题。

java bukkit
1个回答
0
投票

解决方案未读取全部错误,也未在pom.xml文件中导入mojang。

© www.soinside.com 2019 - 2024. All rights reserved.