Error to load plugin

Discussion in 'Plugin Development' started by wasmake, Oct 29, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    wasmake

    [​IMG]

    Code:
    package me.akardooo.annihilation;
     
    import java.util.logging.Logger;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.block.Sign;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.event.player.PlayerInteractEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    import org.bukkit.scoreboard.Team;
     
    public class Main extends JavaPlugin
    implements Listener
    {
        private static final Logger log = Logger.getLogger("Minecraft");
       
        @Override
        public void onEnable()
        {
            log.info("[Annihilation] Annihilation has been enabled!");
            log.info(" Plugin by wasmake");
        }
     
        @Override
        public void onDisable()
        {
            log.info("[Annihilation] Annihilation has been disabled!");
            log.info(" Plugin by wasmake");
        }
       
        ScoreboardManager manager = Bukkit.getScoreboardManager(); // Scoreboard
        Scoreboard board = manager.getNewScoreboard();
     
        Team blue = board.registerNewTeam("blue"); //team Blue
        Team red = board.registerNewTeam("red"); //team Red
        Team yellow = board.registerNewTeam("yellow"); //team yellow
        Team green = board.registerNewTeam("green"); //team green
       
        public abstract class SignUpdater extends BukkitRunnable {
           
            World world = Bukkit.getServer().getWorld("world");
            Sign signB = getSign(new Location(world, 301, 63, 311));
            Sign signR = getSign(new Location(world, 305, 63, 307));
            Sign signG = getSign(new Location(world, 301, 63, 303));
            Sign signY = getSign(new Location(world, 297, 63, 307));
           
     
        public void run() {
         
            signB.setLine(1, "Blue Team");
            signB.setLine(2, "Players: " + ChatColor.BLUE + blue.getSize());
            signR.setLine(1, ChatColor.RED + "Equipo Rojo");
            signR.setLine(2, "Jugadores: " + ChatColor.RED + red.getSize());
            signG.setLine(1, ChatColor.GREEN + "Equipo Verde");
            signG.setLine(2, "Jugadores: " + ChatColor.GREEN + green.getSize());
            signY.setLine(1, ChatColor.YELLOW + "Equipo Amarillo");
            signY.setLine(2, "Jugadores: " + ChatColor.YELLOW + yellow.getSize());
           
            signB.update();
            signR.update();
            signG.update();
            signY.update();
           
            }
           
            public Sign getSign(Location loc){
            Block block = loc.getBlock();
            if(!(block.getType() == Material.SIGN_POST)) return null;
            return ((Sign) block.getState());
            }
       
     
    @EventHandler
    public void clickHandler(PlayerInteractEvent e) {
        Player p = (Player) e.getPlayer();
        Block clickedBlock = e.getClickedBlock();
        if(!(clickedBlock.getType()==Material.SIGN || clickedBlock.getType()==Material.SIGN_POST || clickedBlock.getType()==Material.WALL_SIGN)) return;
        Sign s = (Sign) clickedBlock.getState();
        if(!(e.getAction()==Action.RIGHT_CLICK_BLOCK || e.getAction()==Action.LEFT_CLICK_BLOCK)) return;
            if (e.getClickedBlock().getState() instanceof Sign) {
                    if (s.getLine(1).equalsIgnoreCase("Blue Team")) {
                            if (!p.hasPermission("anni.user")) {
                                p.sendMessage(ChatColor.BLUE + "You join to the blue team");
                                blue.addPlayer(p);
                            }
                    }
                            if (s.getLine(1).equalsIgnoreCase("Red Team")) {
                                if (!p.hasPermission("anni.user")) {
                                    p.sendMessage(ChatColor.BLUE + "You join to the red team");
                                    red.addPlayer(p);
                                }
                            }
                            if (s.getLine(1).equalsIgnoreCase("Green Team")) {
                                    if (!p.hasPermission("anni.user")) {
                                        p.sendMessage(ChatColor.BLUE + "You join to the green team");
                                        green.addPlayer(p);
                                    }
                            }
                            if (s.getLine(1).equalsIgnoreCase("Yellow Team")) {
                                        if (!p.hasPermission("anni.user")) {
                                            p.sendMessage(ChatColor.BLUE + "You joint to the yellow team");
                                            yellow.addPlayer(p);
                                        }
                            }
            }
        }
    }
    @EventHandler
    public void onBlockBreak(final BlockBreakEvent event){
        Player p = (Player) event.getPlayer();
        if (event.getBlock().getType() == Material.ENDER_STONE)
        {
            event.setCancelled(true);
            Bukkit.broadcastMessage(ChatColor.AQUA + "[Annihilation] " + ChatColor.WHITE+"1 Nexus damage by " + event.getPlayer());
        }
     
        if (event.getBlock().getType() == Material.IRON_ORE){
        p.getInventory().addItem(new ItemStack(Material.IRON_ORE));
        p.giveExp(2);
        event.getBlock().setType(Material.COBBLESTONE);
        event.setCancelled(true);
        new BukkitRunnable(){
            public void run(){
                event.getBlock().setType(Material.IRON_ORE);
            }
        }.runTaskLater(this, 600);
        }
        if (event.getBlock().getType() == Material.STONE){
        p.getInventory().addItem(new ItemStack(Material.STONE));
        p.giveExp(2);
        event.getBlock().setType(Material.COBBLESTONE);
        event.setCancelled(true);
        new BukkitRunnable(){
            public void run(){
                event.getBlock().setType(Material.STONE);
            }
        }.runTaskLater(this, 200);
        }
        if (event.getBlock().getType() == Material.LOG){
        p.getInventory().addItem(new ItemStack(Material.LOG));
        p.giveExp(2);
        event.getBlock().setType(Material.AIR);
        event.setCancelled(true);
        new BukkitRunnable(){
            public void run(){
                event.getBlock().setType(Material.LOG);
            }
        }.runTaskLater(this, 300);
        }
    }
    }
    
    Thx for your help!

    MineDoubleSpace
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Offline

    Rocoty

    Place initialization of your fields into onEnable(). Initializing the fields outside onEnable causes them to be initialized just as the class gets instantiated, which is way too early. At least as far as Scoreboards go.
     
  3. Offline

    wasmake

Thread Status:
Not open for further replies.

Share This Page