public static void saveInventory(String name, PInv pinv) {
    BaseSerializer serializer = getSerializer(name);
    Date now = new Date();
    String date = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(now);
    System.out.println("10. " + date);
    int curSection = serializer.config.getInt("curSection", 0);
    serializer.config.set("curSection", (curSection + 1) % 3);
    ConfigurationSection pcs = serializer.config.createSection(curSection + "");
    pcs.set("storedDate", date);
    List<String> stritems = new ArrayList<String>();
    for (ItemStack is : pinv.armor) {
      if (is == null || is.getType() == Material.AIR) continue;
      stritems.add(InventoryUtil.getItemString(is));
    }
    pcs.set("armor", stritems);

    stritems = new ArrayList<String>();
    for (ItemStack is : pinv.contents) {
      if (is == null || is.getType() == Material.AIR) continue;
      stritems.add(InventoryUtil.getItemString(is));
    }
    pcs.set("contents", stritems);

    serializer.save();
  }
 public static void LocationRegister(Location Loc, String MainMsg, String SubMsg, String Index) {
   File file = new File("plugins/rTutorialReloaded/Location.yml");
   YamlConfiguration LocationYaml = YamlConfiguration.loadConfiguration(file);
   ConfigurationSection CS = LocationYaml.getConfigurationSection("Locations");
   CS.createSection(Index);
   World world = Loc.getWorld();
   double x = Double.valueOf(Loc.getX());
   double y = Double.valueOf(Loc.getY());
   double z = Double.valueOf(Loc.getZ());
   float pitch = Loc.getPitch();
   float yaw = Loc.getYaw();
   ConfigurationSection CS2 = CS.getConfigurationSection(Index);
   CS2.createSection("Location");
   CS2.createSection("Message");
   ConfigurationSection CS3 = FileSection.PlusSelect(CS2, "Location");
   CS3.set("World", world.getName());
   CS3.set("Coordinate", x + "," + y + "," + z);
   CS3.set("Angle", String.valueOf(yaw + "," + pitch));
   ConfigurationSection CS4 = FileSection.PlusSelect(CS2, "Message");
   CS4.set("Main", MainMsg);
   if (!(SubMsg.equalsIgnoreCase("¾øÀ½") || SubMsg.equalsIgnoreCase("None"))) {
     CS4.set("Sub", SubMsg);
   }
   try {
     LocationYaml.save(file);
   } catch (IOException e) {
     e.printStackTrace();
   }
   LocationLoader.LocationCfg();
   return;
 }
Exemple #3
0
 public void save(ConfigurationSection section) {
   section.set("location.world", loc.getWorld().getName());
   section.set("location.x", loc.getX());
   section.set("location.y", loc.getY());
   section.set("location.z", loc.getZ());
   section.set("arena", arena.getID());
 }
  @Override
  public void setDefaultGroup(PermissionGroup group, String worldName) {
    ConfigurationSection groups = this.permissions.getConfigurationSection("groups");

    String defaultGroupProperty = "default";
    if (worldName != null) {
      defaultGroupProperty = buildPath("worlds", worldName, defaultGroupProperty);
    }

    for (Map.Entry<String, Object> entry : groups.getValues(false).entrySet()) {
      if (entry.getValue() instanceof ConfigurationSection) {
        ConfigurationSection groupSection = (ConfigurationSection) entry.getValue();

        groupSection.set(defaultGroupProperty, false);

        if (!entry.getValue().equals(group.getName())) {
          groupSection.set(defaultGroupProperty, null);
        } else {
          groupSection.set(defaultGroupProperty, true);
        }
      }
    }

    this.save();
  }
Exemple #5
0
  @Override
  public void serialize(ConfigurationSection section) {
    super.serialize(section, TYPE);

    section.set("amount", amount);
    section.set("boss", name);
  }
 private boolean importIsland(uSkyBlock plugin, File file) {
   log.info("Importing " + file);
   FileConfiguration config = new YamlConfiguration();
   readConfig(config, file);
   if (config.contains("party.leader") && !config.contains("party.leader.name")) {
     String leaderName = config.getString("party.leader");
     ConfigurationSection leaderSection = config.createSection("party.leader");
     leaderSection.set("name", leaderName);
     leaderSection.set("uuid", UUIDUtil.asString(getUUID(leaderName)));
   }
   ConfigurationSection members = config.getConfigurationSection("party.members");
   if (members != null) {
     for (String member : members.getKeys(false)) {
       ConfigurationSection section = members.getConfigurationSection(member);
       if (!section.contains("name")) {
         members.set(member, null);
         String uuid = UUIDUtil.asString(getUUID(member));
         members.createSection(uuid, section.getValues(true));
         members.set(uuid + ".name", member);
       } else {
         log.info("Skipping " + member + ", already has a name");
       }
     }
   }
   try {
     config.save(file);
     return true;
   } catch (IOException e) {
     log.log(Level.SEVERE, "Failed to import " + file, e);
     return false;
   }
 }
Exemple #7
0
 // saves data into main Ingredient section. Returns the save id
 public int save(ConfigurationSection config) {
   String path = "Ingredients." + id;
   if (cookedTime != 0) {
     config.set(path + ".cookedTime", cookedTime);
   }
   config.set(path + ".mats", serializeIngredients());
   return id;
 }
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(SkillSetting.DURATION.node(), Integer.valueOf(10000));
   node.set(SkillSetting.DURATION_INCREASE.node(), Integer.valueOf(10));
   node.set(SkillSetting.COOLDOWN.node(), Integer.valueOf(0));
   node.set(SkillSetting.MANA.node(), Integer.valueOf(0));
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(Setting.AMOUNT.node(), 0.25);
   node.set("amount-increase", 0.0);
   node.set("hst-amount", 0);
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set("BaseTickDamage", 0);
   node.set("LevelMultiplier", 0.5);
   node.set(Setting.DURATION.node(), 12000);
   return node;
 }
 public static void save(ConfigurationSection config, Scoreboard scoreboard) {
   config.set("command", scoreboard.getCommand());
   config.set("interval", scoreboard.getRefresh());
   config.set("sender", scoreboard.getSender().name().toLowerCase());
   config.set("filter", scoreboard.getFilter());
   config.set("delay", scoreboard.getDelay());
   save(config.createSection("location"), scoreboard.getLocation());
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(Setting.CHANCE.node(), 0.2);
   node.set(Setting.CHANCE_LEVEL.node(), 0);
   node.set("hst-chance", 0);
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(SkillSetting.DAMAGE.node(), 30);
   node.set(SkillSetting.DAMAGE_INCREASE.node(), 0);
   node.set(SkillSetting.RADIUS.node(), 10);
   node.set(SkillSetting.RADIUS_INCREASE.node(), 0);
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(Setting.DAMAGE.node(), Integer.valueOf(5));
   node.set("block-dmg", Integer.valueOf(0));
   node.set("mana-per-shot", Integer.valueOf(1));
   node.set("radius", Integer.valueOf(5));
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(SkillSetting.CHANCE.node(), 0.2);
   node.set(SkillSetting.CHANCE_LEVEL.node(), 0);
   node.set("damage-multiplier", 2.0);
   node.set("damage-multiplier-increase", 0);
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set("chance-2x", 0.2);
   node.set("chance-3x", 0.1);
   node.set("added-chance-2x-per-level", 0.0);
   node.set("added-chance-3x-per-level", 0.0);
   return node;
 }
Exemple #17
0
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(Setting.DURATION.node(), 30000); // in milliseconds
   node.set(Setting.PERIOD.node(), 200); // in milliseconds
   node.set(Setting.APPLY_TEXT.node(), "%hero% is lighting the way.");
   node.set(Setting.EXPIRE_TEXT.node(), "%hero% is no longer lighting the way");
   return node;
 }
 // -----------------------  Private static methods.
 private static void savePriceMap(Price p, ConfigurationSection bought, Integer amount) {
   bought.set("type", p.getType());
   bought.set("data", p.getData());
   bought.set("iamount", p.getAmount());
   bought.set("amount", amount);
   bought.set("metahash", p.getMetaHash());
   if (p.hasDescription()) {
     bought.set("description", p.getDescription());
   }
 }
Exemple #19
0
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set(Setting.DURATION.node(), 10000);
   node.set(Setting.PERIOD.node(), 2000);
   node.set("tick-damage", 1);
   node.set(Setting.APPLY_TEXT.node(), "%target% is bleeding!");
   node.set(Setting.EXPIRE_TEXT.node(), "%target% has stopped bleeding!");
   return node;
 }
 @Override
 public ConfigurationSection getDefaultConfig() {
   ConfigurationSection node = super.getDefaultConfig();
   node.set("health-per-attack", 1);
   node.set("health-increase", 0);
   node.set(SkillSetting.COOLDOWN.node(), 500);
   node.set(SkillSetting.COOLDOWN_REDUCE.node(), 0);
   node.set("exp-per-heal", 0);
   return node;
 }
  private void saveToBackend(Lot lot) {

    UUID uuid = lot.getUuid();
    String uuidString = uuid.toString();
    ItemStack item = lot.getItem();
    boolean started = lot.isStarted();
    double price = lot.getPrice();
    String lastBidPlayerName = lot.getLastBidPlayerName();
    UUID lastBidPlayerUuid = lot.getLastBidPlayerUuid();
    double lastBidPrice = lot.getLastBidPrice();
    double minimumIncrement = lot.getMinimumIncrement();
    long preserveTimeExpire = lot.getPreserveTimeExpire();
    long auctionDurationExpire = lot.getAuctionDurationExpire();

    String sectionPath = "lots." + uuidString;
    ConfigurationSection singleLotSection =
        data.getYamlConfig().getConfigurationSection(sectionPath);
    if (null == singleLotSection) {
      singleLotSection = data.getYamlConfig().createSection(sectionPath);
    }

    singleLotSection.set("item", item);
    singleLotSection.set("started", started);
    singleLotSection.set("price", price);
    singleLotSection.set("lastBidPlayerName", lastBidPlayerName);
    singleLotSection.set(
        "lastBidPlayerUuid", null == lastBidPlayerUuid ? null : lastBidPlayerUuid.toString());
    singleLotSection.set("lastBidPrice", lastBidPrice);
    singleLotSection.set("minimumIncrement", minimumIncrement);
    singleLotSection.set("preserveTimeExpire", preserveTimeExpire);
    singleLotSection.set("auctionDurationExpire", auctionDurationExpire);
  }
Exemple #22
0
 @Override
 public void save(final ConfigurationSection config, final String path) {
   super.save(config, path);
   final String typeName = type.name();
   getConnection().save(config, path + typeName + ".connection.");
   config.set(path + typeName + ".tableName", tableName);
   config.set(path + typeName + ".cached", cached);
   config.set(path + typeName + ".static", doNotUpdate);
   for (int i = 0; i < defaultColumnNames.length; i++)
     config.set(path + typeName + ".columns." + defaultColumnNames[i], columnNames[i]);
 }
  @Override
  public ConfigurationSection getDefaultConfig() {
    ConfigurationSection node = super.getDefaultConfig();
    node.set(SkillSetting.MAX_DISTANCE.node(), 30);
    node.set(SkillSetting.DAMAGE.node(), 5);
    node.set(SkillSetting.DURATION.node(), 1000);
    node.set(SkillSetting.MANA.node(), 5);
    node.set(SkillSetting.COOLDOWN.node(), 100);

    return node;
  }
  /**
   * Saves a ShippedPackage to a configuration section for YAML parser.
   *
   * @param pack Shipped package to save
   * @param destination The configuration section of config file.
   */
  public static void saveShippedPackage(ShippedPackage pack, ConfigurationSection destination) {
    destination.set("cost", pack.getCost());

    ConfigurationSection location = destination.createSection("location");
    location.set("x", pack.getLocationSent().getX());
    location.set("y", pack.getLocationSent().getY());
    location.set("z", pack.getLocationSent().getZ());
    location.set("world", pack.getLocationSent().getWorld().getName());

    ConfigurationSection contents = destination.createSection("contents");
    // Save every element in the list
    saveItemStackList(Arrays.asList(pack.getContents()), contents);
  }
 public static void savePotion(ItemStack potion, String name) {
   if (potion.getType() != Material.POTION) return;
   PotionMeta meta = (PotionMeta) potion.getItemMeta();
   ConfigurationSection potionYaml = yaml.createSection(name);
   for (int i = 0; i < meta.getCustomEffects().size(); i++) {
     PotionEffect effect = meta.getCustomEffects().get(i);
     ConfigurationSection effectYaml = potionYaml.createSection("effect_" + i);
     effectYaml.set("type", effect.getType().getName().toLowerCase());
     effectYaml.set("duration", effect.getDuration());
     effectYaml.set("amplifier", effect.getAmplifier() + 1);
     effectYaml.set("showParticles", effect.isAmbient());
   }
 }
 public static void saveLocation(
     final ConfigurationSection config,
     final String path,
     final Location location,
     final boolean saveWorld,
     final boolean saveRotation) {
   config.set(path + "x", location.getX());
   config.set(path + "y", location.getY());
   config.set(path + "z", location.getZ());
   if (saveRotation) {
     config.set(path + "yaw", location.getYaw());
     config.set(path + "pitch", location.getPitch());
   }
   if (saveWorld) config.set(path + "world", location.getWorld().getName());
 }
 public void removePlayer(String name) {
   ConfigurationSection section =
       this.getConfiguration().getConfigurationSection("reserved-players");
   section.set(name, null);
   this.save();
   this.reservedPlayers.remove(name);
 }
 public void addPlayer(String name, ReservationType type) {
   ConfigurationSection section =
       this.getConfiguration().getConfigurationSection("reserved-players");
   section.set(name, type.name());
   this.save();
   this.reservedPlayers.put(name, type);
 }
Exemple #29
0
 public void saveTo(ConfigurationSection warConfigSection) {
   for (WarConfig config : WarConfig.values()) {
     if (this.bag.containsKey(config)) {
       warConfigSection.set(config.toString(), this.bag.get(config));
     }
   }
 }
  @Override
  public void apply(final FileConfiguration base) {
    final ConfigurationSection target = this.target(base);
    if (target == null) return;

    target.set(this.key, null);
  }