mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Added checks in the events to prevent errors when Citizens NPCs perform tasks.
This commit is contained in:
parent
43fe92fe3f
commit
703b5b2f3f
@ -124,6 +124,8 @@ public class BlockListener implements Listener {
|
||||
int id = block.getTypeId();
|
||||
Material type = block.getType();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||
if (type.equals(Material.SAND) || type.equals(Material.GRAVEL)) {
|
||||
for (int y = -1; y + block.getY() >= 0; y--) {
|
||||
@ -162,6 +164,9 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
@ -272,6 +277,9 @@ public class BlockListener implements Listener {
|
||||
final int LEAF_BLOWER_LEVEL = 100;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
|
@ -64,6 +64,8 @@ public class EntityListener implements Listener {
|
||||
Entity attacker = event.getDamager();
|
||||
Entity defender = event.getEntity();
|
||||
|
||||
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
||||
|
||||
if (attacker instanceof Projectile) {
|
||||
attacker = ((Projectile) attacker).getShooter();
|
||||
}
|
||||
@ -114,6 +116,8 @@ public class EntityListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
DamageCause cause = event.getCause();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
return;
|
||||
}
|
||||
@ -172,6 +176,8 @@ public class EntityListener implements Listener {
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
LivingEntity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
entity.setFireTicks(0);
|
||||
BleedTimer.remove(entity);
|
||||
Archery.arrowRetrievalCheck(entity);
|
||||
@ -200,6 +206,8 @@ public class EntityListener implements Listener {
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (entity instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
@ -222,6 +230,8 @@ public class EntityListener implements Listener {
|
||||
public void onEnitityExplode(EntityExplodeEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (event.getEntity() instanceof TNTPrimed) {
|
||||
int id = entity.getEntityId();
|
||||
|
||||
@ -242,6 +252,9 @@ public class EntityListener implements Listener {
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int currentFoodLevel = player.getFoodLevel();
|
||||
int newFoodLevel = event.getFoodLevel();
|
||||
@ -315,6 +328,8 @@ public class EntityListener implements Listener {
|
||||
public void onEntityTame(EntityTameEvent event) {
|
||||
Player player = (Player) event.getOwner();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
EntityType type = event.getEntityType();
|
||||
|
@ -21,6 +21,8 @@ public class HardcoreListener implements Listener {
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
|
@ -58,6 +58,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
@ -88,6 +91,8 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFish(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
if (Permissions.getInstance().fishing(player)) {
|
||||
State state = event.getState();
|
||||
|
||||
@ -119,6 +124,9 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
||||
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile == null) {
|
||||
@ -137,6 +145,7 @@ public class PlayerListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||
}
|
||||
|
||||
@ -149,6 +158,8 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
/* GARBAGE COLLECTION */
|
||||
|
||||
//Bleed it out
|
||||
@ -164,6 +175,8 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
//TODO: Locale ALL the things.
|
||||
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
|
||||
String prefix = ChatColor.GOLD + "[mcMMO] ";
|
||||
@ -205,6 +218,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||
|
||||
if (profile != null) {
|
||||
@ -220,6 +234,7 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
Action action = event.getAction();
|
||||
Block block = event.getClickedBlock();
|
||||
ItemStack inHand = player.getItemInHand();
|
||||
@ -331,6 +346,9 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
|
||||
if (profile == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user