|
@@ -1,31 +1,31 @@
|
|
|
package com.gmail.nossr50.listeners;
|
|
|
|
|
|
+import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
|
import com.gmail.nossr50.core.config.skills.AdvancedConfig;
|
|
|
import com.gmail.nossr50.core.config.skills.Config;
|
|
|
import com.gmail.nossr50.core.config.skills.WorldBlacklist;
|
|
|
-import com.gmail.nossr50.config.experience.ExperienceConfig;
|
|
|
+import com.gmail.nossr50.core.data.UserManager;
|
|
|
import com.gmail.nossr50.core.datatypes.meta.OldName;
|
|
|
import com.gmail.nossr50.core.datatypes.player.McMMOPlayer;
|
|
|
-import com.gmail.nossr50.core.skills.SubSkillType;
|
|
|
-import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
|
|
|
-import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
|
|
-import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
|
|
-import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
|
|
-import com.gmail.nossr50.mcMMO;
|
|
|
import com.gmail.nossr50.core.party.PartyManager;
|
|
|
+import com.gmail.nossr50.core.skills.SubSkillType;
|
|
|
import com.gmail.nossr50.core.skills.primary.archery.Archery;
|
|
|
import com.gmail.nossr50.core.skills.primary.fishing.Fishing;
|
|
|
import com.gmail.nossr50.core.skills.primary.mining.BlastMining;
|
|
|
import com.gmail.nossr50.core.skills.primary.mining.MiningManager;
|
|
|
import com.gmail.nossr50.core.skills.primary.taming.Taming;
|
|
|
import com.gmail.nossr50.core.skills.primary.taming.TamingManager;
|
|
|
+import com.gmail.nossr50.core.skills.subskills.interfaces.InteractType;
|
|
|
import com.gmail.nossr50.core.util.BlockUtils;
|
|
|
import com.gmail.nossr50.core.util.Misc;
|
|
|
import com.gmail.nossr50.core.util.Permissions;
|
|
|
-import com.gmail.nossr50.core.data.UserManager;
|
|
|
import com.gmail.nossr50.core.util.skills.CombatUtils;
|
|
|
import com.gmail.nossr50.core.worldguard.WorldGuardManager;
|
|
|
import com.gmail.nossr50.core.worldguard.WorldGuardUtils;
|
|
|
+import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
|
|
+import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
|
|
+import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
|
|
|
+import com.gmail.nossr50.mcMMO;
|
|
|
import org.bukkit.Material;
|
|
|
import org.bukkit.OfflinePlayer;
|
|
|
import org.bukkit.block.Block;
|
|
@@ -55,15 +55,13 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
- public void onEntityTargetEntity(EntityTargetLivingEntityEvent event)
|
|
|
- {
|
|
|
- if(!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
|
|
|
+ public void onEntityTargetEntity(EntityTargetLivingEntityEvent event) {
|
|
|
+ if (!ExperienceConfig.getInstance().isEndermanEndermiteFarmingPrevented())
|
|
|
return;
|
|
|
|
|
|
//Prevent entities from giving XP if they target endermite
|
|
|
- if(event.getTarget() instanceof Endermite)
|
|
|
- {
|
|
|
- if(event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
|
|
|
+ if (event.getTarget() instanceof Endermite) {
|
|
|
+ if (event.getEntity().getMetadata(mcMMO.entityMetadataKey) == null || event.getEntity().getMetadata(mcMMO.entityMetadataKey).size() <= 0)
|
|
|
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
|
|
}
|
|
|
}
|
|
@@ -71,17 +69,15 @@ public class EntityListener implements Listener {
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onEntityShootBow(EntityShootBowEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
- if(event.getEntity() instanceof Player)
|
|
|
- {
|
|
|
+ if (event.getEntity() instanceof Player) {
|
|
|
Player player = (Player) event.getEntity();
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -105,17 +101,15 @@ public class EntityListener implements Listener {
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
- if(event.getEntity() instanceof Player)
|
|
|
- {
|
|
|
+ if (event.getEntity() instanceof Player) {
|
|
|
Player player = (Player) event.getEntity();
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -133,13 +127,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Monitor EntityChangeBlock events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Block block = event.getBlock();
|
|
@@ -159,14 +152,12 @@ public class EntityListener implements Listener {
|
|
|
if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
|
|
|
mcMMO.getPlaceStore().setFalse(block);
|
|
|
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
|
|
|
- }
|
|
|
- else if (isTracked) {
|
|
|
+ } else if (isTracked) {
|
|
|
mcMMO.getPlaceStore().setTrue(block);
|
|
|
}
|
|
|
} else if ((block.getType() == Material.REDSTONE_ORE)) {
|
|
|
return;
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
if (mcMMO.getPlaceStore().isTrue(block)) {
|
|
|
mcMMO.getPlaceStore().setFalse(block);
|
|
|
}
|
|
@@ -176,13 +167,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle EntityDamageByEntity events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
if (event instanceof FakeEntityDamageByEntityEvent) {
|
|
@@ -192,9 +182,8 @@ public class EntityListener implements Listener {
|
|
|
if (event.getEntity() instanceof ArmorStand) {
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey))
|
|
|
- {
|
|
|
+
|
|
|
+ if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey)) {
|
|
|
event.setCancelled(true);
|
|
|
return;
|
|
|
}
|
|
@@ -203,14 +192,12 @@ public class EntityListener implements Listener {
|
|
|
Entity defender = event.getEntity();
|
|
|
Entity attacker = event.getDamager();
|
|
|
|
|
|
- if(attacker instanceof Player)
|
|
|
- {
|
|
|
+ if (attacker instanceof Player) {
|
|
|
Player player = (Player) attacker;
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -221,7 +208,7 @@ public class EntityListener implements Listener {
|
|
|
Player attackingPlayer = (Player) attacker;
|
|
|
if (event.getDamage(DamageModifier.ABSORPTION) > 0) {
|
|
|
//If friendly fire is off don't allow players to hurt one another
|
|
|
- if(!Config.getInstance().getPartyFriendlyFire())
|
|
|
+ if (!Config.getInstance().getPartyFriendlyFire())
|
|
|
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
|
|
event.setCancelled(true);
|
|
|
return;
|
|
@@ -252,7 +239,6 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
if (Misc.isNPCEntity(attacker)) {
|
|
|
return;
|
|
|
}
|
|
@@ -263,15 +249,13 @@ public class EntityListener implements Listener {
|
|
|
if (projectileSource instanceof LivingEntity) {
|
|
|
attacker = (LivingEntity) projectileSource;
|
|
|
}
|
|
|
- }
|
|
|
- else if (attacker instanceof Tameable) {
|
|
|
+ } else if (attacker instanceof Tameable) {
|
|
|
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
|
|
|
|
|
|
if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) {
|
|
|
attacker = (Entity) animalTamer;
|
|
|
}
|
|
|
- }
|
|
|
- else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
|
|
+ } else if (attacker instanceof TNTPrimed && defender instanceof Player) {
|
|
|
if (BlastMining.processBlastMiningExplosion(event, (TNTPrimed) attacker, (Player) defender)) {
|
|
|
return;
|
|
|
}
|
|
@@ -292,7 +276,7 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
//Party Friendly Fire
|
|
|
- if(!Config.getInstance().getPartyFriendlyFire())
|
|
|
+ if (!Config.getInstance().getPartyFriendlyFire())
|
|
|
if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
|
|
|
event.setCancelled(true);
|
|
|
return;
|
|
@@ -305,17 +289,14 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* This sets entity names back to whatever they are supposed to be
|
|
|
*/
|
|
|
- if(!(attacker instanceof Player) && defender instanceof Player)
|
|
|
- {
|
|
|
- if(event.getFinalDamage() >= ((LivingEntity) defender).getHealth())
|
|
|
- {
|
|
|
+ if (!(attacker instanceof Player) && defender instanceof Player) {
|
|
|
+ if (event.getFinalDamage() >= ((LivingEntity) defender).getHealth()) {
|
|
|
List<MetadataValue> metadataValue = attacker.getMetadata("mcMMO_oldName");
|
|
|
|
|
|
- if(metadataValue.size() <= 0)
|
|
|
+ if (metadataValue.size() <= 0)
|
|
|
return;
|
|
|
|
|
|
- if(metadataValue != null)
|
|
|
- {
|
|
|
+ if (metadataValue != null) {
|
|
|
OldName oldName = (OldName) metadataValue.get(0);
|
|
|
attacker.setCustomName(oldName.asString());
|
|
|
attacker.setCustomNameVisible(false);
|
|
@@ -327,22 +308,19 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle EntityDamage events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to modify
|
|
|
+ * @param event The event to modify
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
|
public void onEntityDamage(EntityDamageEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
- if(event.getEntity() instanceof Player)
|
|
|
- {
|
|
|
+ if (event.getEntity() instanceof Player) {
|
|
|
Player player = (Player) event.getEntity();
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -408,19 +386,15 @@ public class EntityListener implements Listener {
|
|
|
mcMMOPlayer.actualizeRecentlyHurt();
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- else if (livingEntity instanceof Tameable) {
|
|
|
+ } else if (livingEntity instanceof Tameable) {
|
|
|
Tameable pet = (Tameable) livingEntity;
|
|
|
AnimalTamer owner = pet.getOwner();
|
|
|
|
|
|
- if(owner instanceof Player)
|
|
|
- {
|
|
|
+ if (owner instanceof Player) {
|
|
|
Player player = (Player) owner;
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -493,13 +467,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Monitor EntityDeath events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
public void onEntityDeathLowest(EntityDeathEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
LivingEntity entity = event.getEntity();
|
|
@@ -526,13 +499,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Monitor EntityDeath events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
|
public void onEntityDeath(EntityDeathEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
LivingEntity entity = event.getEntity();
|
|
@@ -547,13 +519,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Monitor CreatureSpawn events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
LivingEntity entity = event.getEntity();
|
|
@@ -583,13 +554,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle ExplosionPrime events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to modify
|
|
|
+ * @param event The event to modify
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Entity entity = event.getEntity();
|
|
@@ -607,9 +577,8 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -623,13 +592,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle EntityExplode events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to modify
|
|
|
+ * @param event The event to modify
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
|
public void onEnitityExplode(EntityExplodeEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Entity entity = event.getEntity();
|
|
@@ -647,9 +615,8 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -664,13 +631,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle EntityExplode events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to modify
|
|
|
+ * @param event The event to modify
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
|
|
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Entity entity = event.getEntity();
|
|
@@ -685,13 +651,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle FoodLevelChange events that involve modifying the event.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to modify
|
|
|
+ * @param event The event to modify
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
|
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Entity entity = event.getEntity();
|
|
@@ -703,9 +668,8 @@ public class EntityListener implements Listener {
|
|
|
Player player = (Player) entity;
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -728,27 +692,27 @@ public class EntityListener implements Listener {
|
|
|
*/
|
|
|
switch (player.getInventory().getItemInMainHand().getType()) {
|
|
|
case BAKED_POTATO: /*
|
|
|
- * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
case BEETROOT:
|
|
|
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
|
|
|
case CARROT: /*
|
|
|
- * RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
case GOLDEN_CARROT: /*
|
|
|
- * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
case MUSHROOM_STEW: /*
|
|
|
- * RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
case PUMPKIN_PIE: /*
|
|
|
- * RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
|
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
|
|
}
|
|
@@ -757,9 +721,9 @@ public class EntityListener implements Listener {
|
|
|
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
|
|
case MELON_SLICE: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
|
|
|
case POISONOUS_POTATO: /*
|
|
|
- * RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
|
|
|
- * @ 1000
|
|
|
- */
|
|
|
+ * RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
|
|
|
+ * @ 1000
|
|
|
+ */
|
|
|
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
|
|
|
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_FARMERS_DIET)) {
|
|
|
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(newFoodLevel));
|
|
@@ -767,9 +731,9 @@ public class EntityListener implements Listener {
|
|
|
return;
|
|
|
|
|
|
case COOKED_SALMON: /*
|
|
|
- * RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
|
|
|
- * 1000
|
|
|
- */
|
|
|
+ * RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
|
|
|
+ * 1000
|
|
|
+ */
|
|
|
if (Permissions.isSubSkillEnabled(player, SubSkillType.FISHING_FISHERMANS_DIET)) {
|
|
|
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel1, newFoodLevel));
|
|
|
}
|
|
@@ -789,13 +753,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Monitor EntityTame events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to watch
|
|
|
+ * @param event The event to watch
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onEntityTame(EntityTameEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
if (event instanceof FakeEntityTameEvent) {
|
|
@@ -805,9 +768,8 @@ public class EntityListener implements Listener {
|
|
|
Player player = (Player) event.getOwner();
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -824,13 +786,12 @@ public class EntityListener implements Listener {
|
|
|
/**
|
|
|
* Handle EntityTarget events.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to process
|
|
|
+ * @param event The event to process
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
|
public void onEntityTarget(EntityTargetEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
Entity entity = event.getEntity();
|
|
@@ -843,9 +804,8 @@ public class EntityListener implements Listener {
|
|
|
Player player = (Player) target;
|
|
|
|
|
|
/* WORLD GUARD MAIN FLAG CHECK */
|
|
|
- if(WorldGuardUtils.isWorldGuardLoaded())
|
|
|
- {
|
|
|
- if(!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
+ if (WorldGuardUtils.isWorldGuardLoaded()) {
|
|
|
+ if (!WorldGuardManager.getInstance().hasMainFlag(player))
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -867,13 +827,12 @@ public class EntityListener implements Listener {
|
|
|
* Handle PotionSplash events in order to fix broken Splash Potion of
|
|
|
* Saturation.
|
|
|
*
|
|
|
- * @param event
|
|
|
- * The event to process
|
|
|
+ * @param event The event to process
|
|
|
*/
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onPotionSplash(PotionSplashEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
for (PotionEffect effect : ((PotionMeta) event.getPotion().getItem().getItemMeta()).getCustomEffects()) {
|
|
@@ -887,11 +846,11 @@ public class EntityListener implements Listener {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
|
public void onPigZapEvent(PigZapEvent event) {
|
|
|
/* WORLD BLACKLIST CHECK */
|
|
|
- if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
+ if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
|
|
return;
|
|
|
|
|
|
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {
|