Exemple #1
0
  // prints a list of Strings at the specified page
  public void list(CommandSender sender, ArrayList<String> strings, int page) {
    int pages = (int) Math.ceil(strings.size() / 7F);
    if (page > pages || page < 1) {
      page = 1;
    }

    sender.sendMessage(
        color(
            "&7-------------- &f"
                + languageReader.get("Etc_Page")
                + " &6"
                + page
                + "&f/&6"
                + pages
                + " &7--------------"));

    ListIterator<String> iter = strings.listIterator((page - 1) * 7);

    for (int i = 0; i < 7; i++) {
      if (iter.hasNext()) {
        sender.sendMessage(color(iter.next()));
      } else {
        break;
      }
    }
  }
Exemple #2
0
  @Override
  public void onDisable() {

    // Disable listeners
    HandlerList.unregisterAll(this);

    // Stop shedulers
    getServer().getScheduler().cancelTasks(this);

    if (p == null) {
      return;
    }

    // save Data to Disk
    DataSave.save(true);

    // save LanguageReader
    languageReader.save();

    // delete Data from Ram
    Barrel.barrels.clear();
    BCauldron.bcauldrons.clear();
    BIngredients.possibleIngredients.clear();
    BIngredients.recipes.clear();
    BIngredients.cookedNames.clear();
    BPlayer.clear();
    Brew.potions.clear();
    Wakeup.wakeups.clear();
    Words.words.clear();

    this.log(this.getDescription().getName() + " disabled!");
  }
Exemple #3
0
  public void reload(CommandSender sender) {
    // clear all existent config Data
    BIngredients.possibleIngredients.clear();
    BIngredients.recipes.clear();
    BIngredients.cookedNames.clear();
    Words.words.clear();
    BPlayer.drainItems.clear();
    if (useLB) {
      try {
        LogBlockBarrel.clear();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }

    // load the Config
    try {
      if (!readConfig()) {
        p = null;
        getServer().getPluginManager().disablePlugin(this);
        return;
      }
    } catch (Exception e) {
      e.printStackTrace();
      p = null;
      getServer().getPluginManager().disablePlugin(this);
      return;
    }

    // save and load LanguageReader
    languageReader.save();
    languageReader =
        new LanguageReader(new File(p.getDataFolder(), "languages/" + language + ".yml"));

    // Reload Recipes
    Boolean successful = true;
    for (Brew brew : Brew.potions.values()) {
      if (!brew.reloadRecipe()) {
        successful = false;
      }
    }
    if (!successful) {
      msg(sender, p.languageReader.get("Error_Recipeload"));
    }
  }