示例#1
0
 private void setup() {
   // Schedule set of mines with tag 1/2 to run immediately
   plugin.getServer().getScheduler().runTaskLater(plugin, new Refill(plugin, 1, 0), 100);
   plugin.getServer().getScheduler().runTaskLater(plugin, new Refill(plugin, 2, 0), 100);
   // Schedule mins with tag 1 to run in 10 mintes, tag 2 in 20
   plugin.getServer().getScheduler().runTaskLater(plugin, new Refill(plugin, 1, 1), 100);
   plugin
       .getServer()
       .getScheduler()
       .runTaskLater(plugin, new Refill(plugin, 2, 2), 10800 + 100); // Offset by 9 minutes
 }
示例#2
0
  public MineManager(ConRiot plugin) {
    this.plugin = plugin;

    // Get the file for the block data
    dataFile = new ConfigAccessor(plugin, file);

    // Instantiate mines hashmap
    mines = new HashMap<String, Mine>();

    // Verify we have enough info
    if (!(valid = hasNeededKeys())) {
      plugin.getLogger().warning("Mines data file '" + file + "' didn't have sufficient keys!");
      return; // Log a nice warning so we know what's up
    }

    // Load all the cells in the block
    List<String> list = dataFile.getConfig().getStringList("mines");
    for (String entry : list) {
      Mine m = new Mine(plugin, dataFile, entry, true);
      if (m.isValid()) mines.put(entry, m);
    }

    // Load up the correct MineRefiller implementation, log manager as active
    String p = plugin.getServer().getClass().getPackage().getName();
    String version = p.substring(p.lastIndexOf('.') + 1);
    if (version.equals("v1_5_R3")) {
      refiller = new V1_5_R3MineRefiller(this);
      plugin.getLogger().info("Mine Manager is online! [V1_5_R3 NMS]");
    } else {
      refiller = new BukkitMineRefiller(this);
      plugin.getLogger().info("Mine Manager is online! [Bukkit API]");
    }

    // Set up piston event listener
    plugin.getServer().getPluginManager().registerEvents(this, plugin);

    // Done loading, call setup to start the refills
    setup();
  }
示例#3
0
 public void run() {
   switch (state) {
     case 0: // Special case, immediately refill, do not schedule another
       plugin
           .getServer()
           .broadcastMessage(
               ChatColor.GREEN
                   + "The mines have been reset! "
                   + ChatColor.AQUA
                   + "("
                   + refiller.refill(tag)
                   + "ms)");
       break;
     case 1: // Mark for refill in 20 minutes
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(
               plugin, new Refill(plugin, tag, state + 1), 22800); // 19 minutes = 22800
       break;
     case 2: // Mark for refill in 1 minutes
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "1 Minute until the mines reset!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 1100); // 55 seconds = 1100
       break;
     case 3: // Mark for refill in 5 seconds
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "5!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 20);
       break;
     case 4: // Mark for refill in 4 seconds
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "4!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 20);
       break;
     case 5: // Mark for refill in 3 seconds
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "3!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 20);
       break;
     case 6: // Mark for refill in 2 seconds
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "2!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 20);
       break;
     case 7: // Mark for refill in 1 seconds
       plugin.getServer().broadcastMessage(ChatColor.GOLD + "1!");
       plugin
           .getServer()
           .getScheduler()
           .runTaskLater(plugin, new Refill(plugin, tag, state + 1), 20);
       break;
     case 8: // Refill now, start cycle over
       plugin
           .getServer()
           .broadcastMessage(
               ChatColor.GREEN
                   + "The mines have been reset! "
                   + ChatColor.AQUA
                   + "("
                   + refiller.refill(tag)
                   + "ms)");
       plugin.getServer().getScheduler().runTask(plugin, new Refill(plugin, tag, 1));
       break;
   }
 }