1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How-to? BROADCASTS

Discussion in 'Plugins/Codes' started by A Christmas Hangar, Jul 22, 2016.

  1. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Hello, this will be a group of medium level bukkit/spigot tutorials (no video). This is for broadcasts:

    I assume you have alredy created the onCommand method
    Code:
     public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
    
    And created your player
    Code:
    
            Player player = (Player)sender;
    

    Now we need to create two ints and a string
    Code:
    int laengeArray = args.length;
                int indexArray = 0;
                String text = "";
    
    Now we need to get the lenght and use the String that we named "text":
    Code:
                for (int i = 0; i < args.length; i++) {
                    text = text + args[i] + " ";
                }
    
    Now the message. Here we will use bukkit one.
    Code:
            Bukkit.broadcastMessage(ChatColor.DARK_RED + "[Alert] " + ChatColor.RED + text);


    I'm noob explaining in text. I know
     
    Buuuddy likes this.
  2. NedGaming

    NedGaming Member

    Joined:
    May 22, 2015
    Messages:
    2,030
    Likes Received:
    1,570
    Trophy Points:
    113
    Gender:
    Male
    Location:
    The Netherlands
    Youre pro, pls
     
  3. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    no, I am not :p
     
  4. NedGaming

    NedGaming Member

    Joined:
    May 22, 2015
    Messages:
    2,030
    Likes Received:
    1,570
    Trophy Points:
    113
    Gender:
    Male
    Location:
    The Netherlands
    Ok, u need to help me with plugins on mu server, check your inbox.
     
  5. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    okay
     
  6. Hulk Hogan

    Hulk Hogan Member

    Joined:
    Aug 9, 2015
    Messages:
    891
    Likes Received:
    1,176
    Trophy Points:
    93
    Gender:
    Male
    Location:
    Sesame Street
    HTML:
    idk what this all means .-.

    gj tho
     
  7. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    I can explain it, if you want :p
     
  8. Hulk Hogan

    Hulk Hogan Member

    Joined:
    Aug 9, 2015
    Messages:
    891
    Likes Received:
    1,176
    Trophy Points:
    93
    Gender:
    Male
    Location:
    Sesame Street
    Dont, my head will explode.
     
  9. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Not really. But it will waste 26 hours of a day. Yes 26 hours
     
  10. Susannaah

    Susannaah Member

    Joined:
    Mar 28, 2016
    Messages:
    517
    Likes Received:
    598
    Trophy Points:
    93
    Gender:
    Female
    What I just read?
     
  11. DanOF

    DanOF Member

    Joined:
    Aug 20, 2015
    Messages:
    335
    Likes Received:
    230
    Trophy Points:
    43
    Gender:
    Male
    Location:
    New Jersey, USA
    Home Page:
    An easier way to make the announcement string is to use String.join (Java 8) or StringUtils.join from Apache commons
     
    iLoveYouu likes this.
  12. Landviz

    Landviz Member

    Joined:
    Feb 20, 2016
    Messages:
    664
    Likes Received:
    391
    Trophy Points:
    63
    Gender:
    Male
    Location:
    North pole
    I'll just keep using /say.. Java = 3hard5me
     
  13. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Java :p
    I'll check this out! Thanks :D
    Read my signature. Java OOP is the answer to everything :p
     
  14. Snooker

    Snooker Member

    Joined:
    Jul 23, 2016
    Messages:
    5
    Likes Received:
    1
    Trophy Points:
    3
    Gender:
    Male
    o_O Too hard for me.
     
  15. A Christmas Hangar

    A Christmas Hangar Member

    Joined:
    Sep 15, 2015
    Messages:
    2,534
    Likes Received:
    1,477
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    Well, this is medium-level tutorial :p
     
    NedGaming likes this.