Merge remote-tracking branch 'refs/remotes/mcMMO-Dev/master'

This commit is contained in:
Dor 2016-03-12 08:03:30 +02:00
commit 4f9a463b9d
3 changed files with 38 additions and 21 deletions

View File

@ -12,8 +12,10 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.material.Dye;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.ConfigLoader;
@ -170,10 +172,7 @@ public class TreasureConfig extends ConfigLoader {
*/
Material material;
if (materialName.contains("POTION")) {
material = Material.POTION;
}
else if (materialName.contains("INK_SACK")) {
if (materialName.contains("INK_SACK")) {
material = Material.INK_SACK;
}
else if (materialName.contains("INVENTORY")) {
@ -239,29 +238,36 @@ public class TreasureConfig extends ConfigLoader {
ItemStack item = null;
if (materialName.contains("POTION")) {
String potionType = materialName.substring(7);
try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for Treasures.yml has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
PotionType potionType = null;
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
item.setItemMeta(itemMeta);
}
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
List<String> lore = new ArrayList<String>();
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
}
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType);
item.setItemMeta(itemMeta);
}
}
else if (materialName.contains("INK_SACK")) {

View File

@ -31,6 +31,9 @@ public class EnchantmentUtils {
enchants.put("FLAME", Enchantment.ARROW_FIRE);
enchants.put("KNOCKBACK", Enchantment.KNOCKBACK);
enchants.put("THORNS", Enchantment.THORNS);
enchants.put("MENDING", Enchantment.MENDING);
enchants.put("DEPTH_STRIDER", Enchantment.DEPTH_STRIDER);
enchants.put("FROST_WALKER", Enchantment.FROST_WALKER);
}
/**
@ -45,6 +48,6 @@ public class EnchantmentUtils {
return enchants.get(enchantmentName);
}
return null;
return Enchantment.getByName(enchantmentName);
}
}

View File

@ -651,7 +651,9 @@ Shake:
XP: 0
Drop_Chance: 1.0
Drop_Level: 0
POTION_POISON:
POTION|0|POISON:
PotionData:
PotionType: POISON
Amount: 1
XP: 0
Drop_Chance: 1.0
@ -861,17 +863,23 @@ Shake:
Drop_Chance: 100.0
Drop_Level: 0
WITCH:
POTION_INSTANT_HEAL:
SPLASH_POTION|0|INSTANT_HEAL:
PotionData:
PotionType: INSTANT_HEAL
Amount: 1
XP: 0
Drop_Chance: 1.0
Drop_Level: 0
POTION_FIRE_RESISTANCE:
SPLASH_POTION|0|FIRE_RESISTANCE:
PotionData:
PotionType: FIRE_RESISTANCE
Amount: 1
XP: 0
Drop_Chance: 1.0
Drop_Level: 0
POTION_SPEED:
SPLASH_POTION|0|SPEED:
PotionData:
PotionType: SPEED
Amount: 1
XP: 0
Drop_Chance: 1.0