Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Asintotoo authored Jul 18, 2024
1 parent 21463a9 commit f4c0a17
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.asintoto</groupId>
<artifactId>Basic</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>Basic</name>
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/asintoto/basic/items/ItemCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
Expand Down Expand Up @@ -210,4 +211,30 @@ public void give(Player p) {
public static ItemCreator of(Material m) {
return new ItemCreator(m);
}

public static ItemCreator ofEgg(EntityType type) {
return of(makeMonsterEgg(type));
}

private static Material makeMonsterEgg(EntityType type) {
Material created = Material.SHEEP_SPAWN_EGG;

try {
String name = type.toString().toUpperCase() + "_SPAWN_EGG";

if (type.name().equals("MUSHROOM_COW") || type.name().equals("MOOSHROOM"))
name = "MOOSHROOM_SPAWN_EGG";

created = Material.valueOf(name);

if(created == null) {
return Material.SHEEP_SPAWN_EGG;
}

} catch (Throwable e) {
e.printStackTrace();
}

return created;
}
}

0 comments on commit f4c0a17

Please sign in to comment.