Solved The code used to work, i copy and paste it, and it doesn't anymore!

Discussion in 'Plugin Development' started by linkrock4, Nov 26, 2012.

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

    linkrock4

    Hello, as the title says, the code used to work before it had been copied and pasted somewhere else. and then it stopped working.

    Heres the code:
    Code:
    package net.skydevs.src;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.inventory.ItemStack;
    import java.util.Random;
     
    public class Christmas extends JavaPlugin implements Listener {
        Random rand = new Random();
        public String ChristmasMessage;
     
        public void onEnable() { // Server Starts
            getLogger().info("Christmas Plugin has been enabled!");
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
        }
     
        public void onDisable() { // Server Stops
            getLogger().info("Christmas Plugin has been disabled!");
     
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
     
          if (cmd.getName().equalsIgnoreCase("Christmas")) {
          Bukkit.broadcastMessage(ChatColor.BLACK+"["+ChatColor.RED+"Christmas"+ChatColor.BLACK+"] "+ChatColor.GREEN+"The "+ChatColor.RED+"Christmas "+ChatColor.GREEN+"plugin been activated!");
     
          }
     
    return false;
     
          @EventHandler
          @SuppressWarnings("deprecation")
          public void ------> onBlockPlace(<------ BlockPlaceEvent e------>)<------ {
            Block b = e.getBlockPlaced();
            if(b.getTypeId() == 56) {
            int id = 0;
            id = rand.nextInt((400+1) - 1) + 1;
            e.getPlayer().sendMessage(ChatColor.BLACK+"["+ChatColor.RED+"Christmas"+ChatColor.BLACK+"] "+ChatColor.GREEN+"Ho! Ho! Ho!"+ChatColor.RED+"Merry Christmas! Enjoy your gift!");
            e.getPlayer().getInventory().addItem(new ItemStack(id, 1));
            e.getPlayer().updateInventory();
            e.getPlayer().getInventory().removeItem(new ItemStack(56, 1));
            e.setCancelled(true);
    }
    }
        }
    }
    Whats in the red is where the problem is, they are the 3 problems in the code and i cant find out why. EDIT: WHATS IN BETWEEN THE ARROWS BECAUSE COLORS OBVIOUSLY DONT WORK

    so basicly the error is onBlockPlace( bla bla bla ) <----- is the error
     
  2. Offline

    JazzaG

    onBlockPlace() is in the body of onCommand()
     
  3. Offline

    linkrock4

    And how do i take it out? xD
    EDIT: Nvm, fixed :D thanks!
     
  4. Offline

    Woobie

    Put another body under "return false;"
    Code:
      return false;
    }
    
    @EventHander etc.. 
     
  5. Offline

    JazzaG

    Code:
    package net.skydevs.src;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.inventory.ItemStack;
    import java.util.Random;
     
    public class Christmas extends JavaPlugin implements Listener {
        Random rand = new Random();
        public String ChristmasMessage;
     
        public void onEnable() { // Server Starts
            getLogger().info("Christmas Plugin has been enabled!");
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
        }
     
        public void onDisable() { // Server Stops
            getLogger().info("Christmas Plugin has been disabled!");
     
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args) {
      if (cmd.getName().equalsIgnoreCase("Christmas")) {
       Bukkit.broadcastMessage(ChatColor.BLACK+"["+ChatColor.RED+"Christmas"+ChatColor.BLACK+"] "+ChatColor.GREEN+"The "+ChatColor.RED+"Christmas "+ChatColor.GREEN+"plugin been activated!");
      }
     
      return false;
     }
     
        @EventHandler
        @SuppressWarnings("deprecation")
        public void ------> onBlockPlace(<------ BlockPlaceEvent e------>)<------ {
      Block b = e.getBlockPlaced();
            if(b.getTypeId() == 56) {
       int id = 0;
       id = rand.nextInt((400+1) - 1) + 1;
       e.getPlayer().sendMessage(ChatColor.BLACK+"["+ChatColor.RED+"Christmas"+ChatColor.BLACK+"] "+ChatColor.GREEN+"Ho! Ho! Ho!"+ChatColor.RED+"Merry Christmas! Enjoy your gift!");
       e.getPlayer().getInventory().addItem(new ItemStack(id, 1));
       e.getPlayer().updateInventory();
       e.getPlayer().getInventory().removeItem(new ItemStack(56, 1));
       e.setCancelled(true);
      }
     }
        
    }
    
     
  6. Offline

    linkrock4

    :p yah fixed it right before you wrote it :D Thanks!
     
Thread Status:
Not open for further replies.

Share This Page