Added Horses to the "Shake" ability.

Witches no longer drop water bottles from Shake, since they no longer drop them in Vanilla.
Changed format of treasures.yml.

**YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
This commit is contained in:
GJ 2013-09-15 01:05:10 -04:00
parent 3bc029a0de
commit 797ac20567
6 changed files with 659 additions and 1722 deletions

View File

@ -8,6 +8,7 @@ Key:
- Removal - Removal
Version 1.4.07-dev Version 1.4.07-dev
+ Added Horses to the "Shake" ability
+ Added ability to summon horses via "Call of the Wild" using apples + Added ability to summon horses via "Call of the Wild" using apples
+ Added XP gain to Taming for horses + Added XP gain to Taming for horses
+ Added new permission nodes to allow more control over Taming and "Call of the Wild" + Added new permission nodes to allow more control over Taming and "Call of the Wild"
@ -32,6 +33,8 @@ Version 1.4.07-dev
= Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing". = Fixed a bug where teleport location was never reset if warmup was set to 0 for "Chimaera Wing".
= Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml = Fixed a bug where the "Dodge" DamageModifier wasn't being read from advanced.yml
= Fixed a bug where squid were not awarding XP. = Fixed a bug where squid were not awarding XP.
! Changed format of treasures.yml. **YOU WILL NEED TO UPDATE YOUR FILE TO THE NEW FORMAT**
! Witches no longer drop water bottles from Shake, since they no longer drop them in Vanilla.
! Changed various values to double in advanced.yml for the sake of consistency. ! Changed various values to double in advanced.yml for the sake of consistency.
! Nerfed Archery damage to eliminate constant one-hit kills. ! Nerfed Archery damage to eliminate constant one-hit kills.
! Changed the way Repair hands out XP, also added config options to control Repair XP ! Changed the way Repair hands out XP, also added config options to control Repair XP

View File

@ -1,16 +1,14 @@
package com.gmail.nossr50.config.treasure; package com.gmail.nossr50.config.treasure;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
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.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData; import org.bukkit.material.Dye;
import org.bukkit.potion.Potion; import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType; import org.bukkit.potion.PotionType;
@ -19,7 +17,6 @@ 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.ShakeTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class TreasureConfig extends ConfigLoader { public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance; private static TreasureConfig instance;
@ -45,6 +42,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>(); public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
@ -75,47 +73,49 @@ public class TreasureConfig extends ConfigLoader {
@Override @Override
protected void loadKeys() { protected void loadKeys() {
Map<String, Treasure> treasures = new HashMap<String, Treasure>(); loadTreaures("Fishing");
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures"); loadTreaures("Excavation");
loadTreaures("Hylian");
for (EntityType entity : EntityType.values()) {
if (entity.isAlive()) {
loadTreaures("Shake." + entity.toString());
}
}
}
private void loadTreaures(String type) {
boolean isFishing = type.equals("Fishing");
boolean isShake = type.contains("Shake");
boolean isExcavation = type.equals("Excavation");
boolean isHylian = type.equals("Hylian");
ConfigurationSection treasureSection = config.getConfigurationSection(type);
if (treasureSection == null) { if (treasureSection == null) {
return; return;
} }
for (String treasureName : treasureSection.getKeys(false)) { for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things! // Validate all the things!
List<String> reason = new ArrayList<String>(); List<String> reason = new ArrayList<String>();
/* /*
* ID, Amount, and Data * Material, Amount, and Data
*/ */
Material material = treasureName.contains("POTION") ? Material.POTION : Material.matchMaterial(treasureName);
int amount = config.getInt(type + "." + treasureName + ".Amount");
int data = config.getInt(type + "." + treasureName + ".Data");
if (!config.contains("Treasures." + treasureName + ".ID")) { if (material == null) {
reason.add("Missing ID"); reason.add("Invalid material: " + treasureName);
}
if (!config.contains("Treasures." + treasureName + ".Amount")) {
reason.add("Missing Amount");
}
if (!config.contains("Treasures." + treasureName + ".Data")) {
reason.add("Missing Data");
}
int id = config.getInt("Treasures." + treasureName + ".ID");
int amount = config.getInt("Treasures." + treasureName + ".Amount");
int data = config.getInt("Treasures." + treasureName + ".Data");
if (Material.getMaterial(id) == null) {
reason.add("Invalid id: " + id);
} }
if (amount < 1) { if (amount < 1) {
reason.add("Invalid amount: " + amount); reason.add("Invalid amount: " + amount);
} }
if (id < 256 && (data > 127 || data < -128)) { if (material != null && material.isBlock() && (data > 127 || data < -128)) {
reason.add("Invalid data: " + data); reason.add("Invalid data: " + data);
} }
@ -123,27 +123,15 @@ public class TreasureConfig extends ConfigLoader {
* XP, Drop Chance, and Drop Level * XP, Drop Chance, and Drop Level
*/ */
if (!config.contains("Treasures." + treasureName + ".XP")) { int xp = config.getInt(type + "." + treasureName + ".XP");
reason.add("Missing XP"); double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
} int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (!config.contains("Treasures." + treasureName + ".Drop_Chance")) {
reason.add("Missing Drop_Chance");
}
if (!config.contains("Treasures." + treasureName + ".Drop_Level")) {
reason.add("Missing Drop_Level");
}
int xp = config.getInt("Treasures." + treasureName + ".XP");
Double dropChance = config.getDouble("Treasures." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt("Treasures." + treasureName + ".Drop_Level");
if (xp < 0) { if (xp < 0) {
reason.add("Invalid xp: " + xp); reason.add("Invalid xp: " + xp);
} }
if (dropChance < 0) { if (dropChance < 0.0D) {
reason.add("Invalid Drop_Chance: " + dropChance); reason.add("Invalid Drop_Chance: " + dropChance);
} }
@ -152,296 +140,176 @@ public class TreasureConfig extends ConfigLoader {
} }
/* /*
* Potions * Specific Types
*/ */
int maxLevel = 0;
if (isFishing) {
maxLevel = config.getInt(type + "." + treasureName + ".Max_Level");
if (maxLevel < -1) {
reason.add("Invalid Max_Level: " + maxLevel);
}
if (maxLevel != -1 && maxLevel < dropLevel) {
reason.add("Max_Level must be -1 or greater than Drop_Level!");
}
}
/*
* Itemstack
*/
ItemStack item = null; ItemStack item = null;
if (config.contains("Treasures." + treasureName + ".Potion_Type")) { if (treasureName.contains("POTION")) {
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type"); String potionType = treasureName.substring(7);
try { try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount); item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
} }
catch (IllegalArgumentException ex) { catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType); reason.add("Invalid Potion_Type: " + potionType);
} }
} }
else { else if (config.contains(type + "." + treasureName + ".Dye_Color")) {
item = (new MaterialData(id, (byte) data)).toItemStack(amount); String color = config.getString("Fishing." + treasureName + ".Dye_Color");
}
/*
* Drops From & Max Level
*/
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a fishing drop.");
}
if (!config.contains("Treasures." + treasureName + ".Max_Level")) {
reason.add("Missing Max_Level");
}
int maxLevel = config.getInt("Treasures." + treasureName + ".Max_Level");
if (noErrorsInConfig(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
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 { try {
mob = EntityType.valueOf(mobType.toUpperCase().trim()); Dye dye = new Dye();
} dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
catch (IllegalArgumentException ex){
reason.add("Invalid Mob: " + mobType);
}
if (noErrorsInConfig(reason)) { item = dye.toItemStack(amount);
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob); }
treasures.put(treasureName, sTreasure); catch (IllegalArgumentException ex) {
reason.add("Invalid Dye_Color: " + color);
} }
} }
else { else {
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel); item = new ItemStack(material, amount, (short) data);
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
eTreasure.setDropsFromDirt();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
eTreasure.setDropsFromGrass();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
eTreasure.setDropsFromSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
eTreasure.setDropsFromGravel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
eTreasure.setDropsFromClay();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
eTreasure.setDropsFromMycel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
eTreasure.setDropsFromSoulSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
eTreasure.setDropsFromSnow();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
hTreasure.setDropsFromBushes();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
hTreasure.setDropsFromFlowers();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
hTreasure.setDropsFromPots();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
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 (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, eTreasure);
}
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, hTreasure);
}
} }
}
List<String> excavationTreasures = config.getStringList("Excavation.Treasure"); if (noErrorsInConfig(reason)) {
List<String> fishingTreasures = config.getStringList("Fishing.Treasure"); if (isFishing) {
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure"); fishingRewards.add(new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel));
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();
if (treasure instanceof FishingTreasure) {
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
continue;
} }
else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
fishingRewards.add((FishingTreasure) treasure); if (type.equals("Shake.BLAZE")) {
} shakeFromBlaze.add(shakeTreasure);
else if (treasure instanceof ShakeTreasure) { }
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) { else if (type.equals("Shake.CAVE_SPIDER")) {
continue; shakeFromCaveSpider.add(shakeTreasure);
}
else if (type.equals("Shake.CHICKEN")) {
shakeFromChicken.add(shakeTreasure);
}
else if (type.equals("Shake.COW")) {
shakeFromCow.add(shakeTreasure);
}
else if (type.equals("Shake.CREEPER")) {
shakeFromCreeper.add(shakeTreasure);
}
else if (type.equals("Shake.ENDERMAN")) {
shakeFromEnderman.add(shakeTreasure);
}
else if (type.equals("Shake.GHAST")) {
shakeFromGhast.add(shakeTreasure);
}
else if (type.equals("Shake.HORSE")) {
shakeFromHorse.add(shakeTreasure);
}
else if (type.equals("Shake.IRON_GOLEM")) {
shakeFromIronGolem.add(shakeTreasure);
}
else if (type.equals("Shake.MAGMA_CUBE")) {
shakeFromMagmaCube.add(shakeTreasure);
}
else if (type.equals("Shake.MUSHROOM_COW")) {
shakeFromMushroomCow.add(shakeTreasure);
}
else if (type.equals("Shake.PIG")) {
shakeFromPig.add(shakeTreasure);
}
else if (type.equals("Shake.PIG_ZOMBIE")) {
shakeFromPigZombie.add(shakeTreasure);
}
else if (type.equals("Shake.SHEEP")) {
shakeFromSheep.add(shakeTreasure);
}
else if (type.equals("Shake.SKELETON")) {
shakeFromSkeleton.add(shakeTreasure);
}
else if (type.equals("Shake.SLIME")) {
shakeFromSlime.add(shakeTreasure);
}
else if (type.equals("Shake.SPIDER")) {
shakeFromSpider.add(shakeTreasure);
}
else if (type.equals("Shake.SNOWMAN")) {
shakeFromSnowman.add(shakeTreasure);
}
else if (type.equals("Shake.SQUID")) {
shakeFromSquid.add(shakeTreasure);
}
else if (type.equals("Shake.WITCH")) {
shakeFromWitch.add(shakeTreasure);
}
else if (type.equals("Shake.ZOMBIE")) {
shakeFromZombie.add(shakeTreasure);
}
} }
else if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
ShakeTreasure e = (ShakeTreasure) treasure; if (dropList.contains("Dirt")) {
switch (e.getMob()) { excavationFromDirt.add(excavationTreasure);
case BLAZE: }
shakeFromBlaze.add(e);
break;
case CAVE_SPIDER: if (dropList.contains("Grass")) {
shakeFromCaveSpider.add(e); excavationFromGrass.add(excavationTreasure);
break; }
case CHICKEN: if (dropList.contains("Sand")) {
shakeFromChicken.add(e); excavationFromSand.add(excavationTreasure);
break; }
case COW: if (dropList.contains("Gravel")) {
shakeFromCow.add(e); excavationFromGravel.add(excavationTreasure);
break; }
case CREEPER: if (dropList.contains("Clay")) {
shakeFromCreeper.add(e); excavationFromClay.add(excavationTreasure);
break; }
case ENDERMAN: if (dropList.contains("Mycelium")) {
shakeFromEnderman.add(e); excavationFromMycel.add(excavationTreasure);
break; }
case GHAST: if (dropList.contains("Soul_Sand")) {
shakeFromGhast.add(e); excavationFromSoulSand.add(excavationTreasure);
break; }
case IRON_GOLEM: if (dropList.contains("Snow")) {
shakeFromIronGolem.add(e); excavationFromSnow.add(excavationTreasure);
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) {
if (hylianTreasures == null || !hylianTreasures.contains(treasureKey)) {
continue;
} }
else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
HylianTreasure hTreasure = (HylianTreasure) treasure; if (dropList.contains("Bushes")) {
hylianFromBushes.add(hylianTreasure);
}
if (hTreasure.getDropsFromBushes()) { if (dropList.contains("Flowers")) {
hylianFromBushes.add(hTreasure); hylianFromFlowers.add(hylianTreasure);
} }
if (hTreasure.getDropsFromFlowers()) { if (dropList.contains("Pots")) {
hylianFromFlowers.add(hTreasure); hylianFromPots.add(hylianTreasure);
} }
if (hTreasure.getDropsFromPots()) {
hylianFromPots.add(hTreasure);
}
}
else if (treasure instanceof ExcavationTreasure) {
if (excavationTreasures == null || !excavationTreasures.contains(treasureKey)) {
continue;
}
ExcavationTreasure eTreasure = (ExcavationTreasure) treasure;
if (eTreasure.getDropsFromDirt()) {
excavationFromDirt.add(eTreasure);
}
if (eTreasure.getDropsFromGrass()) {
excavationFromGrass.add(eTreasure);
}
if (eTreasure.getDropsFromSand()) {
excavationFromSand.add(eTreasure);
}
if (eTreasure.getDropsFromGravel()) {
excavationFromGravel.add(eTreasure);
}
if (eTreasure.getDropsFromClay()) {
excavationFromClay.add(eTreasure);
}
if (eTreasure.getDropsFromMycel()) {
excavationFromMycel.add(eTreasure);
}
if (eTreasure.getDropsFromSoulSand()) {
excavationFromSoulSand.add(eTreasure);
}
if (eTreasure.getDropsFromSnow()) {
excavationFromSnow.add(eTreasure);
} }
} }
} }

View File

@ -3,138 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure { public class ExcavationTreasure extends Treasure {
// dirt | grass | sand | gravel | clay | mycel | soulsand | snow
// 00000001 - dirt 1
// 00000010 - grass 2
// 00000100 - sand 4
// 00001000 - gravel 8
// 00010000 - clay 16
// 00100000 - mycel 32
// 01000000 - soulsand 64
// 10000000 - snow 128
private byte dropsFrom = 0x0;
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel); super(drop, xp, dropChance, dropLevel);
} }
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromDirt() {
return getDropFromMask(1);
}
public boolean getDropsFromGrass() {
return getDropFromMask(2);
}
public boolean getDropsFromSand() {
return getDropFromMask(4);
}
public boolean getDropsFromGravel() {
return getDropFromMask(8);
}
public boolean getDropsFromClay() {
return getDropFromMask(16);
}
public boolean getDropsFromMycel() {
return getDropFromMask(32);
}
public boolean getDropsFromSoulSand() {
return getDropFromMask(64);
}
public boolean getDropsFromSnow() {
return getDropFromMask(128);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromDirt() {
setDropFromMask(1);
}
public void setDropsFromGrass() {
setDropFromMask(2);
}
public void setDropsFromSand() {
setDropFromMask(4);
}
public void setDropsFromGravel() {
setDropFromMask(8);
}
public void setDropsFromClay() {
setDropFromMask(16);
}
public void setDropsFromMycel() {
setDropFromMask(32);
}
public void setDropsFromSoulSand() {
setDropFromMask(64);
}
public void setDropsFromSnow() {
setDropFromMask(128);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromDirt() {
unsetDropFromMask(1);
}
public void unsetDropsFromGrass() {
unsetDropFromMask(2);
}
public void unsetDropsFromSand() {
unsetDropFromMask(4);
}
public void unsetDropsFromGravel() {
unsetDropFromMask(8);
}
public void unsetDropsFromClay() {
unsetDropFromMask(16);
}
public void unsetDropsFromMycel() {
unsetDropFromMask(32);
}
public void unsetDropsFromSoulSand() {
unsetDropFromMask(64);
}
public void unsetDropsFromSnow() {
unsetDropFromMask(128);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
} }

View File

@ -3,73 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class HylianTreasure extends Treasure { public class HylianTreasure extends Treasure {
// bushes | flowers | pots
// 00000001 - bushes 1
// 00000010 - flowers 2
// 00000100 - pots 4
private byte dropsFrom = 0x0;
public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel); super(drop, xp, dropChance, dropLevel);
} }
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromBushes() {
return getDropFromMask(1);
}
public boolean getDropsFromFlowers() {
return getDropFromMask(2);
}
public boolean getDropsFromPots() {
return getDropFromMask(4);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromBushes() {
setDropFromMask(1);
}
public void setDropsFromFlowers() {
setDropFromMask(2);
}
public void setDropsFromPots() {
setDropFromMask(4);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromBushes() {
unsetDropFromMask(1);
}
public void unsetDropsFromFlowers() {
unsetDropFromMask(2);
}
public void unsetDropsFromPots() {
unsetDropFromMask(4);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
} }

View File

@ -1,21 +1,9 @@
package com.gmail.nossr50.datatypes.treasure; package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class ShakeTreasure extends Treasure { public class ShakeTreasure extends Treasure {
private EntityType mob; public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel, EntityType mob) {
super(drop, xp, dropChance, dropLevel); super(drop, xp, dropChance, dropLevel);
this.mob = mob;
}
public EntityType getMob() {
return mob;
}
public void setMob(EntityType mob) {
this.mob = mob;
} }
} }

File diff suppressed because it is too large Load Diff