mirror of
https://github.com/shansen/EggCatcher.git
synced 2025-01-20 14:31:32 +01:00
Update to 2.1.3
Add ElderGuardian Variant, Add Ability to Catch Mobs by Smacking with Egg
This commit is contained in:
parent
b6d0c15740
commit
7b1d05bd05
9
pom.xml
9
pom.xml
@ -4,7 +4,7 @@
|
||||
|
||||
<groupId>me.shansen</groupId>
|
||||
<artifactId>EggCatcher</artifactId>
|
||||
<version>2.1.2-SNAPSHOT</version>
|
||||
<version>2.1.3-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EggCatcher</name>
|
||||
@ -84,6 +84,13 @@
|
||||
<artifactId>Vault</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.hotmail.com.jacob_vejvoda</groupId>
|
||||
<artifactId>ElderGuardianBoss</artifactId>
|
||||
<version>0.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/ElderGuardianBoss.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
|
@ -35,13 +35,14 @@ import java.util.List;
|
||||
public class EggCatcher extends JavaPlugin {
|
||||
public static List<Egg> eggs = new ArrayList<Egg>();
|
||||
public static Economy economy = null;
|
||||
public static PluginManager pm;
|
||||
|
||||
public void onDisable() {
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm = this.getServer().getPluginManager();
|
||||
|
||||
final EggCatcherPlayerListener playerListener = new EggCatcherPlayerListener();
|
||||
final EggCatcherEntityListener entityListener = new EggCatcherEntityListener(this);
|
||||
@ -61,5 +62,16 @@ public class EggCatcher extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// **************************** Specialized Support for Personal ElderGuardian Boss *****************************
|
||||
/*
|
||||
public static boolean isElderGuardianBoss()
|
||||
{
|
||||
if (pm.isPluginEnabled("ElderGuardianBoss")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
@ -50,6 +50,7 @@ public enum EggType {
|
||||
ENDERDRAGON(EntityType.ENDER_DRAGON, 63, "EnderDragon"),
|
||||
RABBIT(EntityType.RABBIT, 101, "Rabbit"),
|
||||
GUARDIAN(EntityType.GUARDIAN, 68, "Guardian"),
|
||||
ELDERGUARDIAN(EntityType.GUARDIAN, 68, "ElderGuardian"),
|
||||
SNOWMAN(EntityType.SNOWMAN, 97, "Snowman"),
|
||||
IRON_GOLEM(EntityType.IRON_GOLEM, 99, "VillagerGolem"),
|
||||
WITHER(EntityType.WITHER, 64, "WitherBoss"),
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Guardian;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
@ -101,8 +102,146 @@ public class EggCatcherEntityListener
|
||||
else {}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onEntityStruckByEgg(EntityDamageByEntityEvent event)
|
||||
{
|
||||
Player player = null;
|
||||
Entity entity = event.getEntity();
|
||||
EggType eggType = null;
|
||||
double vaultCost = 0.0;
|
||||
if(!(event.getDamager() instanceof Player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
player = (Player)((EntityDamageByEntityEvent)event).getDamager();
|
||||
if(player.getItemInHand().getType() != Material.EGG)
|
||||
return;
|
||||
eggType = EggType.getEggType(entity);
|
||||
if (eggType == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack takeEgg = new ItemStack(Material.EGG, (player.getItemInHand().getAmount() - 1));
|
||||
if (this.preventCatchingBabyAnimals) {
|
||||
if (entity instanceof Ageable) {
|
||||
if (!((Ageable) entity).isAdult()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.preventCatchingTamedAnimals) {
|
||||
if (entity instanceof Tameable) {
|
||||
if (((Tameable) entity).isTamed()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.preventCatchingShearedSheeps) {
|
||||
if (entity instanceof Sheep) {
|
||||
if (((Sheep) entity).isSheared()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.usePermissions) {
|
||||
if (!player.hasPermission("eggcatcher.catch." + eggType.getFriendlyName().toLowerCase())) {
|
||||
player.sendMessage(config.getString("Messages.PermissionFail"));
|
||||
if (!this.looseEggOnFail) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.useHealthPercentage) {
|
||||
double healthPercentage = config.getDouble("HealthPercentage." + eggType.getFriendlyName());
|
||||
double currentHealth = ((LivingEntity) entity).getHealth() * 100.0 / ((LivingEntity) entity)
|
||||
.getMaxHealth();
|
||||
if (healthPercentage < currentHealth) {
|
||||
if (this.healthPercentageFailMessage.length() > 0) {
|
||||
player.sendMessage(String.format(this.healthPercentageFailMessage, healthPercentage));
|
||||
}
|
||||
if (!this.looseEggOnFail) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.useCatchChance) {
|
||||
double catchChance = config.getDouble("CatchChance." + eggType.getFriendlyName());
|
||||
if (Math.random() * 100 <= catchChance) {
|
||||
if (this.catchChanceSuccessMessage.length() > 0) {
|
||||
player.sendMessage(catchChanceSuccessMessage);
|
||||
}
|
||||
} else {
|
||||
if (this.catchChanceFailMessage.length() > 0) {
|
||||
player.sendMessage(this.catchChanceFailMessage);
|
||||
}
|
||||
if (!this.looseEggOnFail) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean freeCatch = player.hasPermission("eggcatcher.free");
|
||||
|
||||
if (this.useVaultCost && !freeCatch) {
|
||||
vaultCost = config.getDouble("VaultCost." + eggType.getFriendlyName());
|
||||
if (!EggCatcher.economy.has(player.getName(), vaultCost)) {
|
||||
player.sendMessage(String.format(config.getString("Messages.VaultFail"), vaultCost));
|
||||
if (!this.looseEggOnFail) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
EggCatcher.economy.withdrawPlayer(player.getName(), vaultCost);
|
||||
|
||||
if (!this.vaultTargetBankAccount.isEmpty()) {
|
||||
EggCatcher.economy.bankDeposit(this.vaultTargetBankAccount, vaultCost);
|
||||
}
|
||||
player.sendMessage(String.format(config.getString("Messages.VaultSuccess"), vaultCost));
|
||||
}
|
||||
}
|
||||
|
||||
if (this.useItemCost && !freeCatch) {
|
||||
int itemId = config.getInt("ItemCost.ItemId", 266);
|
||||
int itemData = config.getInt("ItemCost.ItemData", 0);
|
||||
int itemAmount = config.getInt("ItemCost.Amount." + eggType.getFriendlyName(), 0);
|
||||
ItemStack itemStack = new ItemStack(itemId, itemAmount, (short) itemData);
|
||||
if (player.getInventory().containsAtLeast(itemStack, itemStack.getAmount())) {
|
||||
player.sendMessage(String.format(config.getString("Messages.ItemCostSuccess"),
|
||||
String.valueOf(itemAmount)));
|
||||
player.getInventory().removeItem(itemStack);
|
||||
} else {
|
||||
player.sendMessage(String.format(config.getString("Messages.ItemCostFail"),
|
||||
String.valueOf(itemAmount)));
|
||||
if (!this.looseEggOnFail) {
|
||||
player.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
entity.getWorld().dropItem(entity.getLocation(), makeEgg(eggType, entity));
|
||||
// **************************** Specialized Support for Personal ElderGuardian Boss *****************************
|
||||
// killElderGuardian(entity);
|
||||
entity.remove();
|
||||
if (this.explosionEffect) {
|
||||
entity.getWorld().createExplosion(entity.getLocation(), 0);
|
||||
}
|
||||
if (this.smokeEffect) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.SMOKE, 0);
|
||||
}
|
||||
if(takeEgg.getAmount() > 0){
|
||||
player.getInventory().setItemInHand(takeEgg);
|
||||
}else{
|
||||
player.getInventory().setItemInHand(new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onEntityHitByEgg(EntityDamageEvent event) {
|
||||
@ -118,11 +257,13 @@ public class EggCatcherEntityListener
|
||||
|
||||
damageEvent = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (!(damageEvent.getDamager() instanceof Egg)) {
|
||||
if (!((damageEvent.getDamager() instanceof Egg))) {
|
||||
return;
|
||||
}
|
||||
|
||||
egg = (Egg) damageEvent.getDamager();
|
||||
if((damageEvent.getDamager() instanceof Egg))
|
||||
{
|
||||
egg = (Egg) damageEvent.getDamager();
|
||||
}
|
||||
eggType = EggType.getEggType(entity);
|
||||
|
||||
if (eggType == null) {
|
||||
@ -165,8 +306,10 @@ public class EggCatcherEntityListener
|
||||
}
|
||||
|
||||
if (egg.getShooter() instanceof Player) {
|
||||
Player player = (Player) egg.getShooter();
|
||||
|
||||
Player player = null;
|
||||
if(egg.getShooter() instanceof Player){
|
||||
player = (Player) egg.getShooter();
|
||||
}
|
||||
if (this.usePermissions) {
|
||||
if (!player.hasPermission("eggcatcher.catch." + eggType.getFriendlyName().toLowerCase())) {
|
||||
player.sendMessage(config.getString("Messages.PermissionFail"));
|
||||
@ -273,7 +416,21 @@ public class EggCatcherEntityListener
|
||||
if (this.smokeEffect) {
|
||||
entity.getWorld().playEffect(entity.getLocation(), Effect.SMOKE, 0);
|
||||
}
|
||||
ItemStack eggStack = new ItemStack(383, 1, eggType.getCreatureId());
|
||||
entity.getWorld().dropItem(entity.getLocation(), makeEgg(eggType, entity));
|
||||
// **************************** Specialized Support for Personal ElderGuardian Boss *****************************
|
||||
// killElderGuardian(entity);
|
||||
|
||||
if (!this.spawnChickenOnSuccess) {
|
||||
if (!EggCatcher.eggs.contains(egg)) {
|
||||
EggCatcher.eggs.add(egg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemStack makeEgg(EggType eggType, Entity entity)
|
||||
{
|
||||
ItemStack eggStack = new ItemStack(383, 1, eggType.getCreatureId());
|
||||
String customName = ((LivingEntity)entity).getCustomName();
|
||||
ItemMeta meta = eggStack.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
@ -358,6 +515,10 @@ public class EggCatcherEntityListener
|
||||
lore.add(ChatColor.BLUE + "Color: " + ChatColor.WHITE + ((Wolf)entity).getCollarColor().name());
|
||||
}
|
||||
|
||||
if((entity instanceof Guardian && ((Guardian)entity).isElder())) {
|
||||
lore.add(ChatColor.BLUE + "Variant: " + ChatColor.WHITE + "Elder");
|
||||
}
|
||||
|
||||
if ((entity instanceof Horse))
|
||||
{
|
||||
if (((Horse)entity).getVariant() == Horse.Variant.HORSE) {
|
||||
@ -394,14 +555,9 @@ public class EggCatcherEntityListener
|
||||
lore.add(ChatColor.BLUE + "Tamed");
|
||||
}
|
||||
}
|
||||
if (!this.spawnChickenOnSuccess) {
|
||||
if (!EggCatcher.eggs.contains(egg)) {
|
||||
EggCatcher.eggs.add(egg);
|
||||
}
|
||||
}
|
||||
meta.setLore(lore);
|
||||
eggStack.setItemMeta(meta);
|
||||
entity.getWorld().dropItem(entity.getLocation(), eggStack);
|
||||
return eggStack;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -410,4 +566,16 @@ public class EggCatcherEntityListener
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
//**************************** Specialized Support for Personal ElderGuardian Boss *****************************
|
||||
/*
|
||||
public void killElderGuardian(Entity entity)
|
||||
{
|
||||
if((entity instanceof Guardian && ((Guardian)entity).isElder())) {
|
||||
if(EggCatcher.isElderGuardianBoss()){
|
||||
io.hotmail.com.jacob_vejvoda.ElderGuardianBoss.ElderGuardianBoss.killBoss(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -62,6 +62,9 @@ public class EggCatcherPlayerClickListener implements org.bukkit.event.Listener
|
||||
if ((entity instanceof Skeleton)) {
|
||||
((Skeleton)entity).setSkeletonType(Skeleton.SkeletonType.valueOf(l));
|
||||
}
|
||||
if ((entity instanceof Guardian)){
|
||||
((Guardian)entity).setElder(true);
|
||||
}
|
||||
}
|
||||
if (s.contains("Age:")) {
|
||||
String l = s.replaceAll("§9", "");
|
||||
|
@ -42,6 +42,7 @@ CatchChance:
|
||||
Endermite: 40.0
|
||||
Rabbit: 100.0
|
||||
Guardian: 10.0
|
||||
ElderGuardian: 10.0
|
||||
Snowman: 40.0
|
||||
VillagerGolem: 40.0
|
||||
WitherBoss: 10.0
|
||||
@ -75,6 +76,7 @@ VaultCost:
|
||||
Endermite: 0.0
|
||||
Rabbit: 0.0
|
||||
Guardian: 0.0
|
||||
ElderGuardian: 0.0
|
||||
Snowman: 0.0
|
||||
VillagerGolem: 0.0
|
||||
WitherBoss: 0.0
|
||||
@ -111,6 +113,7 @@ ItemCost:
|
||||
Endermite: 0
|
||||
Rabbit: 0
|
||||
Guardian: 0
|
||||
ElderGuardian: 0
|
||||
Snowman: 0
|
||||
VillagerGolem: 0
|
||||
WitherBoss: 0
|
||||
@ -144,6 +147,7 @@ HealthPercentage:
|
||||
Endermite: 100.0
|
||||
Rabbit: 100.0
|
||||
Guardian: 100.0
|
||||
ElderGuardian: 100.0
|
||||
Snowman: 100.0
|
||||
VillagerGolem: 100.0
|
||||
WitherBoss: 100.0
|
||||
|
@ -1,9 +1,9 @@
|
||||
name: EggCatcher
|
||||
version: 2.1.2
|
||||
version: 2.1.3
|
||||
description: This plugin allows you to catch mobs in eggs.
|
||||
author: shansen
|
||||
|
||||
main: me.shansen.EggCatcher.EggCatcher
|
||||
softdepend: [ElderGuardianBoss]
|
||||
|
||||
permissions:
|
||||
eggcatcher.catch.*:
|
||||
@ -38,6 +38,7 @@ permissions:
|
||||
eggcatcher.catch.enderdragon: true
|
||||
eggcatcher.catch.rabbit: true
|
||||
eggcatcher.catch.guardian: true
|
||||
eggcatcher.catch.elderguardian: true
|
||||
eggcatcher.catch.snowman: true
|
||||
eggcatcher.catch.villagergolem: true
|
||||
eggcatcher.catch.witherboss: true
|
||||
|
Loading…
Reference in New Issue
Block a user