개인 자료란 (JE)

  서버 커뮤니티

Profile 업로드 대표칭호 없음

Upload18 4e03df7f25d64f6db683ff448ef5875f

Profile

질문하기 플러그인

for문 작성 중 오류

2023.02.01 조회 수 60 추천 수 0
이해도 중급자 
게임버전 (JE) 1.18.2 
게임버전 (BE) 관련없음 

SkullMeta를 ItemStack에 for문을 사용하여 적용하려고 했으나 에러가 출력됩니다.


package com.upload18.votesystem;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;

import java.util.*;

public class OpenUI implements CommandExecutor, Listener {
    Inventory shop = Bukkit.createInventory(null, 81, "마피아를 투표하십시오.");
    @Override
    public boolean onCommand(CommandSender sender,Command command,String commandLabel, String[] args) {
        Player player = (Player) sender;

        ItemStack[] votePlayer = {new ItemStack(Material.PLAYER_HEAD)};

        ItemStack glass = new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE);
        ItemMeta glassMeta = glass.getItemMeta();
        List<String> lore = new ArrayList<>();

        Player[] playerList = Bukkit.getOnlinePlayers().toArray(new Player[0]);
        for (int n = 0; n < 8; n++) {
            SkullMeta[] meta = {(SkullMeta) votePlayer[n].getItemMeta()};
            if (playerList[n] == null) {
                votePlayer[n] = new ItemStack(Material.RED_STAINED_GLASS_PANE);
                meta[n].setOwner(null);
                meta[n].setDisplayName(ChatColor.RED + "" + ChatColor.BOLD + "플레이어 없음");
            }
            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "say" + " " + playerList[n].getName());
            meta[n].setOwner(String.valueOf(playerList[n].getName()));
            meta[n].setDisplayName(ChatColor.GREEN + "" + ChatColor.BOLD + "투표");
            meta[n].setLore(lore);
            votePlayer[n].setItemMeta(meta[n]);
        }

        List<String> eggLore = new ArrayList<>();
        ItemStack eggGlass = new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE);
        ItemMeta eggMeta = eggGlass.getItemMeta();
        eggMeta.setDisplayName(ChatColor.GRAY + "ㅎㅇ");
        eggLore.add(ChatColor.DARK_GRAY + "by. 실비");
        eggMeta.setLore(eggLore);
        eggGlass.setItemMeta(eggMeta);

        glassMeta.setDisplayName(" ");
        lore.add(ChatColor.GRAY + "이새끼 족쳐");

        glass.setItemMeta(glassMeta);

        shop.setItem(0, eggGlass);
        for (int i = 1; i < 13; i++) {
            shop.setItem(i, glass);
        } for (int i = 14; i < 22; i++) {
            shop.setItem(i, glass);
        } for (int i = 23; i < 31; i++) {
            shop.setItem(i, glass);
        } for (int i = 32; i < 40; i++) {
            shop.setItem(i, glass);
        } for (int i = 41; i < 49; i++) {
            shop.setItem(i, glass);
        } for (int i = 50; i < 58; i++) {
            shop.setItem(i, glass);
        } for (int i = 59; i < 67; i++) {
            shop.setItem(i, glass);
        } for (int i = 68; i < 76; i++) {
            shop.setItem(i, glass);
        } for (int i = 77; i < 81; i++) {
            shop.setItem(i, glass);
        }

        shop.setItem(13, votePlayer[0]);
        shop.setItem(22, votePlayer[1]);
        shop.setItem(31, votePlayer[2]);
        shop.setItem(40, votePlayer[3]);
        shop.setItem(49, votePlayer[4]);
        shop.setItem(58, votePlayer[5]);
        shop.setItem(67, votePlayer[6]);
        shop.setItem(76, votePlayer[7]);

        player.openInventory(shop);
        return false;
    }
}

아래는 오류 전문입니다 

org.bukkit.command.CommandException: Cannot execute command '투표' in plugin VoteSystem v${version} - plugin is disabled.

        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:37) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

        at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:906) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2307) ~[?:?]

        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2118) ~[?:?]

        at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2099) ~[?:?]

        at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]

        at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]

        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:51) ~[?:?]

        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]

        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]

        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1400) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:188) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]

        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1377) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1370) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]

        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1348) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1230) ~[paper-1.18.2.jar:git-Paper-379]

        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.18.2.jar:git-Paper-379]

        at java.lang.Thread.run(Thread.java:833) ~[?:?]




4개의 댓글

qsef1256
2023.02.01

플러그인이 비활성화 된 경우이며 비활성화 될 당시의 로그를 올려주셔야 답변이 가능합니다.

업로드
2023.02.01
@qsef1256

헉 콘솔창이 작아서 안보였네요

업로드
2023.02.01
@업로드

[20:02:06] [Server thread/ERROR]: Error occurred while enabling VoteSystem v${version} (Is it up to date?)

java.lang.IllegalArgumentException: Size for custom inventory must be a multiple of 9 between 9 and 54 slots (got 81)

at org.apache.commons.lang.Validate.isTrue(Validate.java:136) ~[commons-lang-2.6.jar:2.6]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.createInventory(CraftServer.java:2100) ~[paper-1.18.2.jar:git-Paper-379]

at org.bukkit.Bukkit.createInventory(Bukkit.java:1586) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at com.upload18.votesystem.OpenUI.(OpenUI.java:19) ~[VoteSystem.jar:?]

at com.upload18.votesystem.VoteSystem.onEnable(VoteSystem.java:15) ~[VoteSystem.jar:?]

at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[paper-1.18.2.jar:git-Paper-379]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[paper-1.18.2.jar:git-Paper-379]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.reload(CraftServer.java:1016) ~[paper-1.18.2.jar:git-Paper-379]

at org.bukkit.Bukkit.reload(Bukkit.java:909) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:54) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:159) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]

at org.bukkit.craftbukkit.v1_18_R2.CraftServer.dispatchCommand(CraftServer.java:906) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2307) ~[?:?]

at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2118) ~[?:?]

at net.minecraft.server.network.ServerGamePacketListenerImpl.handleChat(ServerGamePacketListenerImpl.java:2099) ~[?:?]

at net.minecraft.network.protocol.game.ServerboundChatPacket.handle(ServerboundChatPacket.java:46) ~[?:?]

at net.minecraft.network.protocol.game.ServerboundChatPacket.a(ServerboundChatPacket.java:6) ~[?:?]

at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$1(PacketUtils.java:51) ~[?:?]

at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]

at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]

at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1400) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:188) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]

at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1377) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1370) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]

at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1348) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1230) ~[paper-1.18.2.jar:git-Paper-379]

at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.18.2.jar:git-Paper-379]

at java.lang.Thread.run(Thread.java:833) ~[?:?]

qsef1256
2023.02.02
@업로드

인벤토리 슬롯 54개 이상 안 들어간다네요

뉴스 및 창작물
/files/thumbnails/761/908/003/262x150.crop.jpg?20241025153749

건축

서울 숭례문(崇禮門) 4

KHC

2024-10-25

2

/files/thumbnails/578/899/003/262x150.crop.jpg?20241010142350

건축

경주 월정교 1

KHC

2024-10-10

2

/files/thumbnails/219/899/003/262x150.crop.jpg?20241009200950

건축

송전탑+도시 2

dbasd12

2024-10-09

2

/files/thumbnails/246/898/003/262x150.crop.jpg?20241008102328

레드스톤

단다단 - 오토노케(オトノケ) | 마인크래프트 노트블럭 커버

노트블럭전문가

2024-10-08

1

/files/thumbnails/348/896/003/262x150.crop.jpg?20241006103035

디도스/봇테러등등을 낚는 방법 4

물귀신

2024-10-06

3