mirror of
https://github.com/Auxilor/EcoMobs.git
synced 2025-12-21 07:59:28 +00:00
Added spawn eggs
This commit is contained in:
@@ -4,6 +4,9 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import com.willfp.eco.core.EcoPlugin;
|
import com.willfp.eco.core.EcoPlugin;
|
||||||
import com.willfp.eco.core.PluginDependent;
|
import com.willfp.eco.core.PluginDependent;
|
||||||
import com.willfp.eco.core.config.interfaces.Config;
|
import com.willfp.eco.core.config.interfaces.Config;
|
||||||
|
import com.willfp.eco.core.items.builder.ItemBuilder;
|
||||||
|
import com.willfp.eco.core.items.builder.ItemStackBuilder;
|
||||||
|
import com.willfp.eco.core.recipe.Recipes;
|
||||||
import com.willfp.eco.core.tuples.Pair;
|
import com.willfp.eco.core.tuples.Pair;
|
||||||
import com.willfp.eco.util.StringUtils;
|
import com.willfp.eco.util.StringUtils;
|
||||||
import com.willfp.ecobosses.bosses.effects.Effect;
|
import com.willfp.ecobosses.bosses.effects.Effect;
|
||||||
@@ -27,9 +30,12 @@ import org.bukkit.boss.BarColor;
|
|||||||
import org.bukkit.boss.BarStyle;
|
import org.bukkit.boss.BarStyle;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -263,6 +269,12 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
@Getter
|
@Getter
|
||||||
private final List<Location> autoSpawnLocations;
|
private final List<Location> autoSpawnLocations;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The boss spawn egg.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final ItemStack spawnEgg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Boss.
|
* Create a new Boss.
|
||||||
*
|
*
|
||||||
@@ -481,6 +493,34 @@ public class EcoBoss extends PluginDependent<EcoPlugin> {
|
|||||||
autoSpawnLocations.add(new Location(world, x, y, z));
|
autoSpawnLocations.add(new Location(world, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Spawn egg
|
||||||
|
if (this.getConfig().getBool("spawn-egg.enabled")) {
|
||||||
|
Material material = Material.getMaterial(this.getConfig().getString("spawn-egg.material").toUpperCase());
|
||||||
|
assert material != null;
|
||||||
|
ItemBuilder builder = new ItemStackBuilder(material)
|
||||||
|
.setDisplayName(this.getConfig().getString("spawn-egg.name"))
|
||||||
|
.addLoreLines(this.getConfig().getStrings("spawn-egg.lore"))
|
||||||
|
.writeMetaKey(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING, this.getName());
|
||||||
|
|
||||||
|
if (this.getConfig().getBool("spawn-egg.glow")) {
|
||||||
|
builder.addEnchantment(Enchantment.DURABILITY, 1)
|
||||||
|
.addItemFlag(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.spawnEgg = builder.build();
|
||||||
|
|
||||||
|
if (this.getConfig().getBool("spawn-egg.craftable")) {
|
||||||
|
Recipes.createAndRegisterRecipe(
|
||||||
|
this.getPlugin(),
|
||||||
|
"spawn_egg_" + this.getName(),
|
||||||
|
this.getSpawnEgg(),
|
||||||
|
this.getConfig().getStrings("spawn-egg.recipe", false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.spawnEgg = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.getConfig().getBool("enabled")) {
|
if (this.getConfig().getBool("enabled")) {
|
||||||
EcoBosses.addBoss(this);
|
EcoBosses.addBoss(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,13 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class SpawnListeners extends PluginDependent<EcoPlugin> implements Listener {
|
public class SpawnListeners extends PluginDependent<EcoPlugin> implements Listener {
|
||||||
@@ -65,4 +71,44 @@ public class SpawnListeners extends PluginDependent<EcoPlugin> implements Listen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void spawnEgg(@NotNull final PlayerInteractEvent event) {
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = event.getItem();
|
||||||
|
if (item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistentDataContainer container = meta.getPersistentDataContainer();
|
||||||
|
if (!container.has(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String id = container.get(this.getPlugin().getNamespacedKeyFactory().create("spawn_egg"), PersistentDataType.STRING);
|
||||||
|
if (id == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
EcoBoss boss = EcoBosses.getByName(id);
|
||||||
|
|
||||||
|
item.setType(Material.AIR);
|
||||||
|
item.setAmount(0);
|
||||||
|
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (block == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boss.spawn(block.getLocation());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,29 @@ time-to-live: 120 # Time to live before auto despawn, in seconds. Set to -1 to d
|
|||||||
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
||||||
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
||||||
|
|
||||||
spawn-totem:
|
spawn-egg:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
material: wolf_spawn_egg
|
||||||
|
name: "&fAlpha Wolf Spawn Egg"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&8&oPlace on the ground to"
|
||||||
|
- "&8&osummon an &fAlpha Wolf"
|
||||||
|
glow: true
|
||||||
|
craftable: true
|
||||||
|
recipe:
|
||||||
|
- bone_block
|
||||||
|
- netherite_block
|
||||||
|
- bone_block
|
||||||
|
- bone
|
||||||
|
- ecoitems:boss_core ? nether_star
|
||||||
|
- bone
|
||||||
|
- bone_block
|
||||||
|
- netherite_block
|
||||||
|
- bone_block
|
||||||
|
|
||||||
|
spawn-totem:
|
||||||
|
enabled: false
|
||||||
top: beacon
|
top: beacon
|
||||||
middle: bone_block
|
middle: bone_block
|
||||||
bottom: bone_block
|
bottom: bone_block
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
name: "&9Dark Guardian &7| &c%health%♥ &7| &e%time%" # Display name
|
name: "&9Dark Guardian &7| &c%health%♥ &7| &e%time%" # Display name
|
||||||
base-mob: enderman
|
base-mob: ravager
|
||||||
|
|
||||||
bossbar:
|
bossbar:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -17,8 +17,29 @@ time-to-live: 120 # Time to live before auto despawn, in seconds. Set to -1 to d
|
|||||||
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
||||||
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
||||||
|
|
||||||
spawn-totem:
|
spawn-egg:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
material: ravager_spawn_egg
|
||||||
|
name: "&9Dark Guardian&f Spawn Egg"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&8&oPlace on the ground to"
|
||||||
|
- "&8&osummon a &9Dark Guardian"
|
||||||
|
glow: true
|
||||||
|
craftable: true
|
||||||
|
recipe:
|
||||||
|
- emerald
|
||||||
|
- netherite_block
|
||||||
|
- emerald
|
||||||
|
- air
|
||||||
|
- ecoitems:boss_core ? nether_star
|
||||||
|
- air
|
||||||
|
- emerald
|
||||||
|
- netherite_block
|
||||||
|
- emerald
|
||||||
|
|
||||||
|
spawn-totem:
|
||||||
|
enabled: false
|
||||||
top: carved_pumpkin
|
top: carved_pumpkin
|
||||||
middle: beacon
|
middle: beacon
|
||||||
bottom: diamond_block
|
bottom: diamond_block
|
||||||
|
|||||||
@@ -17,8 +17,29 @@ time-to-live: 120 # Time to live before auto despawn, in seconds. Set to -1 to d
|
|||||||
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
||||||
auto-spawn-locations: [] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
auto-spawn-locations: [] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
||||||
|
|
||||||
spawn-totem:
|
spawn-egg:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
material: evoker_spawn_egg
|
||||||
|
name: "&8Steel Golem&f Spawn Egg"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&8&oPlace on the ground to"
|
||||||
|
- "&8&osummon a &8Steel Golem"
|
||||||
|
glow: true
|
||||||
|
craftable: true
|
||||||
|
recipe:
|
||||||
|
- iron_block
|
||||||
|
- netherite_block
|
||||||
|
- iron_block
|
||||||
|
- air
|
||||||
|
- ecoitems:boss_core ? nether_star
|
||||||
|
- air
|
||||||
|
- iron_block
|
||||||
|
- netherite_block
|
||||||
|
- iron_block
|
||||||
|
|
||||||
|
spawn-totem:
|
||||||
|
enabled: false
|
||||||
top: netherite_block
|
top: netherite_block
|
||||||
middle: iron_block
|
middle: iron_block
|
||||||
bottom: magma_block
|
bottom: magma_block
|
||||||
|
|||||||
@@ -17,8 +17,29 @@ time-to-live: 120 # Time to live before auto despawn, in seconds. Set to -1 to d
|
|||||||
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
auto-spawn-interval: -1 # Time between auto spawns in ticks (20 ticks in a second) - Set to -1 to disable.
|
||||||
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
auto-spawn-locations: [ ] # Formatted as world:x:y:z - for example world_nether:100:10:100
|
||||||
|
|
||||||
spawn-totem:
|
spawn-egg:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
material: cave_spider_spawn_egg
|
||||||
|
name: "&4Tarantula&f Spawn Egg"
|
||||||
|
lore:
|
||||||
|
- ""
|
||||||
|
- "&8&oPlace on the ground to"
|
||||||
|
- "&8&osummon a &4Tarantula"
|
||||||
|
glow: true
|
||||||
|
craftable: true
|
||||||
|
recipe:
|
||||||
|
- string
|
||||||
|
- netherite_block
|
||||||
|
- string
|
||||||
|
- air
|
||||||
|
- ecoitems:boss_core ? nether_star
|
||||||
|
- air
|
||||||
|
- string
|
||||||
|
- netherite_block
|
||||||
|
- string
|
||||||
|
|
||||||
|
spawn-totem:
|
||||||
|
enabled: false
|
||||||
top: netherite_block
|
top: netherite_block
|
||||||
middle: red_wool
|
middle: red_wool
|
||||||
bottom: white_wool
|
bottom: white_wool
|
||||||
|
|||||||
Reference in New Issue
Block a user