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 HangarGeek, Jul 22, 2016.

  1. HangarGeek

    HangarGeek Member

    Joined:
    Sep 15, 2015
    Messages:
    2,667
    Likes Received:
    1,641
    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. Neddypoo

    Neddypoo Member

    Joined:
    May 22, 2015
    Messages:
    2,555
    Likes Received:
    2,184
    Trophy Points:
    113
    Gender:
    Male
    Location:
    The Netherlands, Limburg
    Home Page:
    Youre pro, pls
     
  3. HangarGeek

    HangarGeek Member

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

    Neddypoo Member

    Joined:
    May 22, 2015
    Messages:
    2,555
    Likes Received:
    2,184
    Trophy Points:
    113
    Gender:
    Male
    Location:
    The Netherlands, Limburg
    Home Page:
    Ok, u need to help me with plugins on mu server, check your inbox.
     
  5. HangarGeek

    HangarGeek Member

    Joined:
    Sep 15, 2015
    Messages:
    2,667
    Likes Received:
    1,641
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    okay
     
  6. Stille Willem ;p

    Stille Willem ;p Member

    Joined:
    Aug 9, 2015
    Messages:
    973
    Likes Received:
    1,358
    Trophy Points:
    93
    Home Page:
    HTML:
    idk what this all means .-.

    gj tho
     
  7. HangarGeek

    HangarGeek Member

    Joined:
    Sep 15, 2015
    Messages:
    2,667
    Likes Received:
    1,641
    Trophy Points:
    113
    Gender:
    Male
    Location:
    Kepler452B
    Home Page:
    I can explain it, if you want :p
     
  8. Stille Willem ;p

    Stille Willem ;p Member

    Joined:
    Aug 9, 2015
    Messages:
    973
    Likes Received:
    1,358
    Trophy Points:
    93
    Home Page:
    Dont, my head will explode.
     
  9. HangarGeek

    HangarGeek Member

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

    Soeshi Member

    Joined:
    Mar 28, 2016
    Messages:
    687
    Likes Received:
    966
    Trophy Points:
    93
    Gender:
    Female
    Location:
    Starbucks
    What I just read?
     
  11. Dan:

    Dan: Member

    Joined:
    Aug 20, 2015
    Messages:
    333
    Likes Received:
    238
    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:
    1,033
    Likes Received:
    1,116
    Trophy Points:
    113
    Gender:
    Male
    Location:
    North pole
    Home Page:
    I'll just keep using /say.. Java = 3hard5me
     
  13. HangarGeek

    HangarGeek Member

    Joined:
    Sep 15, 2015
    Messages:
    2,667
    Likes Received:
    1,641
    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. HangarGeek

    HangarGeek Member

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