@SuppressWarnings("deprecation")
	@EventHandler (priority = EventPriority.NORMAL)
	public void onEntityDamageByEntity(EntityDamageByEntityEvent event){
		boolean eventDebug = false;
		if(event.getEntity() instanceof Player){
			// Player got damaged
			Player p = (Player) event.getEntity();
			
			// Check armor being worn by the player to see if it is restricted (wrongly)
			// If the player is wearing restricted armor that they don't normally have permission for, this removes it
			Material mat;
			boolean armorForceRemoved = false;
			if(p.getInventory().getChestplate() != null){
				mat = p.getInventory().getChestplate().getType();
				if(mat != null && !mat.equals(Material.AIR)){
					if(eventDebug) plugin.log.info("Material is not air.");
					if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
						if(eventDebug) plugin.log.info("Player does not have restriction override.");
						if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
							if(eventDebug) plugin.log.info("Item is permission-restricted.");
							// If the item is a restricted item...
							
							if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".equip-permission")) && !p.isOp()){
								if(eventDebug) plugin.log.info("Player does not have permission to equip item.");
								p.sendMessage(ChatConstants.err("Permission to equip " + mat.toString() + " denied."));
								p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".equip-permission") + ChatColor.RED));
								p.getInventory().setChestplate(new ItemStack(Material.AIR));
								p.getInventory().addItem(new ItemStack(mat,1));
								armorForceRemoved = true;
							}
						}
					}
				}
			}
			
			if(p.getInventory().getLeggings() != null){
				mat = p.getInventory().getLeggings().getType();
				if(mat != null && !mat.equals(Material.AIR)){
					if(eventDebug) plugin.log.info("Material is not air.");
					if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
						if(eventDebug) plugin.log.info("Player does not have restriction override.");
						if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
							if(eventDebug) plugin.log.info("Item is permission-restricted.");
							// If the item is a restricted item...
							
							if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".equip-permission")) && !p.isOp()){
								if(eventDebug) plugin.log.info("Player does not have permission to equip item.");
								p.sendMessage(ChatConstants.err("Permission to equip " + mat.toString() + " denied."));
								p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".equip-permission") + ChatColor.RED));
								p.getInventory().setChestplate(new ItemStack(Material.AIR));
								p.getInventory().addItem(new ItemStack(mat,1));
								armorForceRemoved = true;
							}
						}
					}
				}
			}
			
			if(p.getInventory().getBoots() != null){
				mat = p.getInventory().getBoots().getType();
				if(mat != null && !mat.equals(Material.AIR)){
					if(eventDebug) plugin.log.info("Material is not air.");
					if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
						if(eventDebug) plugin.log.info("Player does not have restriction override.");
						if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
							if(eventDebug) plugin.log.info("Item is permission-restricted.");
							// If the item is a restricted item...
							
							if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".equip-permission")) && !p.isOp()){
								if(eventDebug) plugin.log.info("Player does not have permission to equip item.");
								p.sendMessage(ChatConstants.err("Permission to equip " + mat.toString() + " denied."));
								p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".equip-permission") + ChatColor.RED));
								p.getInventory().setChestplate(new ItemStack(Material.AIR));
								p.getInventory().addItem(new ItemStack(mat,1));
								armorForceRemoved = true;
							}
						}
					}
				}
			}
			
			if(p.getInventory().getHelmet() != null){
				mat = p.getInventory().getHelmet().getType();
				if(mat != null && !mat.equals(Material.AIR)){
					if(eventDebug) plugin.log.info("Material is not air.");
					if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
						if(eventDebug) plugin.log.info("Player does not have restriction override.");
						if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
							if(eventDebug) plugin.log.info("Item is permission-restricted.");
							// If the item is a restricted item...
							
							if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".equip-permission")) && !p.isOp()){
								if(eventDebug) plugin.log.info("Player does not have permission to equip item.");
								p.sendMessage(ChatConstants.err("Permission to equip " + mat.toString() + " denied."));
								p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".equip-permission") + ChatColor.RED));
								p.getInventory().setChestplate(new ItemStack(Material.AIR));
								p.getInventory().addItem(new ItemStack(mat,1));
								armorForceRemoved = true;
							}
						}
					}
				}
			}
			
			if(armorForceRemoved) p.damage(event.getDamage()); // Redoes the damage now that the illegal armor is removed.
		}
		else {
			// Not a player
			if(event.getDamager() instanceof Player){
				// Player did the damage
				Player p = (Player) event.getDamager();
				Material mat = p.getItemInHand().getType();
				
				if(mat != null && !mat.equals(Material.AIR)){
					if(eventDebug) plugin.log.info("Material is not air.");
					if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
						if(eventDebug) plugin.log.info("Player does not have restriction override.");
						if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
							if(eventDebug) plugin.log.info("Item is permission-restricted.");
							// If the item is a restricted item...
							
							if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".attack-permission")) && !p.isOp()){
								if(eventDebug) plugin.log.info("Player does not have permission to attack with item.");
								p.sendMessage(ChatConstants.err("Permission to attack with " + mat.toString() + " denied."));
								p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".attack-permission") + ChatColor.RED));
								event.setCancelled(true);
								event.setDamage(0.00);
							}
						}
					}
				}
			}
			else if(event.getDamager() instanceof Arrow){
				// Player did the damage
				Arrow a = (Arrow) event.getDamager();
				if(a.getShooter() instanceof Player){
					Player p = (Player) a.getShooter();
					Material mat;
					
					mat = Material.BOW;				
					if(mat != null && !mat.equals(Material.AIR)){
						if(eventDebug) plugin.log.info("Material is not air.");
						if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
							if(eventDebug) plugin.log.info("Player does not have restriction override.");
							if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
								if(eventDebug) plugin.log.info("Item is permission-restricted.");
								// If the item is a restricted item...
								
								if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".attack-permission")) && !p.isOp()){
									if(eventDebug) plugin.log.info("Player does not have permission to attack with item.");
									p.sendMessage(ChatConstants.err("Permission to attack with " + mat.toString() + " denied."));
									p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".attack-permission") + ChatColor.RED));
									event.setCancelled(true);
									event.setDamage(0.00);
								}
							}
						}
					}
					
					mat = Material.ARROW;				
					if(mat != null && !mat.equals(Material.AIR)){
						if(eventDebug) plugin.log.info("Material is not air.");
						if(!RPSystem.permission.has(p, plugin.config.getString("block-restriction.override-permission")) && !p.isOp()){
							if(eventDebug) plugin.log.info("Player does not have restriction override.");
							if(plugin.itemConfig.getStringList("restricted-items").contains(mat.toString())){
								if(eventDebug) plugin.log.info("Item is permission-restricted.");
								// If the item is a restricted item...
								
								if(!RPSystem.permission.has(p, plugin.itemConfig.getString(mat.toString() + ".attack-permission")) && !p.isOp()){
									if(eventDebug) plugin.log.info("Player does not have permission to attack with item.");
									p.sendMessage(ChatConstants.err("Permission to attack with " + mat.toString() + " denied."));
									p.sendMessage(ChatConstants.err("You do not have permission: " + ChatColor.DARK_RED + plugin.itemConfig.getString(mat + ".attack-permission") + ChatColor.RED));
									event.setCancelled(true);
								}
							}
						}
					}
				}
			}
		}
	}