Results 1 to 2 of 2
  1. #1
    Modz is offline Member
    Join Date
    Aug 2012
    Posts
    1
    Rep Power
    0

    Default Java - Plugin for Minecraft

    Hey guys. I am new here and would love some help. I am trying to code a plugin for a game called Minecraft. I have everything done except I need to make a timer between the two different announcements that I have. This is my class.


    Java Code:
    import java.io.IOException;
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class IllzzBC extends JavaPlugin
    {
      public static IllzzBC plugin;
      public final Logger logger = Logger.getLogger("Minecraft");
      public static int currentLine = 0;
      public static int tid = 0;
      public static int running = 1;
      public static long interval = 10L; //300 for 5 minutes
    
      public void onDisable()
      {
        PluginDescriptionFile pdfFile = getDescription();
        this.logger.info(pdfFile.getName() + " version " + pdfFile.getVersion() + 
    " is now disabled.");
      }
    
      public void onEnable()
      {
        PluginDescriptionFile pdfFile = getDescription();
        this.logger.info(pdfFile.getName() + " version " + pdfFile.getVersion() + 
    " is now enabled.");
    
        tid = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
          public void run() {
            Bukkit.getServer().broadcastMessage("§0[§4McTitans§0] "+ 
    ChatColor.LIGHT_PURPLE + "This Is A Test!");
          }
        }
        , 0L, interval * 20L);
      }
    
      public static void broadcastMessage(String fileName) throws IOException
      {
        Bukkit.getServer().broadcastMessage("§0[§4McTitans§0] "+ 
    ChatColor.LIGHT_PURPLE + "This Is A Test!");   <--- This is my first Announcement.
        Bukkit.getServer().broadcastMessage("§0[§4McTitans§0] "+ 
    ChatColor.LIGHT_PURPLE + "Modz Is A Boss");  <--- This is my second
    Announcement.
      }
    }

    How would I add a timer between the first an second announcement so they are displayed on the screen like 20 seconds after each other? Any help would be great.
    Last edited by Modz; 08-19-2012 at 06:39 AM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Java - Plugin for Minecraft

    When you show the first message, start the timer to wait until when you wanted to show the second message. In the method that the timer calls when the time is up, show the second message.
    If you don't understand my response, don't ignore it, ask a question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •