mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26: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;
|
||||
|
||||
public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
private static TreasureConfig instance;
|
||||
|
||||
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> shakeFromWitch = 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<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
|
||||
@ -174,13 +178,11 @@ public class TreasureConfig extends ConfigLoader {
|
||||
|
||||
if (materialName.contains("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
|
||||
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
material = Material.matchMaterial(materialName);
|
||||
}
|
||||
|
||||
@ -248,8 +250,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
PotionType potionType = null;
|
||||
try {
|
||||
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"));
|
||||
}
|
||||
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
|
||||
@ -269,8 +270,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
else if (materialName.contains("INK_SACK")) {
|
||||
} else if (materialName.contains("INK_SACK")) {
|
||||
String color = materialName.substring(9);
|
||||
|
||||
try {
|
||||
@ -294,12 +294,10 @@ public class TreasureConfig extends ConfigLoader {
|
||||
itemMeta.setLore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
} catch (IllegalArgumentException ex) {
|
||||
reason.add("Invalid Dye_Color: " + color);
|
||||
}
|
||||
}
|
||||
else if (material != null) {
|
||||
} else if (material != null) {
|
||||
item = new ItemStack(material, amount, data);
|
||||
|
||||
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
|
||||
@ -322,78 +320,61 @@ public class TreasureConfig extends ConfigLoader {
|
||||
if (noErrorsInConfig(reason)) {
|
||||
if (isFishing) {
|
||||
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
|
||||
}
|
||||
else if (isShake) {
|
||||
} else if (isShake) {
|
||||
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
|
||||
|
||||
if (type.equals("Shake.BLAZE")) {
|
||||
shakeFromBlaze.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CAVE_SPIDER")) {
|
||||
} else if (type.equals("Shake.CAVE_SPIDER")) {
|
||||
shakeFromCaveSpider.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CHICKEN")) {
|
||||
} else if (type.equals("Shake.CHICKEN")) {
|
||||
shakeFromChicken.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.COW")) {
|
||||
} else if (type.equals("Shake.COW")) {
|
||||
shakeFromCow.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.CREEPER")) {
|
||||
} else if (type.equals("Shake.CREEPER")) {
|
||||
shakeFromCreeper.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.ENDERMAN")) {
|
||||
} else if (type.equals("Shake.ENDERMAN")) {
|
||||
shakeFromEnderman.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.GHAST")) {
|
||||
} else if (type.equals("Shake.GHAST")) {
|
||||
shakeFromGhast.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.HORSE")) {
|
||||
} else if (type.equals("Shake.HORSE")) {
|
||||
shakeFromHorse.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.IRON_GOLEM")) {
|
||||
} else if (type.equals("Shake.IRON_GOLEM")) {
|
||||
shakeFromIronGolem.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.MAGMA_CUBE")) {
|
||||
} else if (type.equals("Shake.MAGMA_CUBE")) {
|
||||
shakeFromMagmaCube.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.MUSHROOM_COW")) {
|
||||
} else if (type.equals("Shake.MUSHROOM_COW")) {
|
||||
shakeFromMushroomCow.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PIG")) {
|
||||
} else if (type.equals("Shake.PIG")) {
|
||||
shakeFromPig.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||
} else if (type.equals("Shake.PIG_ZOMBIE")) {
|
||||
shakeFromPigZombie.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.PLAYER")) {
|
||||
} else if (type.equals("Shake.PLAYER")) {
|
||||
shakeFromPlayer.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SHEEP")) {
|
||||
} else if (type.equals("Shake.SHEEP")) {
|
||||
shakeFromSheep.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SKELETON")) {
|
||||
} else if (type.equals("Shake.SKELETON")) {
|
||||
shakeFromSkeleton.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SLIME")) {
|
||||
} else if (type.equals("Shake.SLIME")) {
|
||||
shakeFromSlime.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SPIDER")) {
|
||||
} else if (type.equals("Shake.SPIDER")) {
|
||||
shakeFromSpider.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SNOWMAN")) {
|
||||
} else if (type.equals("Shake.SNOWMAN")) {
|
||||
shakeFromSnowman.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.SQUID")) {
|
||||
} else if (type.equals("Shake.SQUID")) {
|
||||
shakeFromSquid.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.WITCH")) {
|
||||
} else if (type.equals("Shake.WITCH")) {
|
||||
shakeFromWitch.add(shakeTreasure);
|
||||
}
|
||||
else if (type.equals("Shake.ZOMBIE")) {
|
||||
} else if (type.equals("Shake.ZOMBIE")) {
|
||||
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);
|
||||
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
|
||||
|
||||
@ -436,8 +417,7 @@ public class TreasureConfig extends ConfigLoader {
|
||||
if (dropList.contains("Podzol")) {
|
||||
excavationFromPodzol.add(excavationTreasure);
|
||||
}
|
||||
}
|
||||
else if (isHylian) {
|
||||
} else if (isHylian) {
|
||||
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
|
||||
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() {
|
||||
@ -487,11 +470,27 @@ public class TreasureConfig extends ConfigLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getInventoryStealEnabled() { return config.contains("Shake.PLAYER.INVENTORY"); }
|
||||
public boolean getInventoryStealStacks() { 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 boolean getInventoryStealEnabled() {
|
||||
return config.contains("Shake.PLAYER.INVENTORY");
|
||||
}
|
||||
|
||||
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()); }
|
||||
public boolean getInventoryStealStacks() {
|
||||
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.block.Biome;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -134,6 +135,14 @@ public final class Fishing {
|
||||
case ZOMBIE:
|
||||
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:
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user