개인 자료란 (JE)

  서버 커뮤니티

Profile 마크초보레오 대표칭호 없음
Profile

질문하기 Java

오류가 나요ㅠㅠ

2021.05.29 조회 수 110 추천 수 0
이해도 플러그인 
게임버전 (JE) 버킷 

package com.leo.leoscheduler.leoscheduler;

import org.bukkit.Bukkit;
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.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.Calendar;

public final class LeoScheduler extends JavaPlugin implements Listener, CommandExecutor {

    boolean check;

    @Override
    public void onEnable() {
        Bukkit.getLogger().info("§bLeoSheduler Enabling....");
        getServer().getPluginManager().registerEvents(this, this);
        getCommand("random").setExecutor(this);
        // Plugin startup logic

    }

    @Override
    public void onDisable() {
        // Plugin shutdown logic
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player) sender;
        Item item = new Item();
        Inventory i = Bukkit.createInventory(null, 27, "시계");
        i.setItem(0, item.setSlot(Material.DIAMOND, "첫번째"));
        i.setItem(13, item.setSlot(Material.COMPASS, ""+ Calendar.getInstance().get(Calendar.HOUR)+"시"+Calendar.getInstance().get(Calendar.MINUTE)+""));
        i.setItem(1, item.setSlot(Material.EMERALD, "두번째"));
        p.openInventory(i);
        return false;
    }

    @EventHandler
    public void a123(InventoryClickEvent e){
        Player p = (Player) e.getWhoClicked();
        if(e.getInventory().getTitle().equals("시계")){
            p.sendMessage("시계 열어주까???");
            e.setCancelled(true);
            if(e.getRawSlot() == 0){
                check = true;
                a1234(p);
            }else if(e.getRawSlot() == 1){
                check = false;
            }
        }
    }

    public void a1234(Player p){
        Item item = new Item();
        new BukkitRunnable(){

            @Override
            public void run() {
                if(check == false) {
                    p.sendMessage("멈췄어!");
                    cancel();
                }
                i.setItem(13, item.setSlot(Material.COMPASS, ""+ Calendar.getInstance().get(Calendar.HOUR)+"시"+Calendar.getInstance().get(Calendar.MINUTE)+"분"));
            }
        }.runTaskTimer(this, 0L,20L);
    }
}

이렇게 있는데 

i.setItem(13, item.setSlot(Material.COMPASS, ""+ Calendar.getInstance().get(Calendar.HOUR)+"시"+Calendar.getInstance().get(Calendar.MINUTE)+"분"));

여기에 i가 빨간글씨로 바뀌어요

어떻게 해야하나요?


1개의 댓글

개발자토미
2021.09.12

i를 전역 변수로 설정하세요