令牌上的语法错误"}",{预期

时间:2016-08-18 02:11:42

标签: java

此问题仍然存在。我无法删除它。请帮忙! 我尝试了很多不同的东西,但没有任何工作。

package me.swoq;

import org.bukkit.command.Command;

import org.bukkit.command.CommandSender;
import java.util.Random;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.Material;


public class RTPPlus extends JavaPlugin {

    public Permission playerPermission = new Permission("rtp.teleport");

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

    if (cmd.getName().equalsIgnoreCase("rtp") && sender instanceof Player) {
        Player player = (Player) sender;                
        Location originalLocation = player.getLocation();
        Random random = new Random();

        int x = random.nextInt(1000) + 1;
        int y = 70;
        int z = random.nextInt(1000) + 1;

        boolean isOnLand = false;

        while (isOnLand == false) {

        Location teleportLocation = new Location(player.getWorld(), x, y, z);

        if (teleportLocation.getBlock().getType() != Material.AIR) {
             isOnLand = true;



        player.teleport(teleportLocation);

        player.sendMessage(ChatColor.GREEN + "You have been teleported " + (int)teleportLocation.distance(originalLocation) + " blocks away!");




        }

        return true;

        }

    } 
    return false;       
    }
    return false;
    }
}
}

1 个答案:

答案 0 :(得分:0)

查看最后2个return false语句,并查看您方法的范围。

public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    //method content
    }
    return false;       
}
return false;
}

关闭方法的花括号后,您还有一个返回语句。请格式化您的代码,然后您将看到出了什么问题。

删除最后return false和右手大括号("}")