Skip to content

Commit

Permalink
Fix bug of missing dye materials with UNSPECIFIC_META:{meta-type=UNSP…
Browse files Browse the repository at this point in the history
…ECIFIC, Damage=XX}
  • Loading branch information
jyhsu2000 committed Apr 5, 2019
1 parent aea5a81 commit 2af1ae0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/main/java/club/kid7/bannermaker/util/BannerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static public List<ItemStack> getMaterials(ItemStack banner) {
case SQUARE_TOP_LEFT:
case SQUARE_TOP_RIGHT:
case CIRCLE_MIDDLE:
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
break;
case STRIPE_BOTTOM:
case STRIPE_TOP:
Expand All @@ -115,61 +115,61 @@ static public List<ItemStack> getMaterials(ItemStack banner) {
case DIAGONAL_RIGHT:
case DIAGONAL_LEFT_MIRROR:
case DIAGONAL_RIGHT_MIRROR:
materialInventory.addItem(dye.toItemStack(3));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 3));
break;
case STRIPE_SMALL:
case RHOMBUS_MIDDLE:
case GRADIENT:
case GRADIENT_UP:
materialInventory.addItem(dye.toItemStack(4));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 4));
break;
case CROSS:
case STRAIGHT_CROSS:
materialInventory.addItem(dye.toItemStack(5));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 5));
break;
case HALF_VERTICAL:
case HALF_HORIZONTAL:
case HALF_VERTICAL_MIRROR:
case HALF_HORIZONTAL_MIRROR:
materialInventory.addItem(dye.toItemStack(6));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 6));
break;
case BORDER:
materialInventory.addItem(dye.toItemStack(8));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 8));
break;
case CURLY_BORDER:
materialInventory.addItem(new ItemStack(Material.VINE));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
case CREEPER:
materialInventory.addItem(new ItemStack(Material.CREEPER_HEAD));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
case BRICKS:
materialInventory.addItem(new ItemStack(Material.BRICK));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
case SKULL:
materialInventory.addItem(new ItemStack(Material.WITHER_SKELETON_SKULL));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
case FLOWER:
materialInventory.addItem(new ItemStack(Material.OXEYE_DAISY));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
case MOJANG:
materialInventory.addItem(new ItemStack(Material.ENCHANTED_GOLDEN_APPLE));
if (!pattern.getColor().equals(DyeColor.BLACK)) {
materialInventory.addItem(dye.toItemStack(1));
materialInventory.addItem(DyeColorUtil.toDyeItemStack(dye.getColor(), 1));
}
break;
}
Expand Down Expand Up @@ -432,7 +432,7 @@ static public HashMap<Integer, ItemStack> getPatternRecipe(final ItemStack banne
//所需染料
Dye dye = new Dye();
dye.setColor(pattern.getColor());
ItemStack dyeItem = dye.toItemStack(1);
ItemStack dyeItem = DyeColorUtil.toDyeItemStack(dye.getColor(), 1);
//旗幟位置
int bannerPosition = 4;
//染料位置
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/club/kid7/bannermaker/util/DyeColorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.collect.HashBiMap;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

public class DyeColorUtil {
final private static BiMap<DyeColor, Integer> integerMap = HashBiMap.create();
Expand Down Expand Up @@ -116,6 +117,10 @@ public static Material toDyeMaterial(DyeColor dyeColor) {
return dyeMaterialMap.get(dyeColor);
}

public static ItemStack toDyeItemStack(DyeColor dyeColor, int amount) {
return new ItemStack(toDyeMaterial(dyeColor), amount);
}

public static Material toWoolMaterial(DyeColor dyeColor) {
return woolMaterialMap.get(dyeColor);
}
Expand Down

0 comments on commit 2af1ae0

Please sign in to comment.