mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
These should definently not be hard coded in the future... but allow rabbits and guardians to be shaken down
This commit is contained in:
parent
70de0ba00b
commit
315b713005
@ -28,6 +28,7 @@ import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
|
|||||||
import com.gmail.nossr50.util.EnchantmentUtils;
|
import com.gmail.nossr50.util.EnchantmentUtils;
|
||||||
|
|
||||||
public class TreasureConfig extends ConfigLoader {
|
public class TreasureConfig extends ConfigLoader {
|
||||||
|
|
||||||
private static TreasureConfig instance;
|
private static TreasureConfig instance;
|
||||||
|
|
||||||
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
|
||||||
@ -67,6 +68,9 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
|
||||||
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
|
||||||
|
public List<ShakeTreasure> shakeFromRabbit = new ArrayList<ShakeTreasure>();
|
||||||
|
public List<ShakeTreasure> shakeFromElderGuardian = new ArrayList<ShakeTreasure>();
|
||||||
|
public List<ShakeTreasure> shakeFromGuardian = new ArrayList<ShakeTreasure>();
|
||||||
|
|
||||||
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
|
||||||
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||||
@ -174,13 +178,11 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
|
|
||||||
if (materialName.contains("INK_SACK")) {
|
if (materialName.contains("INK_SACK")) {
|
||||||
material = Material.INK_SACK;
|
material = Material.INK_SACK;
|
||||||
}
|
} else if (materialName.contains("INVENTORY")) {
|
||||||
else if (materialName.contains("INVENTORY")) {
|
|
||||||
// Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure
|
// Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure
|
||||||
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
material = Material.matchMaterial(materialName);
|
material = Material.matchMaterial(materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +250,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
PotionType potionType = null;
|
PotionType potionType = null;
|
||||||
try {
|
try {
|
||||||
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||||
}
|
} catch (IllegalArgumentException ex) {
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
|
||||||
}
|
}
|
||||||
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
||||||
@ -269,8 +270,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
} else if (materialName.contains("INK_SACK")) {
|
||||||
else if (materialName.contains("INK_SACK")) {
|
|
||||||
String color = materialName.substring(9);
|
String color = materialName.substring(9);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -294,12 +294,10 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
itemMeta.setLore(lore);
|
itemMeta.setLore(lore);
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
}
|
}
|
||||||
}
|
} catch (IllegalArgumentException ex) {
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
reason.add("Invalid Dye_Color: " + color);
|
reason.add("Invalid Dye_Color: " + color);
|
||||||
}
|
}
|
||||||
}
|
} else if (material != null) {
|
||||||
else if (material != null) {
|
|
||||||
item = new ItemStack(material, amount, data);
|
item = new ItemStack(material, amount, data);
|
||||||
|
|
||||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||||
@ -322,78 +320,61 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
if (noErrorsInConfig(reason)) {
|
if (noErrorsInConfig(reason)) {
|
||||||
if (isFishing) {
|
if (isFishing) {
|
||||||
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||||
}
|
} else if (isShake) {
|
||||||
else if (isShake) {
|
|
||||||
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||||
|
|
||||||
if (type.equals("Shake.BLAZE")) {
|
if (type.equals("Shake.BLAZE")) {
|
||||||
shakeFromBlaze.add(shakeTreasure);
|
shakeFromBlaze.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.CAVE_SPIDER")) {
|
||||||
else if (type.equals("Shake.CAVE_SPIDER")) {
|
|
||||||
shakeFromCaveSpider.add(shakeTreasure);
|
shakeFromCaveSpider.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.CHICKEN")) {
|
||||||
else if (type.equals("Shake.CHICKEN")) {
|
|
||||||
shakeFromChicken.add(shakeTreasure);
|
shakeFromChicken.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.COW")) {
|
||||||
else if (type.equals("Shake.COW")) {
|
|
||||||
shakeFromCow.add(shakeTreasure);
|
shakeFromCow.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.CREEPER")) {
|
||||||
else if (type.equals("Shake.CREEPER")) {
|
|
||||||
shakeFromCreeper.add(shakeTreasure);
|
shakeFromCreeper.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.ENDERMAN")) {
|
||||||
else if (type.equals("Shake.ENDERMAN")) {
|
|
||||||
shakeFromEnderman.add(shakeTreasure);
|
shakeFromEnderman.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.GHAST")) {
|
||||||
else if (type.equals("Shake.GHAST")) {
|
|
||||||
shakeFromGhast.add(shakeTreasure);
|
shakeFromGhast.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.HORSE")) {
|
||||||
else if (type.equals("Shake.HORSE")) {
|
|
||||||
shakeFromHorse.add(shakeTreasure);
|
shakeFromHorse.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.IRON_GOLEM")) {
|
||||||
else if (type.equals("Shake.IRON_GOLEM")) {
|
|
||||||
shakeFromIronGolem.add(shakeTreasure);
|
shakeFromIronGolem.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.MAGMA_CUBE")) {
|
||||||
else if (type.equals("Shake.MAGMA_CUBE")) {
|
|
||||||
shakeFromMagmaCube.add(shakeTreasure);
|
shakeFromMagmaCube.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.MUSHROOM_COW")) {
|
||||||
else if (type.equals("Shake.MUSHROOM_COW")) {
|
|
||||||
shakeFromMushroomCow.add(shakeTreasure);
|
shakeFromMushroomCow.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.PIG")) {
|
||||||
else if (type.equals("Shake.PIG")) {
|
|
||||||
shakeFromPig.add(shakeTreasure);
|
shakeFromPig.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||||
else if (type.equals("Shake.PIG_ZOMBIE")) {
|
|
||||||
shakeFromPigZombie.add(shakeTreasure);
|
shakeFromPigZombie.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.PLAYER")) {
|
||||||
else if (type.equals("Shake.PLAYER")) {
|
|
||||||
shakeFromPlayer.add(shakeTreasure);
|
shakeFromPlayer.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SHEEP")) {
|
||||||
else if (type.equals("Shake.SHEEP")) {
|
|
||||||
shakeFromSheep.add(shakeTreasure);
|
shakeFromSheep.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SKELETON")) {
|
||||||
else if (type.equals("Shake.SKELETON")) {
|
|
||||||
shakeFromSkeleton.add(shakeTreasure);
|
shakeFromSkeleton.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SLIME")) {
|
||||||
else if (type.equals("Shake.SLIME")) {
|
|
||||||
shakeFromSlime.add(shakeTreasure);
|
shakeFromSlime.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SPIDER")) {
|
||||||
else if (type.equals("Shake.SPIDER")) {
|
|
||||||
shakeFromSpider.add(shakeTreasure);
|
shakeFromSpider.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SNOWMAN")) {
|
||||||
else if (type.equals("Shake.SNOWMAN")) {
|
|
||||||
shakeFromSnowman.add(shakeTreasure);
|
shakeFromSnowman.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.SQUID")) {
|
||||||
else if (type.equals("Shake.SQUID")) {
|
|
||||||
shakeFromSquid.add(shakeTreasure);
|
shakeFromSquid.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.WITCH")) {
|
||||||
else if (type.equals("Shake.WITCH")) {
|
|
||||||
shakeFromWitch.add(shakeTreasure);
|
shakeFromWitch.add(shakeTreasure);
|
||||||
}
|
} else if (type.equals("Shake.ZOMBIE")) {
|
||||||
else if (type.equals("Shake.ZOMBIE")) {
|
|
||||||
shakeFromZombie.add(shakeTreasure);
|
shakeFromZombie.add(shakeTreasure);
|
||||||
|
} else if (type.equals("Shake.RABBIT")) {
|
||||||
|
shakeFromRabbit.add(shakeTreasure);
|
||||||
|
} else if (type.equals("Shake.GUARDIAN")) {
|
||||||
|
shakeFromGuardian.add(shakeTreasure);
|
||||||
|
} else if (type.equals("Shake.ELDER_GUARDIAN")) {
|
||||||
|
shakeFromElderGuardian.add(shakeTreasure);
|
||||||
}
|
}
|
||||||
}
|
} else if (isExcavation) {
|
||||||
else if (isExcavation) {
|
|
||||||
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
|
||||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
@ -436,8 +417,7 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
if (dropList.contains("Podzol")) {
|
if (dropList.contains("Podzol")) {
|
||||||
excavationFromPodzol.add(excavationTreasure);
|
excavationFromPodzol.add(excavationTreasure);
|
||||||
}
|
}
|
||||||
}
|
} else if (isHylian) {
|
||||||
else if (isHylian) {
|
|
||||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||||
|
|
||||||
@ -455,6 +435,9 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Fallthrough if not specified
|
||||||
|
if (shakeFromElderGuardian.isEmpty())
|
||||||
|
shakeFromElderGuardian = shakeFromGuardian;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEnchantments() {
|
private void loadEnchantments() {
|
||||||
@ -487,11 +470,27 @@ public class TreasureConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getInventoryStealEnabled() { return config.contains("Shake.PLAYER.INVENTORY"); }
|
public boolean getInventoryStealEnabled() {
|
||||||
public boolean getInventoryStealStacks() { return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks"); }
|
return config.contains("Shake.PLAYER.INVENTORY");
|
||||||
public double getInventoryStealDropChance() { return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance"); }
|
}
|
||||||
public int getInventoryStealDropLevel() { return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level"); }
|
|
||||||
|
|
||||||
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
public boolean getInventoryStealStacks() {
|
||||||
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
|
return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getInventoryStealDropChance() {
|
||||||
|
return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance");
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInventoryStealDropLevel() {
|
||||||
|
return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level");
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getItemDropRate(int tier, Rarity rarity) {
|
||||||
|
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getEnchantmentDropRate(int tier, Rarity rarity) {
|
||||||
|
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.util.Set;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -134,6 +135,14 @@ public final class Fishing {
|
|||||||
case ZOMBIE:
|
case ZOMBIE:
|
||||||
return TreasureConfig.getInstance().shakeFromZombie;
|
return TreasureConfig.getInstance().shakeFromZombie;
|
||||||
|
|
||||||
|
case RABBIT:
|
||||||
|
return TreasureConfig.getInstance().shakeFromRabbit;
|
||||||
|
|
||||||
|
case GUARDIAN:
|
||||||
|
if (((Guardian) target).isElder())
|
||||||
|
return TreasureConfig.getInstance().shakeFromElderGuardian;
|
||||||
|
return TreasureConfig.getInstance().shakeFromGuardian;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user