Пример #1
0
  @Override
  public void onDisable() {
    super.onDisable();

    List<String> blockBagList = new ArrayList<>();
    for (BlockBag blockBag : blockBags) blockBagList.add(blockBag.toString());

    config.getNode("blockbags").setValue(blockBagList);
  }
Пример #2
0
  public void createBlockBag(Player creator, BlockBag blockBag) {
    if (getBlockBag(creator.getUniqueId(), blockBag.simpleName) != null) {
      creator.sendMessage(Text.of(TextColors.RED, "A blockbag with this name already exists!"));
      return;
    }

    blockBag.blockBagId = getUnusedID();

    blockBags = Arrays.copyOf(blockBags, blockBags.length + 1);
    blockBags[blockBags.length - 1] = blockBag;
  }
Пример #3
0
  @Override
  public void onInitialize() throws CraftBookException {
    super.onInitialize();

    try {
      List<String> blockBagList = config.getNode("blockbags").getList(TypeToken.of(String.class));
      blockBags = new BlockBag[blockBagList.size()];
      for (int i = 0; i < blockBagList.size(); i++) {
        blockBags[i] = BlockBag.createFromString(blockBagList.get(i));
      }
    } catch (ObjectMappingException e) {
      CraftBookPlugin.spongeInst().getLogger().error("Failed to map object.", e);
    }
  }