Bukkit插件错误 - 语法错误},{预期

时间:2013-11-03 09:21:55

标签: syntax minecraft bukkit

我在为this youtube tutorial创建命令时遇到此错误,他解释了如何制作插件,当你加入fireworks爆炸时我想为它做一个命令。

我收到错误Syntax error on token "}", { expected。这是我的代码:

package me.gecco123.EnterWithABang;

import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener{

    public void onDisable(){
        getLogger().info("[EWAB] Disabled");
    }

    public void onEnable(){
        getLogger().info("[EWAB] Enabled");
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
    }

    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
        if (sender instanceof Player){
            Player player = (Player) sender;
            if (cmd.getName().equalsIgnoreCase("forcebang")){
                Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){

                    public void run(){
                    PlayerJoinEvent pje;

                        Firework f = (Firework) pje.getPlayer().getWorld().spawn(pje.getPlayer().getLocation(), Firework.class);
                        FireworkMeta fm = f.getFireworkMeta();
                        fm.addEffect(FireworkEffect.builder()
                             .flicker(false)
                             .trail(true)
                             .with(Type.BALL)
                             .with(Type.BALL_LARGE)
                             .with(Type.STAR)
                             .withColor(Color.YELLOW)
                             .withColor(Color.ORANGE)
                             .withFade(Color.RED)
                             .withFade(Color.PURPLE)
                             .build());
                             fm.setPower(2);
                             f.setFireworkMeta(fm);
                    }

                }, 20);
            }
        }
    }

    @EventHandler
    public void onPlayerJoin (final PlayerJoinEvent pje){
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){

            public void run(){

                Firework f = (Firework) pje.getPlayer().getWorld().spawn(pje.getPlayer().getLocation(), Firework.class);
                FireworkMeta fm = f.getFireworkMeta();
                fm.addEffect(FireworkEffect.builder()
                     .flicker(false)
                     .trail(true)
                     .with(Type.BALL)
                     .with(Type.BALL_LARGE)
                     .with(Type.STAR)
                     .withColor(Color.YELLOW)
                     .withColor(Color.ORANGE)
                     .withFade(Color.RED)
                     .withFade(Color.PURPLE)
                     .build());
                     fm.setPower(2);
                     f.setFireworkMeta(fm);
            }

        }, 20);




        }
}
} 
}

错误发生在第3个最后一个括号

1 个答案:

答案 0 :(得分:1)

删除最后两个括号。你有11个开放和13个关闭括号。