0

我正在使用 Bukkit 的 API,但我会从中剪掉一些代码,因为它不是 API(因为它没有在我正在做的事情中引入)。因此,我不断收到“空指针异常”,在搜索 Google 之后,我似乎无法将任何修复与我的代码联系起来。所以这是我的代码:

Integer tier = null;
    for(Integer i = 1; i <= 5;) 
    {
        if (p.hasPermission("flyp.fly." + i.toString())){
            tier = i - 1;
            break;
        }
        i++;
    }

if(tier == null) 
    {
            p.sendMessage(ChatColor.RED + "You lack the permission to do this!");
            return true;
    }

使用此代码时,(当我使用“/fly on”事件时)我得到一个“空指针异常”,它指向“if(tier == null)”行。最后,我在清理“旧”代码,这部分是我朋友写的,我似乎联系不上-_-。

感谢您的帮助,AhellHound

4

0 回答 0