|
@@ -9,13 +9,17 @@ import java.util.Set;
|
|
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
import org.bukkit.configuration.ConfigurationSection;
|
|
|
|
+import org.bukkit.entity.EntityType;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.bukkit.material.MaterialData;
|
|
import org.bukkit.material.MaterialData;
|
|
|
|
+import org.bukkit.potion.Potion;
|
|
|
|
+import org.bukkit.potion.PotionType;
|
|
|
|
|
|
import com.gmail.nossr50.config.ConfigLoader;
|
|
import com.gmail.nossr50.config.ConfigLoader;
|
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
|
|
|
+import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
|
import com.gmail.nossr50.datatypes.treasure.Treasure;
|
|
|
|
|
|
public class TreasureConfig extends ConfigLoader {
|
|
public class TreasureConfig extends ConfigLoader {
|
|
@@ -33,6 +37,27 @@ public class TreasureConfig extends ConfigLoader {
|
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
|
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
|
|
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
|
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
|
|
|
|
|
|
|
|
+ public List<ShakeTreasure> shakeFromBlaze = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromCaveSpider = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSpider = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromChicken = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromCow = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromPig = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromPigZombie = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSheep = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSkeleton = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSlime = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSnowman = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
|
|
|
+ public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
|
|
|
+
|
|
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
|
public List<FishingTreasure> fishingRewards = new ArrayList<FishingTreasure>();
|
|
|
|
|
|
private TreasureConfig() {
|
|
private TreasureConfig() {
|
|
@@ -129,14 +154,31 @@ public class TreasureConfig extends ConfigLoader {
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Drops From & Max Level
|
|
|
|
|
|
+ * Potions
|
|
*/
|
|
*/
|
|
|
|
|
|
- ItemStack item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
|
|
|
|
|
+ ItemStack item = null;
|
|
|
|
+
|
|
|
|
+ if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
|
|
|
|
+ String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
|
|
|
|
+ try {
|
|
|
|
+ item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
|
|
|
|
+ }
|
|
|
|
+ catch (IllegalArgumentException ex) {
|
|
|
|
+ reason.add("Invalid Potion_Type: " + potionType);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ item = (new MaterialData(id, (byte) data)).toItemStack(amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Drops From & Max Level
|
|
|
|
+ */
|
|
|
|
|
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
|
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
|
- reason.add("Fishing drops cannot also be excavation drops");
|
|
|
|
|
|
+ reason.add("This can only be a fishing drop.");
|
|
}
|
|
}
|
|
|
|
|
|
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
|
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
|
|
@@ -150,6 +192,30 @@ public class TreasureConfig extends ConfigLoader {
|
|
treasures.put(treasureName, fTreasure);
|
|
treasures.put(treasureName, fTreasure);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ else if (config.getBoolean("Treasures." + treasureName + "Drops_From.Shake", false)) {
|
|
|
|
+ if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
|
|
|
|
+ reason.add("This can only be a shake drop.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!config.contains("Treasures." + treasureName + ".Mob")) {
|
|
|
|
+ reason.add("Missing Mob");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String mobType = config.getString("Treasures." + treasureName + ".Mob");
|
|
|
|
+ EntityType mob = null;
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ mob = EntityType.valueOf(mobType.toUpperCase().trim());
|
|
|
|
+ }
|
|
|
|
+ catch (IllegalArgumentException ex){
|
|
|
|
+ reason.add("Invalid Mob: " + mobType);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (noErrorsInTreasure(reason)) {
|
|
|
|
+ ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
|
|
|
|
+ treasures.put(treasureName, sTreasure);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
else {
|
|
else {
|
|
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
|
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
|
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
|
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
|
@@ -195,7 +261,11 @@ public class TreasureConfig extends ConfigLoader {
|
|
}
|
|
}
|
|
|
|
|
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
|
|
- reason.add("Excavation drops cannot also be fishing drops");
|
|
|
|
|
|
+ reason.add("This cannot also be a fishing drop.");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
|
|
|
|
+ reason.add("This cannot also be a shake drop.");
|
|
}
|
|
}
|
|
|
|
|
|
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
|
if (noErrorsInTreasure(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
|
|
@@ -210,6 +280,7 @@ public class TreasureConfig extends ConfigLoader {
|
|
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
|
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
|
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
|
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
|
|
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
|
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
|
|
|
|
+ List<String> shakeTreasures = config.getStringList("Shake.Treasure");
|
|
|
|
|
|
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
|
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
|
|
String treasureKey = nextEntry.getKey();
|
|
String treasureKey = nextEntry.getKey();
|
|
@@ -222,6 +293,97 @@ public class TreasureConfig extends ConfigLoader {
|
|
|
|
|
|
fishingRewards.add((FishingTreasure) treasure);
|
|
fishingRewards.add((FishingTreasure) treasure);
|
|
}
|
|
}
|
|
|
|
+ else if (treasure instanceof ShakeTreasure) {
|
|
|
|
+ if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ShakeTreasure e = (ShakeTreasure) treasure;
|
|
|
|
+ switch (e.getMob()) {
|
|
|
|
+ case BLAZE:
|
|
|
|
+ shakeFromBlaze.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case CAVE_SPIDER:
|
|
|
|
+ shakeFromCaveSpider.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case CHICKEN:
|
|
|
|
+ shakeFromChicken.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case COW:
|
|
|
|
+ shakeFromCow.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case CREEPER:
|
|
|
|
+ shakeFromCreeper.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case ENDERMAN:
|
|
|
|
+ shakeFromEnderman.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case GHAST:
|
|
|
|
+ shakeFromGhast.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case IRON_GOLEM:
|
|
|
|
+ shakeFromIronGolem.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case MAGMA_CUBE:
|
|
|
|
+ shakeFromMagmaCube.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case MUSHROOM_COW:
|
|
|
|
+ shakeFromMushroomCow.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case PIG:
|
|
|
|
+ shakeFromPig.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case PIG_ZOMBIE:
|
|
|
|
+ shakeFromPigZombie.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SHEEP:
|
|
|
|
+ shakeFromSheep.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SKELETON:
|
|
|
|
+ shakeFromSkeleton.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SLIME:
|
|
|
|
+ shakeFromSlime.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SPIDER:
|
|
|
|
+ shakeFromSpider.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SNOWMAN:
|
|
|
|
+ shakeFromSnowman.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case SQUID:
|
|
|
|
+ shakeFromSquid.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case WITCH:
|
|
|
|
+ shakeFromWitch.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case ZOMBIE:
|
|
|
|
+ shakeFromZombie.add(e);
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
else if (treasure instanceof HylianTreasure) {
|
|
else if (treasure instanceof HylianTreasure) {
|
|
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
|
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
|
|
continue;
|
|
continue;
|