use of com.magmaguy.elitemobs.treasurechest.TreasureChest in project EliteMobs by MagmaGuy.
the class CustomTreasureChestConfigFields method processConfigFields.
@Override
public void processConfigFields() {
this.isEnabled = processBoolean("isEnabled", isEnabled, false, false);
this.chestMaterial = processEnum("chestType", chestMaterial, Material.CHEST, Material.class, true);
this.facing = processEnum("facing", facing, BlockFace.NORTH, BlockFace.class, true);
this.chestTier = processInt("chestTier", chestTier, 0, true);
this.worldName = processString("location", worldName, null, false);
if (worldName != null)
worldName = worldName.split(",")[0];
this.dropStyle = processEnum("dropStyle", dropStyle, TreasureChest.DropStyle.SINGLE, TreasureChest.DropStyle.class, true);
this.restockTimer = processInt("restockTimer", restockTimer, 0, true);
this.lootList = processStringList("lootList", lootList, new ArrayList<>(), true);
this.customLootTable = new CustomLootTable(this);
this.mimicChance = processDouble("mimicChance", mimicChance, 0, true);
this.mimicCustomBossesList = processStringList("mimicCustomBossesList", mimicCustomBossesList, new ArrayList<>(), true);
this.restockTime = processLong("restockTime", restockTimer, 0, false);
this.restockTimers = processStringList("restockTimers", restockTimers, new ArrayList<>(), false);
this.effects = processStringList("effects", effects, new ArrayList<>(), false);
this.locations = processStringList("locations", locations, new ArrayList<>(), false);
this.location = processLocation("location", location, null, false);
if (location == null && locations.isEmpty())
new InfoMessage("Custom Treasure Chest in file " + filename + " does not have a defined location(s)! It will not spawn.");
else
new TreasureChest(this, location, restockTime);
for (String string : locations) {
String[] strings = string.split(":");
Location location = ConfigurationLocation.serialize(strings[0]);
if (location == null) {
new WarningMessage("Bad location entry in locations for " + filename + " . Entry: " + strings[0]);
continue;
}
long timestamp = 0;
if (strings.length > 1) {
try {
timestamp = Long.parseLong(strings[1]);
} catch (Exception exception) {
new WarningMessage("Bad unix timestamp in locations for " + filename + " . Entry: " + strings[0]);
}
}
new TreasureChest(this, location, timestamp);
}
}
use of com.magmaguy.elitemobs.treasurechest.TreasureChest in project EliteMobs by MagmaGuy.
the class CustomTreasureChestConfigFields method updateTreasureChest.
public TreasureChest updateTreasureChest(Location chestInstanceLocation, long unixTimeStamp) {
int index = -1;
String deserializedLocation = ConfigurationLocation.deserialize(chestInstanceLocation.getBlock().getLocation());
for (String string : locations) if (string.split(":")[0].equals(deserializedLocation)) {
index = locations.indexOf(string);
break;
}
String serializedUpdatedLocation = deserializedLocation + ":" + unixTimeStamp;
TreasureChest treasureChest = null;
if (index != -1) {
locations.set(index, serializedUpdatedLocation);
} else {
locations.add(serializedUpdatedLocation);
treasureChest = new TreasureChest(this, chestInstanceLocation, unixTimeStamp);
}
fileConfiguration.set("locations", locations);
ConfigurationEngine.fileSaverCustomValues(fileConfiguration, file);
return treasureChest;
}
Aggregations