Solved Stuck on my auto broadcast part of my plugin

Discussion in 'Plugin Development' started by DominicGamesHD, Mar 24, 2016.

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

    DominicGamesHD

    Okay so I am trying to make a broadcast plugin manual not automatic so this is my code so far
    Code:
    package com.clasteen.aessentials;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin{
        public static int message = "Test";
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(cmd.getName().equalsIgnoreCase("broadcast")){
           
                    Bukkit.broadcastMessage(ChatColor.DARK_RED + "[" + ChatColor.GOLD + "Broadcast" + ChatColor.DARK_RED + "]" + message);
                }
           
           
            return false;
        }
       
       
    
    }
    
    So if I want it to make have when they do /broadcast <message that they want in here>. How would I do it I am a little confused here please help me and explain in as much detail possiable please :)

    All feedback is appreciated!
     
  2. Offline

    Zombie_Striker

    @DominicGamesHD
    • Make sure there is a message that they are trying to broadcast first. (if args are greater than 0)
    • Get all the args and add them into one string (Use a String Builder)
    • Bukkit.broadcast(Message).
    Note: You are misusing Static. Please remove the static modifier.
     
    DominicGamesHD likes this.
  3. Offline

    mine-care

    Ontop of what @Zombie_Striker very correctly pointed out,
    Is it just me that thinks something is wrong here?
    I am pretty sure a piece of text (CharSequence) isn't an integer.
     
  4. Offline

    mcdorli

    1.: Don't use a domain you don't own. (clasteen.com)
    2.: You never return true in the onCommand, you will get the usage text
    3.: You don't register the command (getCommand("yourcommand").setExecutor(new YourClass()) inside your onEnable)
    4.: Don't remove the @Override annotation, it's a good practise to have it there
     
  5. Offline

    DominicGamesHD

    @mcdroli that is my domain

    Should I make it
    public static String ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 25, 2016
  6. Offline

    Swakiny


    I recommend you to learn java first. You are going wrong way, learning how to make a bukkit plugin without java will give you too much trouble.

    Here some links:
    https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
Thread Status:
Not open for further replies.

Share This Page