0

我在为这个 youtube 教程创建命令时遇到了这个错误,他解释了如何制作一个插件,当你加入烟花爆炸时,我想为它制作一个命令。

我得到了错误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);




        }
}
} 
}

错误在倒数第三个括号

4

1 回答 1

1

删除最后两个括号。您有 11 个左括号和 13 个右括号。

于 2013-11-03T09:25:53.390 回答